RM-745 (Event and property filtering not available for audit)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@54064 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-08-14 12:38:59 +00:00
parent 93e566ea7e
commit b446ae8e07
2 changed files with 47 additions and 33 deletions

View File

@@ -184,6 +184,7 @@
<property name="permissionService" ref="PermissionService" /> <property name="permissionService" ref="PermissionService" />
<property name="mimetypeService" ref="mimetypeService" /> <property name="mimetypeService" ref="mimetypeService" />
<property name="recordsManagementAuditService" ref="RecordsManagementAuditService" /> <property name="recordsManagementAuditService" ref="RecordsManagementAuditService" />
<property name="namespaceService" ref="namespaceService" />
</bean> </bean>
<!-- REST impl for PUT Audit Log (starting and stopping auditing) --> <!-- REST impl for PUT Audit Log (starting and stopping auditing) -->
@@ -507,20 +508,20 @@
<property name="customEmailMappingService" ref="CustomEmailMappingService" /> <property name="customEmailMappingService" ref="CustomEmailMappingService" />
</bean> </bean>
<!-- REST impl for GET Action Defitions for RM --> <!-- REST impl for GET Action Defitions for RM -->
<bean id="webscript.org.alfresco.repository.rule.rm-actiondefinitions.get" <bean id="webscript.org.alfresco.repository.rule.rm-actiondefinitions.get"
class="org.alfresco.repo.web.scripts.rule.RmActionDefinitionsGet" class="org.alfresco.repo.web.scripts.rule.RmActionDefinitionsGet"
parent="webscript"> parent="webscript">
<property name="recordsManagementActionService" ref="RecordsManagementActionService"/> <property name="recordsManagementActionService" ref="RecordsManagementActionService"/>
</bean> </bean>
<!-- REST impl for GET Action Condition Defitions for RM --> <!-- REST impl for GET Action Condition Defitions for RM -->
<bean id="webscript.org.alfresco.repository.rule.rm-actionconditiondefinitions.get" <bean id="webscript.org.alfresco.repository.rule.rm-actionconditiondefinitions.get"
class="org.alfresco.repo.web.scripts.rule.RmActionConditionDefinitionsGet" class="org.alfresco.repo.web.scripts.rule.RmActionConditionDefinitionsGet"
parent="webscript"> parent="webscript">
<property name="actionService" ref="ActionService"/> <property name="actionService" ref="ActionService"/>
<property name="recordsManagementActionService" ref="RecordsManagementActionService"/> <property name="recordsManagementActionService" ref="RecordsManagementActionService"/>
</bean> </bean>
@@ -531,6 +532,7 @@
<property name="mimetypeService" ref="mimetypeService"/> <property name="mimetypeService" ref="mimetypeService"/>
<property name="recordsManagementAuditService" ref="RecordsManagementAuditService"/> <property name="recordsManagementAuditService" ref="RecordsManagementAuditService"/>
<property name="contentStreamer" ref="webscript.content.streamer" /> <property name="contentStreamer" ref="webscript.content.streamer" />
<property name="namespaceService" ref="namespaceService" />
</bean> </bean>
<!-- REST impl for GET Class Definitions for RM/DM --> <!-- REST impl for GET Class Definitions for RM/DM -->

View File

@@ -31,6 +31,7 @@ import org.alfresco.repo.web.scripts.content.StreamContent;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.InvalidQNameException; import org.alfresco.service.namespace.InvalidQNameException;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.springframework.extensions.webscripts.WebScriptRequest; import org.springframework.extensions.webscripts.WebScriptRequest;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -41,14 +42,14 @@ import org.json.JSONTokener;
/** /**
* Base class for all audit retrieval webscripts. * Base class for all audit retrieval webscripts.
* *
* @author Gavin Cornwell * @author Gavin Cornwell
*/ */
public class BaseAuditRetrievalWebScript extends StreamContent public class BaseAuditRetrievalWebScript extends StreamContent
{ {
/** Logger */ /** Logger */
private static Log logger = LogFactory.getLog(BaseAuditRetrievalWebScript.class); private static Log logger = LogFactory.getLog(BaseAuditRetrievalWebScript.class);
protected final static String PARAM_USER = "user"; protected final static String PARAM_USER = "user";
protected final static String PARAM_SIZE = "size"; protected final static String PARAM_SIZE = "size";
protected final static String PARAM_EVENT = "event"; protected final static String PARAM_EVENT = "event";
@@ -56,23 +57,34 @@ public class BaseAuditRetrievalWebScript extends StreamContent
protected final static String PARAM_TO = "to"; protected final static String PARAM_TO = "to";
protected final static String PARAM_PROPERTY = "property"; protected final static String PARAM_PROPERTY = "property";
protected final static String DATE_PATTERN = "yyyy-MM-dd"; protected final static String DATE_PATTERN = "yyyy-MM-dd";
protected RecordsManagementAuditService rmAuditService; protected RecordsManagementAuditService rmAuditService;
protected NamespaceService namespaceService;
/** /**
* Sets the RecordsManagementAuditService instance * Sets the RecordsManagementAuditService instance
* *
* @param auditService The RecordsManagementAuditService instance * @param auditService The RecordsManagementAuditService instance
*/ */
public void setRecordsManagementAuditService(RecordsManagementAuditService rmAuditService) public void setRecordsManagementAuditService(RecordsManagementAuditService rmAuditService)
{ {
this.rmAuditService = rmAuditService; this.rmAuditService = rmAuditService;
} }
/** /**
* Parses the given request and builds an instance of * Sets the NamespaceService instance
*
* @param namespaceService The NamespaceService instance
*/
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
/**
* Parses the given request and builds an instance of
* RecordsManagementAuditQueryParameters to retrieve the relevant audit entries * RecordsManagementAuditQueryParameters to retrieve the relevant audit entries
* *
* @param req The request * @param req The request
* @return RecordsManagementAuditQueryParameters instance * @return RecordsManagementAuditQueryParameters instance
*/ */
@@ -80,7 +92,7 @@ public class BaseAuditRetrievalWebScript extends StreamContent
{ {
// create parameters for audit trail retrieval // create parameters for audit trail retrieval
RecordsManagementAuditQueryParameters params = new RecordsManagementAuditQueryParameters(); RecordsManagementAuditQueryParameters params = new RecordsManagementAuditQueryParameters();
// the webscripts can have a couple of different forms of url, work out // the webscripts can have a couple of different forms of url, work out
// whether a nodeRef has been supplied or whether the whole audit // whether a nodeRef has been supplied or whether the whole audit
// log should be displayed // log should be displayed
@@ -92,11 +104,11 @@ public class BaseAuditRetrievalWebScript extends StreamContent
// there is a store_type so all other params are likely to be present // there is a store_type so all other params are likely to be present
String storeId = templateVars.get("store_id"); String storeId = templateVars.get("store_id");
String nodeId = templateVars.get("id"); String nodeId = templateVars.get("id");
// create the nodeRef // create the nodeRef
nodeRef = new NodeRef(new StoreRef(storeType, storeId), nodeId); nodeRef = new NodeRef(new StoreRef(storeType, storeId), nodeId);
} }
// gather all the common filtering parameters, these could be on the // gather all the common filtering parameters, these could be on the
// query string, in a multipart/form-data request or in a JSON body // query string, in a multipart/form-data request or in a JSON body
String size = null; String size = null;
@@ -105,7 +117,7 @@ public class BaseAuditRetrievalWebScript extends StreamContent
String from = null; String from = null;
String to = null; String to = null;
String property = null; String property = null;
if (MimetypeMap.MIMETYPE_JSON.equals(req.getContentType())) if (MimetypeMap.MIMETYPE_JSON.equals(req.getContentType()))
{ {
try try
@@ -163,7 +175,7 @@ public class BaseAuditRetrievalWebScript extends StreamContent
params.setNodeRef(nodeRef); params.setNodeRef(nodeRef);
params.setUser(user); params.setUser(user);
params.setEvent(event); params.setEvent(event);
if (size != null && size.length() > 0) if (size != null && size.length() > 0)
{ {
try try
@@ -176,7 +188,7 @@ public class BaseAuditRetrievalWebScript extends StreamContent
logger.warn("Ignoring size parameter as '" + size + "' is not a number!"); logger.warn("Ignoring size parameter as '" + size + "' is not a number!");
} }
} }
if (from != null && from.length() > 0) if (from != null && from.length() > 0)
{ {
try try
@@ -190,7 +202,7 @@ public class BaseAuditRetrievalWebScript extends StreamContent
logger.warn("Ignoring from parameter as '" + from + "' does not conform to the date pattern: " + DATE_PATTERN); logger.warn("Ignoring from parameter as '" + from + "' does not conform to the date pattern: " + DATE_PATTERN);
} }
} }
if (to != null && to.length() > 0) if (to != null && to.length() > 0)
{ {
try try
@@ -204,12 +216,12 @@ public class BaseAuditRetrievalWebScript extends StreamContent
logger.warn("Ignoring to parameter as '" + to + "' does not conform to the date pattern: " + DATE_PATTERN); logger.warn("Ignoring to parameter as '" + to + "' does not conform to the date pattern: " + DATE_PATTERN);
} }
} }
if (property != null && property.length() > 0) if (property != null && property.length() > 0)
{ {
try try
{ {
params.setProperty(QName.createQName(property)); params.setProperty(QName.createQName(property, namespaceService));
} }
catch (InvalidQNameException iqe) catch (InvalidQNameException iqe)
{ {
@@ -217,21 +229,21 @@ public class BaseAuditRetrievalWebScript extends StreamContent
logger.warn("Ignoring property parameter as '" + property + "' is an invalid QName"); logger.warn("Ignoring property parameter as '" + property + "' is an invalid QName");
} }
} }
return params; return params;
} }
/** /**
* Parses the given request for the format the audit report * Parses the given request for the format the audit report
* should be returned in * should be returned in
* *
* @param req The request * @param req The request
* @return The format for the report * @return The format for the report
*/ */
protected ReportFormat parseReportFormat(WebScriptRequest req) protected ReportFormat parseReportFormat(WebScriptRequest req)
{ {
String format = req.getFormat(); String format = req.getFormat();
if (format != null) if (format != null)
{ {
if (format.equalsIgnoreCase("json")) if (format.equalsIgnoreCase("json"))
@@ -243,7 +255,7 @@ public class BaseAuditRetrievalWebScript extends StreamContent
return ReportFormat.HTML; return ReportFormat.HTML;
} }
} }
return ReportFormat.JSON; return ReportFormat.JSON;
} }
} }