Skip to content

Commit

Permalink
Version 1.1 LogConsole
Browse files Browse the repository at this point in the history
  • Loading branch information
maverick1981 committed Apr 10, 2012
1 parent 1f458a6 commit a124309
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 17 deletions.
1 change: 1 addition & 0 deletions plugins/com.dotcms.consoleLog4j/conf/tiles-defs-ext.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!-- You this file to override or add tiles for backend struts actions.
It will add definition tags looking for the name attribute as the key if override is needed-->


<definition name="portlet.ext.plugins.logMan.struts" extends="portal">
<put name="content" value="/plugins/com.dotcms.consoleLog4j/view/view_log_console.jsp" />
<put name="portlet_sub_nav"
Expand Down
3 changes: 1 addition & 2 deletions plugins/com.dotcms.escalation/conf/Language-ext.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
javax.portlet.title.EXT_EXPCONTENT_TOOL=Expiry Tool Manager
EXP_Manager=Expiry Content Manual Job Tool
EXP_ML=Manual Launch
EXP_button_launch=Run Manual Escalation
EXP_label1=Pippo
EXP_button_launch=Run Manual Escalation
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
import com.dotmarketing.util.Config;
import com.dotmarketing.util.ConfigUtils;
import com.dotmarketing.util.DateUtil;
import com.dotmarketing.util.HostUtil;
import com.dotmarketing.util.InodeUtils;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.PaginatedArrayList;
Expand Down Expand Up @@ -319,8 +320,6 @@ public void publish(Contentlet contentlet, User user, boolean respectFrontendRol
}

conFac.save(contentlet);
ActivityLogger.logInfo(this.getClass(), "Publish Content",
"User " + user.getFirstName() + " is publishing content " + contentlet.getTitle() , contentlet.getHost());
// Set contentlet to live and unlocked
APILocator.getVersionableAPI().setLive(contentlet);
// APILocator.getVersionableAPI().setLocked(contentlet.getIdentifier(),
Expand Down Expand Up @@ -1012,7 +1011,7 @@ public void delete(List<Contentlet> contentlets, User user, boolean respectFront
MultiTreeFactory.deleteMultiTree(mt);
}
ActivityLogger.logInfo(this.getClass(), "delete Contentlet ",
" user " + user.getFirstName() + " deleted content titled '" + con.getTitle() , con.getHost());
" user " + user.getFirstName() + " deleted content titled '" + con.getTitle() , APILocator.getHostAPI().find(con.getHost(), user, true).getHostname());
}

// jira.dotmarketing.net/browse/DOTCMS-1073
Expand Down Expand Up @@ -1268,8 +1267,7 @@ public void archive(Contentlet contentlet, User user, boolean respectFrontendRol

// sets deleted to true
APILocator.getVersionableAPI().setDeleted(workingContentlet, true);
ActivityLogger.logInfo(this.getClass(), "archieve contentlet ", " User " + user.getFirstName() + " archieved content titled '" + workingContentlet.getTitle()
+ "' ", contentlet.getHost());

// Updating lucene index
indexAPI.addContentToIndex(workingContentlet);
indexAPI.removeContentFromLiveIndex(liveContentlet);
Expand Down
2 changes: 1 addition & 1 deletion src/com/dotmarketing/business/PermissionBitAPIImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ public void assignPermissions(List<Permission> permissions, Permissionable permi

permissionFactory.assignPermissions(includingLockedRolePermissions, permissionable);

AdminLogger.log(PermissionBitAPIImpl.class, "assisgnPermissions", "Assigning permissions to :"+permissionable.getPermissionId(),user);
AdminLogger.log(PermissionBitAPIImpl.class, "assign Permissions Action", "Assigning permissions to :"+permissionable.getPermissionId(),user);
}

public Set<User> getReadUsers(Permissionable permissionable) throws DotDataException {
Expand Down
2 changes: 2 additions & 0 deletions src/com/dotmarketing/portal/struts/DotPortletAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public void _deleteWebAsset(ActionRequest req, ActionResponse res, PortletConfig

if (WebAssetFactory.archiveAsset(webAsset, user.getUserId())) {
SessionMessages.add(httpReq, "message", "message." + webAsset.getType() + ".delete");
ActivityLogger.logInfo(this.getClass(), "Delete WebAsset action", "User " + user.getPrimaryKey() + " deleting" + webAsset.getType()+" named "+webAsset.getTitle(), HostUtil.hostNameUtil(req, _getUser(req)));
} else {
SessionMessages.add(httpReq, "message", "message." + webAsset.getType() + ".delete.locked");
}
Expand Down Expand Up @@ -218,6 +219,7 @@ public void _unPublishWebAsset(ActionRequest req, ActionResponse res, PortletCon
if (InodeUtils.isSet(webAsset.getInode())) {
// calls the asset factory edit
if (WebAssetFactory.unPublishAsset(webAsset, userId, parent)) {
ActivityLogger.logInfo(this.getClass(), "Unpublish WebAsset action", "User " + user.getPrimaryKey() + " unpublishing" + webAsset.getType()+" named "+webAsset.getTitle(), HostUtil.hostNameUtil(req, _getUser(req)));
SessionMessages.add(httpReq, "message", "message." + webAsset.getType() + ".unpublished");
} else {
SessionMessages.add(httpReq, "message", "message." + webAsset.getType() + ".unpublish.notlive_or_locked");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
import com.dotmarketing.portlets.structure.model.Field;
import com.dotmarketing.portlets.structure.model.Relationship;
import com.dotmarketing.portlets.structure.model.Structure;
import com.dotmarketing.util.ActivityLogger;
import com.dotmarketing.util.Config;
import com.dotmarketing.util.HostUtil;
import com.dotmarketing.util.InodeUtils;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.PortletURLUtil;
Expand All @@ -103,6 +105,8 @@ public class EditContentletAction extends DotPortletAction implements DotPortlet
private FieldAPI fAPI;
private RelationshipAPI relAPI;
private HostWebAPI hostWebAPI;

private String currentHost;

public EditContentletAction() {
catAPI = APILocator.getCategoryAPI();
Expand Down Expand Up @@ -136,7 +140,8 @@ public void processAction(ActionMapping mapping, ActionForm form, PortletConfig

User user = _getUser(req);


// retrieve current host
currentHost = HostUtil.hostNameUtil(req, user);
//http://jira.dotmarketing.net/browse/DOTCMS-2273
//To transport PortletConfig, Layout objects using session.
//Needed for sendContentletPublishNotification of ContentletWebAPIImpl.java
Expand Down Expand Up @@ -397,6 +402,7 @@ else if ((cmd != null) && cmd.equals(com.dotmarketing.util.Constants.UNPUBLISH))
// calls the asset factory edit
try{
conAPI.unpublish(contentletToEdit, user, false);
ActivityLogger.logInfo(this.getClass(), "Unpublishing Contentlet "," User "+user.getFirstName()+" Unpublished content titled '"+contentletToEdit.getTitle()+"'", HostUtil.hostNameUtil(req, user));
SessionMessages.add(httpReq, "message", "message.contentlet.unpublished");
}catch(DotLockException dlock){
SessionMessages.add(httpReq, "error", "message.contentlet.cannot.be.unlocked");
Expand Down Expand Up @@ -1251,6 +1257,7 @@ public void _saveWebAsset(ActionRequest req, ActionResponse res, PortletConfig c

if ((subcmd != null) && subcmd.equals(com.dotmarketing.util.Constants.PUBLISH)) {
Logger.debug(this, "publishing after checkin");
ActivityLogger.logInfo(this.getClass(), "Publishing Contentlet "," User "+user.getFirstName()+" published content titled '"+currentContentlet.getTitle(), HostUtil.hostNameUtil(req, user));
APILocator.getVersionableAPI().setLive(currentContentlet);
}

Expand Down Expand Up @@ -1935,6 +1942,8 @@ public void unpublish(List<Contentlet> contentToIndexAfterCommit) throws DotCont
try{
conAPI.unpublish(contentlet, user, false);
HibernateUtil.commitTransaction();
ActivityLogger.logInfo(this.getClass(), "Unublish contentlet action", " User " + user.getFirstName() + " Unpublished content titled '" + contentlet.getTitle()
+ "' ", currentHost);
}catch (DotContentletStateException e) {
stateError = true;
}catch(DotDataException de){
Expand Down Expand Up @@ -2054,6 +2063,8 @@ public void publish(List<Contentlet> contentToIndexAfterCommit) throws DotConten
HibernateUtil.startTransaction();
try{
conAPI.publish(contentlet, user, false);
ActivityLogger.logInfo(this.getClass(), "Publish contentlet action", " User " + user.getFirstName() + " Published content titled '" + contentlet.getTitle()
+ "' ", currentHost);
HibernateUtil.commitTransaction();
}catch (DotContentletStateException e) {
stateError = true;
Expand Down Expand Up @@ -2180,6 +2191,8 @@ public void archive(List<Contentlet> contentToIndexAfterCommit) throws DotConten
HibernateUtil.startTransaction();
try{
conAPI.archive(contentlet, user, false);
ActivityLogger.logInfo(this.getClass(), "Archieve contentlet action", " User " + user.getFirstName() + " Archieved content titled '" + contentlet.getTitle()
+ "' ", currentHost);
HibernateUtil.commitTransaction();
}catch (DotContentletStateException e) {
stateError = true;
Expand Down Expand Up @@ -2406,6 +2419,8 @@ public void unarchive(List<Contentlet> contentToIndexAfterCommit) throws DotCont
HibernateUtil.startTransaction();
try{
conAPI.unarchive(contentlet, user, false);
ActivityLogger.logInfo(this.getClass(), "Unarchieve contentlet action", " User " + user.getFirstName() + " Unarchieved content titled '" + contentlet.getTitle()
+ "' ", currentHost);
HibernateUtil.commitTransaction();
}catch (DotContentletStateException e) {
stateError = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private boolean _saveField(ActionForm form, ActionRequest req, ActionResponse re
// saves this field
FieldFactory.saveField(field);

ActivityLogger.logInfo(ActivityLogger.class, "Save Field", "User " + _getUser(req).getUserId() + "/" + _getUser(req).getFirstName() + " added field " + field.getFieldName() + " to " + structure.getName()
ActivityLogger.logInfo(ActivityLogger.class, "Save Field Action", "User " + _getUser(req).getUserId() + "/" + _getUser(req).getFirstName() + " added field " + field.getFieldName() + " to " + structure.getName()
+ " Structure.", HostUtil.hostNameUtil(req, _getUser(req)));

FieldsCache.removeFields(structure);
Expand Down Expand Up @@ -495,7 +495,7 @@ private void _deleteField(ActionForm form, ActionRequest req, ActionResponse res
HibernateUtil.commitTransaction();
FieldsCache.removeFields(structure);

ActivityLogger.logInfo(ActivityLogger.class, "Save Field Action", "User " + _getUser(req).getUserId() + "/" + _getUser(req).getFirstName() + " added field " + field.getFieldName() + " to " + structure.getName()
ActivityLogger.logInfo(ActivityLogger.class, "Delete Field Action", "User " + _getUser(req).getUserId() + "/" + _getUser(req).getFirstName() + " deleted field " + field.getFieldName() + " to " + structure.getName()
+ " Structure.", HostUtil.hostNameUtil(req, _getUser(req)));

StructureCache.removeStructure(structure);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ private void _saveStructure(ActionForm form, ActionRequest req, ActionResponse r
}
System.out.println("L'host settato all'interno dellastructure è: " + structure.getHost());
ActivityLogger.logInfo(ActivityLogger.class, "Save Structure Action", "User " + _getUser(req).getUserId() + "/" + _getUser(req).getFirstName() + " added structure "
+ structure.getName() + " Structure.", HostUtil.hostNameUtil(req, _getUser(req)));
+ structure.getName() + ".", HostUtil.hostNameUtil(req, _getUser(req)));

// Saving the structure in cache
StructureCache.removeStructure(structure);
Expand Down Expand Up @@ -573,7 +573,7 @@ private void _deleteStructure(ActionForm form, ActionRequest req, ActionResponse
StructureFactory.deleteStructure(structure);

ActivityLogger.logInfo(ActivityLogger.class, "Delete Structure Action", "User " + _getUser(req).getUserId() + "/" + _getUser(req).getFirstName() + " deleted structure "
+ structure.getTitle() + " Structure.", HostUtil.hostNameUtil(req, _getUser(req)));
+ structure.getName() + " Structure.", HostUtil.hostNameUtil(req, _getUser(req)));

// Removing the structure from cache
FieldsCache.removeFields(structure);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ public void _editWebAsset(ActionRequest req, ActionResponse res,
} else {
cf.setHostId(templateHost.getIdentifier());
}
ActivityLogger.logInfo(this.getClass(), "Edit Template action", "User " + user.getPrimaryKey() + " edit template " + cf.getTitle(), HostUtil.hostNameUtil(req, _getUser(req)));
cf.setImage(fileAsContent?imageContentlet.getIdentifier():imageFile.getIdentifier());
}

Expand Down Expand Up @@ -531,7 +532,7 @@ public void _saveWebAsset(ActionRequest req, ActionResponse res,

APILocator.getTemplateAPI().saveTemplate(newTemplate,host , user, false);

ActivityLogger.logInfo(this.getClass(), "Save Template action", "User " + user.getPrimaryKey() + " copying page" + newTemplate.getTitle(), HostUtil.hostNameUtil(req, _getUser(req)));
ActivityLogger.logInfo(this.getClass(), "Save Template action", "User " + user.getPrimaryKey() + " saving template" + newTemplate.getTitle(), HostUtil.hostNameUtil(req, _getUser(req)));

APILocator.getVersionableAPI().setLocked(newTemplate, false, user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import com.dotmarketing.portlets.htmlpages.model.HTMLPage;
import com.dotmarketing.portlets.templates.model.Template;
import com.dotmarketing.services.PageServices;
import com.dotmarketing.util.ActivityLogger;
import com.dotmarketing.util.HostUtil;
import com.dotmarketing.util.InodeUtils;
import com.dotmarketing.util.Logger;
import com.liferay.portal.model.User;
Expand Down Expand Up @@ -88,6 +90,7 @@ private void _publishTemplates(ActionRequest req, User user) throws Exception {
//calls the asset factory edit
try{
PublishFactory.publishAsset(template,reqImpl.getHttpServletRequest());
ActivityLogger.logInfo(this.getClass(), "Publish Template action", "User " + user.getPrimaryKey() + " publishing template" + template.getTitle(), HostUtil.hostNameUtil(req, _getUser(req)));
SessionMessages.add(req, "message", "message.template_list.published");
}catch(WebAssetException wax){
Logger.error(this, wax.getMessage(),wax);
Expand Down
4 changes: 2 additions & 2 deletions src/com/dotmarketing/util/ActivityLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public class ActivityLogger {
public static synchronized void logInfo(Class cl, String action, String msg, String host) {

if(LogMapper.getInstance().isLogEnabled(filename)) {
Logger.info(ActivityLogger.class, cl.toString() + ":"+host+": " + action + " , " + msg);
Logger.info(ActivityLogger.class, cl.toString() + ": "+host+" : " + action + " , " + msg);
}

}

public static void logDebug(Class cl, String action, String msg, String host) {
if(LogMapper.getInstance().isLogEnabled(filename)) {
Logger.debug(ActivityLogger.class, cl.toString() + ":"+host+":" + action + " , " + msg);
Logger.debug(ActivityLogger.class, cl.toString() + ": "+host+" :" + action + " , " + msg);
}
}
}
8 changes: 7 additions & 1 deletion src/com/dotmarketing/util/RollingNewFileAppender.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@ protected void subAppend(LoggingEvent event) {
}
map.put(hostName, rolling);
}

rolling.append(event);
}
else {
super.subAppend(event);
}

}

private String cleanMessage(String message){

return null;

}

}

0 comments on commit a124309

Please sign in to comment.