mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/V2.0 to HEAD:
51415: Merged DEV/DODRECERT TO BRANCHES/V2.0: * 50932: RM-741: Allow category and folder id to be editable upon creation. 51418: Merged DEV/DODRECERT TO BRANCHES/V2.0: - r50934: RM-742: Search sort order now works as expected 51419: Merged DEV/DODRECERT TO BRANCHES/V2.0: - r50953: Creating an RM site was not possible (ref RM-742) 51420: Merged DEV/DODRECERT TO BRANCHES/V2.0: - r50970: RM-735 (DOD Recert: Bugs on the "Edit Custom Metadata" page) 51421: Merged DEV/DODRECERT TO BRANCHES/V2.0: - r50975: RM-736 (DOD Recert: Bugs on the "List of Values" page) 51423: Merged DEV/DODRECERT TO BRANCHES/V2.0: 51425: Merged DEV/DODRECERT TO BRANCHES/V2.0: - r51082: RM Audit * improved display so it's easier to see what's going on * RM 744: audit user creation - r51095: RM-738 (DOD Recert: Add events and properties to the "Audit" page) - r51099: Fix upgrade issue - r51108: RM-745: Simple support for event and property filtering on audit - r51134: Upgrade issues * added patch to fill in missing file plan root node reference * default site id set when retrieving saved searches - r51212: RM-746: Space in the property name 51426: Merged DEV/DODRECERT TO BRANCHES/V2.0: - r51218: RM-747: Search for undeclared records results in exception - r51219: RM-748: Editing a disposition schedule did not work for a non admin user - r51220: RM-749: Fixed Accession Report 51504: RM: Fix build git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@51946 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -227,7 +227,7 @@ subprojects {
|
|||||||
copy {
|
copy {
|
||||||
from "${configModuleDir}"
|
from "${configModuleDir}"
|
||||||
include "${moduleProperties}"
|
include "${moduleProperties}"
|
||||||
include "${fileMapping}"
|
include "${fileMapping}"
|
||||||
into assembleDir
|
into assembleDir
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +239,8 @@ subprojects {
|
|||||||
copy {
|
copy {
|
||||||
from configDir
|
from configDir
|
||||||
exclude "**/${moduleProperties}"
|
exclude "**/${moduleProperties}"
|
||||||
exclude "**/${fileMapping}"
|
exclude "**/${fileMapping}"
|
||||||
|
exclude "**/dev-context.xml"
|
||||||
into "${assembleDir}/config"
|
into "${assembleDir}/config"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,2 +1,3 @@
|
|||||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.caveat=warn
|
log4j.logger.org.alfresco.module.org_alfresco_module_rm.caveat=warn
|
||||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityPostProcessor=warn
|
log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityPostProcessor=warn
|
||||||
|
log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=debug
|
||||||
|
@@ -581,7 +581,6 @@
|
|||||||
|
|
||||||
<!-- rma:filePlanComponent is a marker interface for all things RM -->
|
<!-- rma:filePlanComponent is a marker interface for all things RM -->
|
||||||
<!-- Security uses it as a key to determine which implementation to use -->
|
<!-- Security uses it as a key to determine which implementation to use -->
|
||||||
<!-- TODO ... this should not be called "filePlan" as it is DOD specific terminology -->
|
|
||||||
<aspect name="rma:filePlanComponent">
|
<aspect name="rma:filePlanComponent">
|
||||||
<title>File Plan Component</title>
|
<title>File Plan Component</title>
|
||||||
<archive>false</archive>
|
<archive>false</archive>
|
||||||
|
@@ -49,6 +49,22 @@
|
|||||||
<property name="retryingTransactionHelper" ref="retryingTransactionHelper"/>
|
<property name="retryingTransactionHelper" ref="retryingTransactionHelper"/>
|
||||||
<property name="qnameDAO" ref="qnameDAO"/>
|
<property name="qnameDAO" ref="qnameDAO"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="org_alfresco_module_rm_RMv2FilePlanNodeRefPatch"
|
||||||
|
parent="module.baseComponent"
|
||||||
|
class="org.alfresco.module.org_alfresco_module_rm.patch.RMv2FilePlanNodeRefPatch">
|
||||||
|
<property name="moduleId" value="org_alfresco_module_rm"/>
|
||||||
|
<property name="name" value="org_alfresco_module_rm_RMv2FilePlanNodeRefPatch"/>
|
||||||
|
<property name="description" value="Patches the existing RM data with the root file plan values."/>
|
||||||
|
<property name="sinceVersion" value="2.0"/>
|
||||||
|
<property name="appliesFromVersion" value="2.0"/>
|
||||||
|
<property name="patchDAO" ref="patchDAO"/>
|
||||||
|
<property name="nodeDAO" ref="nodeDAO" />
|
||||||
|
<property name="qnameDAO" ref="qnameDAO"/>
|
||||||
|
<property name="nodeService" ref="NodeService"/>
|
||||||
|
<property name="recordsManagementService" ref="RecordsManagementService" />
|
||||||
|
<property name="behaviourFilter" ref="policyBehaviourFilter"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="org_alfresco_module_rm_RMv21InPlacePatch"
|
<bean id="org_alfresco_module_rm_RMv21InPlacePatch"
|
||||||
parent="module.baseComponent"
|
parent="module.baseComponent"
|
||||||
|
@@ -1,43 +1,43 @@
|
|||||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||||
{
|
{
|
||||||
"data":
|
"data":
|
||||||
{
|
{
|
||||||
"customProperties":
|
"customProperties":
|
||||||
{
|
{
|
||||||
<#list customProps as prop>
|
<#list customProps as prop>
|
||||||
"${prop.name.toPrefixString()}":
|
"${prop.name.toPrefixString()}":
|
||||||
{
|
{
|
||||||
"dataType": "<#if prop.dataType??>${prop.dataType.name.toPrefixString()}</#if>",
|
"dataType": "<#if prop.dataType??>${prop.dataType.name.toPrefixString()}</#if>",
|
||||||
"label": "${prop.title!""}",
|
"label": "${prop.title!""}",
|
||||||
"description": "${prop.description!""}",
|
"description": "${prop.description!""}",
|
||||||
"mandatory": ${prop.mandatory?string},
|
"mandatory": ${prop.mandatory?string},
|
||||||
"multiValued": ${prop.multiValued?string},
|
"multiValued": ${prop.multiValued?string},
|
||||||
"defaultValue": "${prop.defaultValue!""}",
|
"defaultValue": "${prop.defaultValue!""}",
|
||||||
"protected": ${prop.protected?string},
|
"protected": ${prop.protected?string},
|
||||||
"propId": "${prop.name.localName}",
|
"propId": "${prop.name.localName}",
|
||||||
"constraintRefs":
|
"constraintRefs":
|
||||||
[
|
[
|
||||||
<#list prop.constraints as con>
|
<#list prop.constraints as con>
|
||||||
{
|
{
|
||||||
"name": "${con.constraint.shortName!""}",
|
"name": "${con.constraint.shortName!""}",
|
||||||
"title": "${con.title!""}",
|
"title": "${con.constraint.title!""}",
|
||||||
"type": "${con.constraint.type!""}",
|
"type": "${con.constraint.type!""}",
|
||||||
"parameters":
|
"parameters":
|
||||||
{
|
{
|
||||||
<#-- Basic implementation. Only providing 2 hardcoded parameters. -->
|
<#-- Basic implementation. Only providing 2 hardcoded parameters. -->
|
||||||
<#assign lov = con.constraint.parameters["allowedValues"]>
|
<#assign lov = con.constraint.parameters["allowedValues"]>
|
||||||
"caseSensitive": ${con.constraint.parameters["caseSensitive"]?string},
|
"caseSensitive": ${con.constraint.parameters["caseSensitive"]?string},
|
||||||
"listOfValues" :
|
"listOfValues" :
|
||||||
[
|
[
|
||||||
<#list lov as val>"${val}"<#if val_has_next>,</#if></#list>
|
<#list lov as val>"${val}"<#if val_has_next>,</#if></#list>
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}<#if con_has_next>,</#if>
|
}<#if con_has_next>,</#if>
|
||||||
</#list>
|
</#list>
|
||||||
]
|
]
|
||||||
}<#if prop_has_next>,</#if>
|
}<#if prop_has_next>,</#if>
|
||||||
</#list>
|
</#list>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</#escape>
|
</#escape>
|
@@ -1246,7 +1246,8 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
|
|||||||
String compoundID = this.getCompoundIdFor(source, target);
|
String compoundID = this.getCompoundIdFor(source, target);
|
||||||
if (existsLabel(compoundID))
|
if (existsLabel(compoundID))
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException(I18NUtil.getMessage(MSG_REF_LABEL_IN_USE, compoundID));
|
return null;
|
||||||
|
//throw new IllegalArgumentException(I18NUtil.getMessage(MSG_REF_LABEL_IN_USE, compoundID));
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeRef modelRef = getCustomModelRef(""); // defaults to RM_CUSTOM_URI
|
NodeRef modelRef = getCustomModelRef(""); // defaults to RM_CUSTOM_URI
|
||||||
|
@@ -528,7 +528,8 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe
|
|||||||
|
|
||||||
// Get the period properties value
|
// Get the period properties value
|
||||||
QName periodProperty = nextDispositionActionDefinition.getPeriodProperty();
|
QName periodProperty = nextDispositionActionDefinition.getPeriodProperty();
|
||||||
if (periodProperty != null)
|
if (periodProperty != null &&
|
||||||
|
RecordsManagementModel.PROP_DISPOSITION_AS_OF.equals(periodProperty) == false)
|
||||||
{
|
{
|
||||||
// doesn't matter if the period property isn't set ... the asOfDate will get updated later
|
// doesn't matter if the period property isn't set ... the asOfDate will get updated later
|
||||||
// when the value of the period property is set
|
// when the value of the period property is set
|
||||||
|
@@ -322,6 +322,10 @@ public class RecordsManagementAuditServiceImpl
|
|||||||
new AuditEvent("unfreeze", MSG_UNFREEZE));
|
new AuditEvent("unfreeze", MSG_UNFREEZE));
|
||||||
this.auditEvents.put("reject",
|
this.auditEvents.put("reject",
|
||||||
new AuditEvent("reject", MSG_REJECT_RECORD));
|
new AuditEvent("reject", MSG_REJECT_RECORD));
|
||||||
|
|
||||||
|
// Added for DOD compliance
|
||||||
|
this.auditEvents.put("createPerson",
|
||||||
|
new AuditEvent("createPerson", "User Created"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -341,7 +345,11 @@ public class RecordsManagementAuditServiceImpl
|
|||||||
policyComponent.bindClassBehaviour(
|
policyComponent.bindClassBehaviour(
|
||||||
BeforeDeleteNodePolicy.QNAME,
|
BeforeDeleteNodePolicy.QNAME,
|
||||||
RecordsManagementModel.ASPECT_RECORD_COMPONENT_ID,
|
RecordsManagementModel.ASPECT_RECORD_COMPONENT_ID,
|
||||||
new JavaBehaviour(this, "beforeDeleteNode"));
|
new JavaBehaviour(this, "beforeDeleteNode"));
|
||||||
|
policyComponent.bindClassBehaviour(
|
||||||
|
OnCreateNodePolicy.QNAME,
|
||||||
|
ContentModel.TYPE_PERSON,
|
||||||
|
new JavaBehaviour(this, "onCreatePersonNode"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -473,7 +481,12 @@ public class RecordsManagementAuditServiceImpl
|
|||||||
{
|
{
|
||||||
auditRMEvent(childAssocRef.getChildRef(), RM_AUDIT_EVENT_CREATE_RM_OBJECT, null, null);
|
auditRMEvent(childAssocRef.getChildRef(), RM_AUDIT_EVENT_CREATE_RM_OBJECT, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onCreatePersonNode(ChildAssociationRef childAssocRef)
|
||||||
|
{
|
||||||
|
auditRMEvent(childAssocRef.getChildRef(), "createPerson", null, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
@@ -505,19 +518,9 @@ public class RecordsManagementAuditServiceImpl
|
|||||||
{
|
{
|
||||||
// Deleted nodes will not be available at the end of the transaction. The data needs to
|
// Deleted nodes will not be available at the end of the transaction. The data needs to
|
||||||
// be extracted now and the audit entry needs to be created now.
|
// be extracted now and the audit entry needs to be created now.
|
||||||
Map<String, Serializable> auditMap = new HashMap<String, Serializable>(13);
|
Map<String, Serializable> auditMap = buildAuditMap(nodeRef, eventName);
|
||||||
auditMap.put(
|
|
||||||
AuditApplication.buildPath(
|
|
||||||
RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT,
|
|
||||||
RecordsManagementAuditService.RM_AUDIT_SNIPPET_NAME),
|
|
||||||
eventName);
|
|
||||||
// Action node
|
|
||||||
auditMap.put(
|
|
||||||
AuditApplication.buildPath(
|
|
||||||
RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT,
|
|
||||||
RecordsManagementAuditService.RM_AUDIT_SNIPPET_NODE),
|
|
||||||
nodeRef);
|
|
||||||
auditMap = auditComponent.recordAuditValues(RecordsManagementAuditService.RM_AUDIT_PATH_ROOT, auditMap);
|
auditMap = auditComponent.recordAuditValues(RecordsManagementAuditService.RM_AUDIT_PATH_ROOT, auditMap);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("RM Audit: Audited node deletion: \n" + auditMap);
|
logger.debug("RM Audit: Audited node deletion: \n" + auditMap);
|
||||||
@@ -555,6 +558,31 @@ public class RecordsManagementAuditServiceImpl
|
|||||||
// That is it. The values are queued for the end of the transaction.
|
// That is it. The values are queued for the end of the transaction.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to build audit map
|
||||||
|
*
|
||||||
|
* @param nodeRef
|
||||||
|
* @param eventName
|
||||||
|
* @return
|
||||||
|
* @since 2.0.3
|
||||||
|
*/
|
||||||
|
private Map<String, Serializable> buildAuditMap(NodeRef nodeRef, String eventName)
|
||||||
|
{
|
||||||
|
Map<String, Serializable> auditMap = new HashMap<String, Serializable>(13);
|
||||||
|
auditMap.put(
|
||||||
|
AuditApplication.buildPath(
|
||||||
|
RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT,
|
||||||
|
RecordsManagementAuditService.RM_AUDIT_SNIPPET_NAME),
|
||||||
|
eventName);
|
||||||
|
// Action node
|
||||||
|
auditMap.put(
|
||||||
|
AuditApplication.buildPath(
|
||||||
|
RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT,
|
||||||
|
RecordsManagementAuditService.RM_AUDIT_SNIPPET_NODE),
|
||||||
|
nodeRef);
|
||||||
|
return auditMap;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A <b>stateless</b> transaction listener for RM auditing. This component picks up the data of
|
* A <b>stateless</b> transaction listener for RM auditing. This component picks up the data of
|
||||||
@@ -615,20 +643,13 @@ public class RecordsManagementAuditServiceImpl
|
|||||||
|
|
||||||
RMAuditNode auditedNode = entry.getValue();
|
RMAuditNode auditedNode = entry.getValue();
|
||||||
|
|
||||||
Map<String, Serializable> auditMap = new HashMap<String, Serializable>(13);
|
|
||||||
// Action description
|
// Action description
|
||||||
String eventName = auditedNode.getEventName();
|
String eventName = auditedNode.getEventName();
|
||||||
auditMap.put(
|
|
||||||
AuditApplication.buildPath(
|
Map<String, Serializable> auditMap = buildAuditMap(nodeRef, eventName);
|
||||||
RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT,
|
|
||||||
RecordsManagementAuditService.RM_AUDIT_SNIPPET_NAME),
|
// TODO do we care if the before and after are null??
|
||||||
eventName);
|
|
||||||
// Action node
|
|
||||||
auditMap.put(
|
|
||||||
AuditApplication.buildPath(
|
|
||||||
RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT,
|
|
||||||
RecordsManagementAuditService.RM_AUDIT_SNIPPET_NODE),
|
|
||||||
nodeRef);
|
|
||||||
// Property changes
|
// Property changes
|
||||||
Map<QName, Serializable> propertiesBefore = auditedNode.getNodePropertiesBefore();
|
Map<QName, Serializable> propertiesBefore = auditedNode.getNodePropertiesBefore();
|
||||||
Map<QName, Serializable> propertiesAfter = auditedNode.getNodePropertiesAfter();
|
Map<QName, Serializable> propertiesAfter = auditedNode.getNodePropertiesAfter();
|
||||||
@@ -648,6 +669,7 @@ public class RecordsManagementAuditServiceImpl
|
|||||||
RecordsManagementAuditService.RM_AUDIT_SNIPPET_CHANGES,
|
RecordsManagementAuditService.RM_AUDIT_SNIPPET_CHANGES,
|
||||||
RecordsManagementAuditService.RM_AUDIT_SNIPPET_AFTER),
|
RecordsManagementAuditService.RM_AUDIT_SNIPPET_AFTER),
|
||||||
(Serializable) deltaPair.getSecond());
|
(Serializable) deltaPair.getSecond());
|
||||||
|
|
||||||
// Audit it
|
// Audit it
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
@@ -742,7 +764,7 @@ public class RecordsManagementAuditServiceImpl
|
|||||||
* @param reportFormat Format to write the audit trail in, ignored if writer is <code>null</code>
|
* @param reportFormat Format to write the audit trail in, ignored if writer is <code>null</code>
|
||||||
*/
|
*/
|
||||||
private void getAuditTrailImpl(
|
private void getAuditTrailImpl(
|
||||||
RecordsManagementAuditQueryParameters params,
|
final RecordsManagementAuditQueryParameters params,
|
||||||
final List<RecordsManagementAuditEntry> results,
|
final List<RecordsManagementAuditEntry> results,
|
||||||
final Writer writer,
|
final Writer writer,
|
||||||
final ReportFormat reportFormat)
|
final ReportFormat reportFormat)
|
||||||
@@ -785,6 +807,7 @@ public class RecordsManagementAuditServiceImpl
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Date timestamp = new Date(time);
|
Date timestamp = new Date(time);
|
||||||
String eventName = null;
|
String eventName = null;
|
||||||
String fullName = null;
|
String fullName = null;
|
||||||
@@ -846,6 +869,22 @@ public class RecordsManagementAuditServiceImpl
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// filter out events if set
|
||||||
|
if (params.getEvent() != null &&
|
||||||
|
params.getEvent().endsWith(eventName) == false)
|
||||||
|
{
|
||||||
|
// skip it
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (params.getProperty() != null &&
|
||||||
|
getChangedProperties(beforeProperties, afterProperties).contains(params.getProperty()) == false)
|
||||||
|
{
|
||||||
|
// skip it
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Refactor this to use the builder pattern
|
// TODO: Refactor this to use the builder pattern
|
||||||
RecordsManagementAuditEntry entry = new RecordsManagementAuditEntry(
|
RecordsManagementAuditEntry entry = new RecordsManagementAuditEntry(
|
||||||
timestamp,
|
timestamp,
|
||||||
@@ -878,6 +917,32 @@ public class RecordsManagementAuditServiceImpl
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<QName> getChangedProperties(Map<QName, Serializable> beforeProperties, Map<QName, Serializable> afterProperties)
|
||||||
|
{
|
||||||
|
List<QName> changedProperties = new ArrayList<QName>(21);
|
||||||
|
|
||||||
|
if (beforeProperties != null && afterProperties != null)
|
||||||
|
{
|
||||||
|
// add all the properties present before the audited action
|
||||||
|
for (QName valuePropName : beforeProperties.keySet())
|
||||||
|
{
|
||||||
|
changedProperties.add(valuePropName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add all the properties present after the audited action that
|
||||||
|
// have not already been added
|
||||||
|
for (QName valuePropName : afterProperties.keySet())
|
||||||
|
{
|
||||||
|
if (!beforeProperties.containsKey(valuePropName))
|
||||||
|
{
|
||||||
|
changedProperties.add(valuePropName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return changedProperties;
|
||||||
|
}
|
||||||
|
|
||||||
private void writeEntryToFile(RecordsManagementAuditEntry entry)
|
private void writeEntryToFile(RecordsManagementAuditEntry entry)
|
||||||
{
|
{
|
||||||
if (writer == null)
|
if (writer == null)
|
||||||
@@ -1215,7 +1280,18 @@ public class RecordsManagementAuditServiceImpl
|
|||||||
json.put("userRole", entry.getUserRole() == null ? "": entry.getUserRole());
|
json.put("userRole", entry.getUserRole() == null ? "": entry.getUserRole());
|
||||||
json.put("fullName", entry.getFullName() == null ? "": entry.getFullName());
|
json.put("fullName", entry.getFullName() == null ? "": entry.getFullName());
|
||||||
json.put("nodeRef", entry.getNodeRef() == null ? "": entry.getNodeRef());
|
json.put("nodeRef", entry.getNodeRef() == null ? "": entry.getNodeRef());
|
||||||
json.put("nodeName", entry.getNodeName() == null ? "": entry.getNodeName());
|
|
||||||
|
if (entry.getEvent().equals("createPerson") == true && entry.getNodeRef() != null)
|
||||||
|
{
|
||||||
|
NodeRef nodeRef = entry.getNodeRef();
|
||||||
|
String userName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME);
|
||||||
|
json.put("nodeName", userName == null ? "": userName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
json.put("nodeName", entry.getNodeName() == null ? "": entry.getNodeName());
|
||||||
|
}
|
||||||
|
|
||||||
json.put("nodeType", entry.getNodeType() == null ? "": entry.getNodeType());
|
json.put("nodeType", entry.getNodeType() == null ? "": entry.getNodeType());
|
||||||
json.put("event", entry.getEvent() == null ? "": getAuditEventLabel(entry.getEvent()));
|
json.put("event", entry.getEvent() == null ? "": getAuditEventLabel(entry.getEvent()));
|
||||||
json.put("identifier", entry.getIdentifier() == null ? "": entry.getIdentifier());
|
json.put("identifier", entry.getIdentifier() == null ? "": entry.getIdentifier());
|
||||||
|
@@ -28,29 +28,30 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.security.AuthorityService;
|
import org.alfresco.service.cmr.security.AuthorityService;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class ScriptConstraint implements Serializable
|
public class ScriptConstraint implements Serializable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private RMConstraintInfo info;
|
private RMConstraintInfo info;
|
||||||
|
|
||||||
private RMCaveatConfigService rmCaveatconfigService;
|
private RMCaveatConfigService rmCaveatconfigService;
|
||||||
|
|
||||||
private AuthorityService authorityService;
|
private AuthorityService authorityService;
|
||||||
|
|
||||||
ScriptConstraint(RMConstraintInfo info, RMCaveatConfigService rmCaveatconfigService, AuthorityService authorityService)
|
ScriptConstraint(RMConstraintInfo info, RMCaveatConfigService rmCaveatconfigService, AuthorityService authorityService)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.rmCaveatconfigService = rmCaveatconfigService;
|
this.rmCaveatconfigService = rmCaveatconfigService;
|
||||||
this.authorityService = authorityService;
|
this.authorityService = authorityService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title)
|
public void setTitle(String title)
|
||||||
{
|
{
|
||||||
info.setTitle(title);
|
info.setTitle(title);
|
||||||
@@ -63,49 +64,49 @@ public class ScriptConstraint implements Serializable
|
|||||||
{
|
{
|
||||||
info.setName(name);
|
info.setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
String xxx = info.getName().replace(":", "_");
|
String xxx = info.getName().replace(":", "_");
|
||||||
return xxx;
|
return xxx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCaseSensitive()
|
public boolean isCaseSensitive()
|
||||||
{
|
{
|
||||||
return info.isCaseSensitive();
|
return info.isCaseSensitive();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getAllowedValues()
|
public String[] getAllowedValues()
|
||||||
{
|
{
|
||||||
return info.getAllowedValues();
|
return info.getAllowedValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptConstraintAuthority[] getAuthorities()
|
public ScriptConstraintAuthority[] getAuthorities()
|
||||||
{
|
{
|
||||||
Map<String, List<String>> values = rmCaveatconfigService.getListDetails(info.getName());
|
Map<String, List<String>> values = rmCaveatconfigService.getListDetails(info.getName());
|
||||||
|
|
||||||
if (values == null)
|
if (values == null)
|
||||||
{
|
{
|
||||||
return new ScriptConstraintAuthority[0];
|
return new ScriptConstraintAuthority[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here with some data to return
|
// Here with some data to return
|
||||||
Set<String> authorities = values.keySet();
|
Set<String> authorities = values.keySet();
|
||||||
|
|
||||||
ArrayList<ScriptConstraintAuthority> constraints = new ArrayList<ScriptConstraintAuthority>(values.size());
|
ArrayList<ScriptConstraintAuthority> constraints = new ArrayList<ScriptConstraintAuthority>(values.size());
|
||||||
for(String authority : authorities)
|
for(String authority : authorities)
|
||||||
{
|
{
|
||||||
ScriptConstraintAuthority constraint = new ScriptConstraintAuthority();
|
ScriptConstraintAuthority constraint = new ScriptConstraintAuthority();
|
||||||
constraint.setAuthorityName(authority);
|
constraint.setAuthorityName(authority);
|
||||||
constraint.setValues(values.get(authority));
|
constraint.setValues(values.get(authority));
|
||||||
constraints.add(constraint);
|
constraints.add(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptConstraintAuthority[] retVal = constraints.toArray(new ScriptConstraintAuthority[constraints.size()]);
|
ScriptConstraintAuthority[] retVal = constraints.toArray(new ScriptConstraintAuthority[constraints.size()]);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updateTitle
|
* updateTitle
|
||||||
*/
|
*/
|
||||||
@@ -114,7 +115,7 @@ public class ScriptConstraint implements Serializable
|
|||||||
info.setTitle(newTitle);
|
info.setTitle(newTitle);
|
||||||
rmCaveatconfigService.updateRMConstraintTitle(info.getName(), newTitle) ;
|
rmCaveatconfigService.updateRMConstraintTitle(info.getName(), newTitle) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updateAllowedValues
|
* updateAllowedValues
|
||||||
*/
|
*/
|
||||||
@@ -123,7 +124,7 @@ public class ScriptConstraint implements Serializable
|
|||||||
info.setAllowedValues(allowedValues);
|
info.setAllowedValues(allowedValues);
|
||||||
rmCaveatconfigService.updateRMConstraintAllowedValues(info.getName(), allowedValues);
|
rmCaveatconfigService.updateRMConstraintAllowedValues(info.getName(), allowedValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a value
|
* Update a value
|
||||||
* @param values
|
* @param values
|
||||||
@@ -133,7 +134,7 @@ public class ScriptConstraint implements Serializable
|
|||||||
{
|
{
|
||||||
for(int i = 0; i < bodge.length(); i++)
|
for(int i = 0; i < bodge.length(); i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
JSONObject obj = bodge.getJSONObject(i);
|
JSONObject obj = bodge.getJSONObject(i);
|
||||||
String value = obj.getString("value");
|
String value = obj.getString("value");
|
||||||
JSONArray authorities = obj.getJSONArray("authorities");
|
JSONArray authorities = obj.getJSONArray("authorities");
|
||||||
@@ -142,10 +143,10 @@ public class ScriptConstraint implements Serializable
|
|||||||
{
|
{
|
||||||
aList.add(authorities.getString(j));
|
aList.add(authorities.getString(j));
|
||||||
}
|
}
|
||||||
rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, aList);
|
rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, aList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a value
|
* Update a value
|
||||||
* @param values
|
* @param values
|
||||||
@@ -154,27 +155,27 @@ public class ScriptConstraint implements Serializable
|
|||||||
public void updateValues(String value, String[] authorities)
|
public void updateValues(String value, String[] authorities)
|
||||||
{
|
{
|
||||||
List<String> list = Arrays.asList(authorities);
|
List<String> list = Arrays.asList(authorities);
|
||||||
rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, list);
|
rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cascade delete an authority
|
* Cascade delete an authority
|
||||||
* @param authority
|
* @param authority
|
||||||
*/
|
*/
|
||||||
public void deleteAuthority(String authority)
|
public void deleteAuthority(String authority)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cascade delete a value
|
* Cascade delete a value
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
public void deleteValue(String value)
|
public void deleteValue(String value)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a single value
|
* Get a single value
|
||||||
@@ -184,7 +185,7 @@ public class ScriptConstraint implements Serializable
|
|||||||
public ScriptConstraintValue getValue(String value)
|
public ScriptConstraintValue getValue(String value)
|
||||||
{
|
{
|
||||||
ScriptConstraintValue[] values = getValues();
|
ScriptConstraintValue[] values = getValues();
|
||||||
|
|
||||||
for(ScriptConstraintValue val : values)
|
for(ScriptConstraintValue val : values)
|
||||||
{
|
{
|
||||||
if(val.getValueName().equalsIgnoreCase(value))
|
if(val.getValueName().equalsIgnoreCase(value))
|
||||||
@@ -194,39 +195,39 @@ public class ScriptConstraint implements Serializable
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptConstraintValue[] getValues()
|
public ScriptConstraintValue[] getValues()
|
||||||
{
|
{
|
||||||
// authority, values
|
// authority, values
|
||||||
Map<String, List<String>> details = rmCaveatconfigService.getListDetails(info.getName());
|
Map<String, List<String>> details = rmCaveatconfigService.getListDetails(info.getName());
|
||||||
|
|
||||||
if (details == null)
|
if (details == null)
|
||||||
{
|
{
|
||||||
details = new HashMap<String, List<String>>();
|
details = new HashMap<String, List<String>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// values, authorities
|
// values, authorities
|
||||||
Map<String, List<String>> pivot = PivotUtil.getPivot(details);
|
Map<String, List<String>> pivot = PivotUtil.getPivot(details);
|
||||||
|
|
||||||
// Here with some data to return
|
// Here with some data to return
|
||||||
Set<String> values = pivot.keySet();
|
Set<String> values = pivot.keySet();
|
||||||
|
|
||||||
ArrayList<ScriptConstraintValue> constraints = new ArrayList<ScriptConstraintValue>(pivot.size());
|
ArrayList<ScriptConstraintValue> constraints = new ArrayList<ScriptConstraintValue>(pivot.size());
|
||||||
for(String value : values)
|
for(String value : values)
|
||||||
{
|
{
|
||||||
ScriptConstraintValue constraint = new ScriptConstraintValue();
|
ScriptConstraintValue constraint = new ScriptConstraintValue();
|
||||||
constraint.setValueName(value);
|
constraint.setValueName(value);
|
||||||
constraint.setValueTitle(value);
|
constraint.setValueTitle(value);
|
||||||
|
|
||||||
List<String>authorities = pivot.get(value);
|
List<String>authorities = pivot.get(value);
|
||||||
List<ScriptAuthority> sauth = new ArrayList<ScriptAuthority>();
|
List<ScriptAuthority> sauth = new ArrayList<ScriptAuthority>();
|
||||||
for(String authority : authorities)
|
for(String authority : authorities)
|
||||||
{
|
{
|
||||||
ScriptAuthority a = new ScriptAuthority();
|
ScriptAuthority a = new ScriptAuthority();
|
||||||
a.setAuthorityName(authority);
|
a.setAuthorityName(authority);
|
||||||
|
|
||||||
String displayName = authorityService.getAuthorityDisplayName(authority);
|
String displayName = authorityService.getAuthorityDisplayName(authority);
|
||||||
if(displayName != null)
|
if(StringUtils.isNotBlank(displayName))
|
||||||
{
|
{
|
||||||
a.setAuthorityTitle(displayName);
|
a.setAuthorityTitle(displayName);
|
||||||
}
|
}
|
||||||
@@ -236,10 +237,10 @@ public class ScriptConstraint implements Serializable
|
|||||||
}
|
}
|
||||||
sauth.add(a);
|
sauth.add(a);
|
||||||
}
|
}
|
||||||
constraint.setAuthorities(sauth);
|
constraint.setAuthorities(sauth);
|
||||||
constraints.add(constraint);
|
constraints.add(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Now go through and add any "empty" values
|
* Now go through and add any "empty" values
|
||||||
*/
|
*/
|
||||||
@@ -251,14 +252,14 @@ public class ScriptConstraint implements Serializable
|
|||||||
constraint.setValueName(value);
|
constraint.setValueName(value);
|
||||||
constraint.setValueTitle(value);
|
constraint.setValueTitle(value);
|
||||||
List<ScriptAuthority> sauth = new ArrayList<ScriptAuthority>();
|
List<ScriptAuthority> sauth = new ArrayList<ScriptAuthority>();
|
||||||
constraint.setAuthorities(sauth);
|
constraint.setAuthorities(sauth);
|
||||||
constraints.add(constraint);
|
constraints.add(constraint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ScriptConstraintValue[] retVal = constraints.toArray(new ScriptConstraintValue[constraints.size()]);
|
ScriptConstraintValue[] retVal = constraints.toArray(new ScriptConstraintValue[constraints.size()]);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,7 @@ import java.util.Set;
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
import org.alfresco.repo.forms.Field;
|
import org.alfresco.repo.forms.Field;
|
||||||
|
import org.alfresco.repo.forms.FieldDefinition;
|
||||||
import org.alfresco.repo.forms.FieldGroup;
|
import org.alfresco.repo.forms.FieldGroup;
|
||||||
import org.alfresco.repo.forms.Form;
|
import org.alfresco.repo.forms.Form;
|
||||||
import org.alfresco.repo.forms.FormData;
|
import org.alfresco.repo.forms.FormData;
|
||||||
@@ -84,8 +85,12 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter
|
|||||||
* java.util.List, java.util.List, org.alfresco.repo.forms.Form,
|
* java.util.List, java.util.List, org.alfresco.repo.forms.Form,
|
||||||
* java.util.Map)
|
* java.util.Map)
|
||||||
*/
|
*/
|
||||||
public void afterGenerate(TypeDefinition type, List<String> fields, List<String> forcedFields, Form form,
|
public void afterGenerate(
|
||||||
Map<String, Object> context)
|
TypeDefinition type,
|
||||||
|
List<String> fields,
|
||||||
|
List<String> forcedFields,
|
||||||
|
Form form,
|
||||||
|
Map<String, Object> context)
|
||||||
{
|
{
|
||||||
QName typeName = type.getName();
|
QName typeName = type.getName();
|
||||||
if (rmAdminService.isCustomisable(typeName) == true)
|
if (rmAdminService.isCustomisable(typeName) == true)
|
||||||
@@ -102,6 +107,18 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter
|
|||||||
addCustomRMProperties(aspect, form);
|
addCustomRMProperties(aspect, form);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the id
|
||||||
|
List<FieldDefinition> fieldDefs = form.getFieldDefinitions();
|
||||||
|
for (FieldDefinition fieldDef : fieldDefs)
|
||||||
|
{
|
||||||
|
String prefixName = fieldDef.getName();
|
||||||
|
if (prefixName.equals("rma:identifier"))
|
||||||
|
{
|
||||||
|
String defaultId = identifierService.generateIdentifier(typeName, null);
|
||||||
|
fieldDef.setDefaultValue(defaultId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,5 +157,4 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter
|
|||||||
public void afterPersist(TypeDefinition item, FormData data, final NodeRef nodeRef)
|
public void afterPersist(TypeDefinition item, FormData data, final NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.patch;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
|
import org.alfresco.repo.domain.node.NodeDAO;
|
||||||
|
import org.alfresco.repo.domain.patch.PatchDAO;
|
||||||
|
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||||
|
import org.alfresco.repo.module.AbstractModuleComponent;
|
||||||
|
import org.alfresco.repo.policy.BehaviourFilter;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.beans.factory.BeanNameAware;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RM v2.0 File Plan Node Ref Patch
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
*/
|
||||||
|
public class RMv2FilePlanNodeRefPatch extends AbstractModuleComponent
|
||||||
|
implements BeanNameAware, RecordsManagementModel, DOD5015Model
|
||||||
|
{
|
||||||
|
/** Logger */
|
||||||
|
private static Log logger = LogFactory.getLog(RMv2FilePlanNodeRefPatch.class);
|
||||||
|
|
||||||
|
private NodeService nodeService;
|
||||||
|
private RecordsManagementService recordsManagementService;
|
||||||
|
private BehaviourFilter behaviourFilter;
|
||||||
|
private PatchDAO patchDAO;
|
||||||
|
private NodeDAO nodeDAO;
|
||||||
|
private QNameDAO qnameDAO;
|
||||||
|
|
||||||
|
public void setNodeService(NodeService nodeService)
|
||||||
|
{
|
||||||
|
this.nodeService = nodeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
|
||||||
|
{
|
||||||
|
this.recordsManagementService = recordsManagementService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
|
||||||
|
{
|
||||||
|
this.behaviourFilter = behaviourFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPatchDAO(PatchDAO patchDAO)
|
||||||
|
{
|
||||||
|
this.patchDAO = patchDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeDAO(NodeDAO nodeDAO)
|
||||||
|
{
|
||||||
|
this.nodeDAO = nodeDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQnameDAO(QNameDAO qnameDAO)
|
||||||
|
{
|
||||||
|
this.qnameDAO = qnameDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void executeInternal() throws Throwable
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled() == true)
|
||||||
|
{
|
||||||
|
logger.debug("RM Module RMv2FilePlanNodeRef Patch ...");
|
||||||
|
}
|
||||||
|
|
||||||
|
Pair<Long, QName> aspectPair = qnameDAO.getQName(ASPECT_FILE_PLAN_COMPONENT);
|
||||||
|
if (aspectPair != null)
|
||||||
|
{
|
||||||
|
List<Long> records = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID());
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled() == true)
|
||||||
|
{
|
||||||
|
logger.debug(" ... updating " + records.size() + " items" );
|
||||||
|
}
|
||||||
|
|
||||||
|
behaviourFilter.disableBehaviour();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (Long record : records)
|
||||||
|
{
|
||||||
|
Pair<Long, NodeRef> recordPair = nodeDAO.getNodePair(record);
|
||||||
|
NodeRef recordNodeRef = recordPair.getSecond();
|
||||||
|
|
||||||
|
if (nodeService.getProperty(recordNodeRef, PROP_ROOT_NODEREF) == null)
|
||||||
|
{
|
||||||
|
nodeService.setProperty(recordNodeRef, PROP_ROOT_NODEREF, recordsManagementService.getFilePlan(recordNodeRef));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
behaviourFilter.enableBehaviour();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled() == true)
|
||||||
|
{
|
||||||
|
logger.debug(" ... complete RM Module RMv2FilePlanNodeRef Patch");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -80,7 +80,7 @@ public class RMv2ModelPatch extends AbstractModuleComponent
|
|||||||
{
|
{
|
||||||
if (logger.isDebugEnabled() == true)
|
if (logger.isDebugEnabled() == true)
|
||||||
{
|
{
|
||||||
logger.debug("RM Module NotificationTemplatePatch ...");
|
logger.debug("RM Module RMv2ModelPatch ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
updateQName(QName.createQName(DOD_URI, "filePlan"), TYPE_FILE_PLAN, "TYPE");
|
updateQName(QName.createQName(DOD_URI, "filePlan"), TYPE_FILE_PLAN, "TYPE");
|
||||||
|
@@ -22,24 +22,27 @@ import java.io.IOException;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.CustomMetadataException;
|
import org.alfresco.module.org_alfresco_module_rm.CustomMetadataException;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.PropertyAlreadyExistsMetadataException;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService;
|
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService;
|
||||||
|
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.json.JSONTokener;
|
||||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.json.JSONTokener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation for Java backed webscript to update RM custom property definitions
|
* Implementation for Java backed webscript to update RM custom property definitions
|
||||||
* in the custom model.
|
* in the custom model.
|
||||||
*
|
*
|
||||||
* @author Neil McErlean
|
* @author Neil McErlean
|
||||||
*/
|
*/
|
||||||
public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript
|
public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript
|
||||||
@@ -86,30 +89,30 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript
|
|||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
||||||
"Could not parse JSON from req.", je);
|
"Could not parse JSON from req.", je);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ftlModel;
|
return ftlModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies custom properties.
|
* Applies custom properties.
|
||||||
* @throws CustomMetadataException
|
* @throws CustomMetadataException
|
||||||
*/
|
*/
|
||||||
protected Map<String, Object> handlePropertyDefinitionUpdate(WebScriptRequest req, JSONObject json)
|
protected Map<String, Object> handlePropertyDefinitionUpdate(WebScriptRequest req, JSONObject json)
|
||||||
throws JSONException, CustomMetadataException
|
throws JSONException, CustomMetadataException
|
||||||
{
|
{
|
||||||
Map<String, Object> result = new HashMap<String, Object>();
|
Map<String, Object> result = new HashMap<String, Object>();
|
||||||
|
|
||||||
Map<String, Serializable> params = getParamsFromUrlAndJson(req, json);
|
Map<String, Serializable> params = getParamsFromUrlAndJson(req, json);
|
||||||
|
|
||||||
QName propertyQName;
|
QName propertyQName;
|
||||||
propertyQName = updatePropertyDefinition(params);
|
propertyQName = updatePropertyDefinition(params);
|
||||||
String localName = propertyQName.getLocalName();
|
String localName = propertyQName.getLocalName();
|
||||||
|
|
||||||
result.put(PROP_ID, localName);
|
result.put(PROP_ID, localName);
|
||||||
|
|
||||||
String urlResult = req.getServicePath();
|
String urlResult = req.getServicePath();
|
||||||
result.put(URL, urlResult);
|
result.put(URL, urlResult);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,15 +120,16 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript
|
|||||||
* If label has a non-null value, it is set on the property def.
|
* If label has a non-null value, it is set on the property def.
|
||||||
* If constraintRef has a non-null value, it is set on this propDef.
|
* If constraintRef has a non-null value, it is set on this propDef.
|
||||||
* If constraintRef has a null value, all constraints for that propDef are removed.
|
* If constraintRef has a null value, all constraints for that propDef are removed.
|
||||||
*
|
*
|
||||||
* @param params
|
* @param params
|
||||||
* @return
|
* @return
|
||||||
* @throws CustomMetadataException
|
* @throws CustomMetadataException
|
||||||
*/
|
*/
|
||||||
protected QName updatePropertyDefinition(Map<String, Serializable> params) throws CustomMetadataException
|
protected QName updatePropertyDefinition(Map<String, Serializable> params) throws CustomMetadataException
|
||||||
{
|
{
|
||||||
QName result = null;
|
QName result = null;
|
||||||
|
boolean updated = false;
|
||||||
|
|
||||||
String propId = (String)params.get(PROP_ID);
|
String propId = (String)params.get(PROP_ID);
|
||||||
ParameterCheck.mandatoryString("propId", propId);
|
ParameterCheck.mandatoryString("propId", propId);
|
||||||
|
|
||||||
@@ -135,45 +139,71 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript
|
|||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND,
|
throw new WebScriptException(Status.STATUS_NOT_FOUND,
|
||||||
"Could not find property definition for: " + propId);
|
"Could not find property definition for: " + propId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey(PARAM_CONSTRAINT_REF))
|
if (params.containsKey(PARAM_CONSTRAINT_REF))
|
||||||
{
|
{
|
||||||
String constraintRef = (String)params.get(PARAM_CONSTRAINT_REF);
|
String constraintRef = (String)params.get(PARAM_CONSTRAINT_REF);
|
||||||
|
List<ConstraintDefinition> constraints = rmAdminService.getCustomPropertyDefinitions().get(propQName).getConstraints();
|
||||||
if (constraintRef == null)
|
|
||||||
{
|
if (constraintRef == null)
|
||||||
result = rmAdminService.removeCustomPropertyDefinitionConstraints(propQName);
|
{
|
||||||
}
|
result = rmAdminService.removeCustomPropertyDefinitionConstraints(propQName);
|
||||||
else
|
updated = constraints.isEmpty() ? false : true;
|
||||||
{
|
}
|
||||||
QName constraintRefQName = QName.createQName(constraintRef, namespaceService);
|
else
|
||||||
result = rmAdminService.setCustomPropertyDefinitionConstraint(propQName, constraintRefQName);
|
{
|
||||||
}
|
boolean exists = false;
|
||||||
|
for (ConstraintDefinition constraintDefinition : constraints)
|
||||||
|
{
|
||||||
|
if (constraintDefinition.getConstraint().getShortName().equalsIgnoreCase(constraintRef))
|
||||||
|
{
|
||||||
|
exists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (exists == false)
|
||||||
|
{
|
||||||
|
QName constraintRefQName = QName.createQName(constraintRef, namespaceService);
|
||||||
|
result = rmAdminService.setCustomPropertyDefinitionConstraint(propQName, constraintRefQName);
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey(PARAM_LABEL))
|
if (params.containsKey(PARAM_LABEL))
|
||||||
{
|
{
|
||||||
String label = (String)params.get(PARAM_LABEL);
|
String label = (String)params.get(PARAM_LABEL);
|
||||||
result = rmAdminService.updateCustomPropertyDefinitionName(propQName, label);
|
try
|
||||||
|
{
|
||||||
|
result = rmAdminService.updateCustomPropertyDefinitionName(propQName, label);
|
||||||
|
}
|
||||||
|
catch (PropertyAlreadyExistsMetadataException ex)
|
||||||
|
{
|
||||||
|
if (updated == false)
|
||||||
|
{
|
||||||
|
String propIdAsString = rmAdminService.getQNameForClientId(label).toPrefixString(namespaceService);
|
||||||
|
throw new PropertyAlreadyExistsMetadataException(propIdAsString);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("rawtypes")
|
||||||
protected Map<String, Serializable> getParamsFromUrlAndJson(WebScriptRequest req, JSONObject json)
|
protected Map<String, Serializable> getParamsFromUrlAndJson(WebScriptRequest req, JSONObject json)
|
||||||
throws JSONException
|
throws JSONException
|
||||||
{
|
{
|
||||||
Map<String, Serializable> params;
|
Map<String, Serializable> params;
|
||||||
params = new HashMap<String, Serializable>();
|
params = new HashMap<String, Serializable>();
|
||||||
|
|
||||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||||
String propId = templateVars.get(PROP_ID);
|
String propId = templateVars.get(PROP_ID);
|
||||||
if (propId != null)
|
if (propId != null)
|
||||||
{
|
{
|
||||||
params.put(PROP_ID, (Serializable)propId);
|
params.put(PROP_ID, (Serializable)propId);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Iterator iter = json.keys(); iter.hasNext(); )
|
for (Iterator iter = json.keys(); iter.hasNext(); )
|
||||||
{
|
{
|
||||||
String nextKeyString = (String)iter.next();
|
String nextKeyString = (String)iter.next();
|
||||||
@@ -182,10 +212,10 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript
|
|||||||
{
|
{
|
||||||
nextValueString = json.getString(nextKeyString);
|
nextValueString = json.getString(nextKeyString);
|
||||||
}
|
}
|
||||||
|
|
||||||
params.put(nextKeyString, nextValueString);
|
params.put(nextKeyString, nextValueString);
|
||||||
}
|
}
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -59,79 +59,79 @@ import org.springframework.extensions.webscripts.WebScriptResponse;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Files a transfer report as a record.
|
* Files a transfer report as a record.
|
||||||
*
|
*
|
||||||
* @author Gavin Cornwell
|
* @author Gavin Cornwell
|
||||||
*/
|
*/
|
||||||
public class TransferReportPost extends BaseTransferWebScript
|
public class TransferReportPost extends BaseTransferWebScript
|
||||||
{
|
{
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static Log logger = LogFactory.getLog(TransferReportPost.class);
|
private static Log logger = LogFactory.getLog(TransferReportPost.class);
|
||||||
|
|
||||||
protected static final String REPORT_FILE_PREFIX = "report_";
|
protected static final String REPORT_FILE_PREFIX = "report_";
|
||||||
protected static final String REPORT_FILE_SUFFIX = ".html";
|
protected static final String REPORT_FILE_SUFFIX = ".html";
|
||||||
protected static final String PARAM_DESTINATION = "destination";
|
protected static final String PARAM_DESTINATION = "destination";
|
||||||
protected static final String RESPONSE_SUCCESS = "success";
|
protected static final String RESPONSE_SUCCESS = "success";
|
||||||
protected static final String RESPONSE_RECORD = "record";
|
protected static final String RESPONSE_RECORD = "record";
|
||||||
protected static final String RESPONSE_RECORD_NAME = "recordName";
|
protected static final String RESPONSE_RECORD_NAME = "recordName";
|
||||||
|
|
||||||
protected DictionaryService ddService;
|
protected DictionaryService ddService;
|
||||||
protected RecordsManagementActionService rmActionService;
|
protected RecordsManagementActionService rmActionService;
|
||||||
protected RecordsManagementService rmService;
|
protected RecordsManagementService rmService;
|
||||||
protected DispositionService dispositionService;
|
protected DispositionService dispositionService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the DictionaryService instance
|
* Sets the DictionaryService instance
|
||||||
*
|
*
|
||||||
* @param ddService The DictionaryService instance
|
* @param ddService The DictionaryService instance
|
||||||
*/
|
*/
|
||||||
public void setDictionaryService(DictionaryService ddService)
|
public void setDictionaryService(DictionaryService ddService)
|
||||||
{
|
{
|
||||||
this.ddService = ddService;
|
this.ddService = ddService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the RecordsManagementService instance
|
* Sets the RecordsManagementService instance
|
||||||
*
|
*
|
||||||
* @param rmService RecordsManagementService instance
|
* @param rmService RecordsManagementService instance
|
||||||
*/
|
*/
|
||||||
public void setRecordsManagementService(RecordsManagementService rmService)
|
public void setRecordsManagementService(RecordsManagementService rmService)
|
||||||
{
|
{
|
||||||
this.rmService = rmService;
|
this.rmService = rmService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the disposition service
|
* Sets the disposition service
|
||||||
*
|
*
|
||||||
* @param dispositionService disposition service
|
* @param dispositionService disposition service
|
||||||
*/
|
*/
|
||||||
public void setDispositionService(DispositionService dispositionService)
|
public void setDispositionService(DispositionService dispositionService)
|
||||||
{
|
{
|
||||||
this.dispositionService = dispositionService;
|
this.dispositionService = dispositionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the RecordsManagementActionService instance
|
* Sets the RecordsManagementActionService instance
|
||||||
*
|
*
|
||||||
* @param rmActionService RecordsManagementActionService instance
|
* @param rmActionService RecordsManagementActionService instance
|
||||||
*/
|
*/
|
||||||
public void setRecordsManagementActionService(RecordsManagementActionService rmActionService)
|
public void setRecordsManagementActionService(RecordsManagementActionService rmActionService)
|
||||||
{
|
{
|
||||||
this.rmActionService = rmActionService;
|
this.rmActionService = rmActionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected File executeTransfer(NodeRef transferNode,
|
protected File executeTransfer(NodeRef transferNode,
|
||||||
WebScriptRequest req, WebScriptResponse res,
|
WebScriptRequest req, WebScriptResponse res,
|
||||||
Status status, Cache cache) throws IOException
|
Status status, Cache cache) throws IOException
|
||||||
{
|
{
|
||||||
File report = null;
|
File report = null;
|
||||||
|
|
||||||
// retrieve requested format
|
// retrieve requested format
|
||||||
String format = req.getFormat();
|
String format = req.getFormat();
|
||||||
Map<String, Object> model = new HashMap<String, Object>();
|
Map<String, Object> model = new HashMap<String, Object>();
|
||||||
model.put("status", status);
|
model.put("status", status);
|
||||||
model.put("cache", cache);
|
model.put("cache", cache);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// extract the destination parameter, ensure it's present and it is
|
// extract the destination parameter, ensure it's present and it is
|
||||||
@@ -139,63 +139,63 @@ public class TransferReportPost extends BaseTransferWebScript
|
|||||||
JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent()));
|
JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent()));
|
||||||
if (!json.has(PARAM_DESTINATION))
|
if (!json.has(PARAM_DESTINATION))
|
||||||
{
|
{
|
||||||
status.setCode(HttpServletResponse.SC_BAD_REQUEST,
|
status.setCode(HttpServletResponse.SC_BAD_REQUEST,
|
||||||
"Mandatory '" + PARAM_DESTINATION + "' parameter has not been supplied");
|
"Mandatory '" + PARAM_DESTINATION + "' parameter has not been supplied");
|
||||||
Map<String, Object> templateModel = createTemplateParameters(req, res, model);
|
Map<String, Object> templateModel = createTemplateParameters(req, res, model);
|
||||||
sendStatus(req, res, status, cache, format, templateModel);
|
sendStatus(req, res, status, cache, format, templateModel);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String destinationParam = json.getString(PARAM_DESTINATION);
|
String destinationParam = json.getString(PARAM_DESTINATION);
|
||||||
NodeRef destination = new NodeRef(destinationParam);
|
NodeRef destination = new NodeRef(destinationParam);
|
||||||
|
|
||||||
if (!this.nodeService.exists(destination))
|
if (!this.nodeService.exists(destination))
|
||||||
{
|
{
|
||||||
status.setCode(HttpServletResponse.SC_NOT_FOUND,
|
status.setCode(HttpServletResponse.SC_NOT_FOUND,
|
||||||
"Node " + destination.toString() + " does not exist");
|
"Node " + destination.toString() + " does not exist");
|
||||||
Map<String, Object> templateModel = createTemplateParameters(req, res, model);
|
Map<String, Object> templateModel = createTemplateParameters(req, res, model);
|
||||||
sendStatus(req, res, status, cache, format, templateModel);
|
sendStatus(req, res, status, cache, format, templateModel);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure the node is a filePlan object
|
// ensure the node is a filePlan object
|
||||||
if (!RecordsManagementModel.TYPE_RECORD_FOLDER.equals(this.nodeService.getType(destination)))
|
if (!RecordsManagementModel.TYPE_RECORD_FOLDER.equals(this.nodeService.getType(destination)))
|
||||||
{
|
{
|
||||||
status.setCode(HttpServletResponse.SC_BAD_REQUEST,
|
status.setCode(HttpServletResponse.SC_BAD_REQUEST,
|
||||||
"Node " + destination.toString() + " is not a record folder");
|
"Node " + destination.toString() + " is not a record folder");
|
||||||
Map<String, Object> templateModel = createTemplateParameters(req, res, model);
|
Map<String, Object> templateModel = createTemplateParameters(req, res, model);
|
||||||
sendStatus(req, res, status, cache, format, templateModel);
|
sendStatus(req, res, status, cache, format, templateModel);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("Filing transfer report as record in record folder: " + destination);
|
logger.debug("Filing transfer report as record in record folder: " + destination);
|
||||||
|
|
||||||
// generate the report (will be in JSON format)
|
// generate the report (will be in JSON format)
|
||||||
report = generateHTMLTransferReport(transferNode);
|
report = generateHTMLTransferReport(transferNode);
|
||||||
|
|
||||||
// file the report as a record
|
// file the report as a record
|
||||||
NodeRef record = fileTransferReport(report, destination);
|
NodeRef record = fileTransferReport(report, destination);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("Filed transfer report as new record: " + record);
|
logger.debug("Filed transfer report as new record: " + record);
|
||||||
|
|
||||||
// return success flag and record noderef as JSON
|
// return success flag and record noderef as JSON
|
||||||
JSONObject responseJSON = new JSONObject();
|
JSONObject responseJSON = new JSONObject();
|
||||||
responseJSON.put(RESPONSE_SUCCESS, (record != null));
|
responseJSON.put(RESPONSE_SUCCESS, (record != null));
|
||||||
if (record != null)
|
if (record != null)
|
||||||
{
|
{
|
||||||
responseJSON.put(RESPONSE_RECORD, record.toString());
|
responseJSON.put(RESPONSE_RECORD, record.toString());
|
||||||
responseJSON.put(RESPONSE_RECORD_NAME,
|
responseJSON.put(RESPONSE_RECORD_NAME,
|
||||||
(String)nodeService.getProperty(record, ContentModel.PROP_NAME));
|
(String)nodeService.getProperty(record, ContentModel.PROP_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup response
|
// setup response
|
||||||
String jsonString = responseJSON.toString();
|
String jsonString = responseJSON.toString();
|
||||||
res.setContentType(MimetypeMap.MIMETYPE_JSON);
|
res.setContentType(MimetypeMap.MIMETYPE_JSON);
|
||||||
res.setContentEncoding("UTF-8");
|
res.setContentEncoding("UTF-8");
|
||||||
res.setHeader("Content-Length", Long.toString(jsonString.length()));
|
res.setHeader("Content-Length", Long.toString(jsonString.length()));
|
||||||
|
|
||||||
// write the JSON response
|
// write the JSON response
|
||||||
res.getWriter().write(jsonString);
|
res.getWriter().write(jsonString);
|
||||||
}
|
}
|
||||||
@@ -203,14 +203,14 @@ public class TransferReportPost extends BaseTransferWebScript
|
|||||||
{
|
{
|
||||||
throw createStatusException(je, req, res);
|
throw createStatusException(je, req, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the file for deletion
|
// return the file for deletion
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a File containing the JSON representation of a transfer report.
|
* Generates a File containing the JSON representation of a transfer report.
|
||||||
*
|
*
|
||||||
* @param transferNode The transfer node
|
* @param transferNode The transfer node
|
||||||
* @return File containing JSON representation of a transfer report
|
* @return File containing JSON representation of a transfer report
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
@@ -223,16 +223,16 @@ public class TransferReportPost extends BaseTransferWebScript
|
|||||||
{
|
{
|
||||||
// get all 'transferred' nodes
|
// get all 'transferred' nodes
|
||||||
NodeRef[] itemsToTransfer = getTransferNodes(transferNode);
|
NodeRef[] itemsToTransfer = getTransferNodes(transferNode);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("Generating HTML transfer report for " + itemsToTransfer.length +
|
logger.debug("Generating HTML transfer report for " + itemsToTransfer.length +
|
||||||
" items into file: " + report.getAbsolutePath());
|
" items into file: " + report.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the writer
|
// create the writer
|
||||||
writer = new FileWriter(report);
|
writer = new FileWriter(report);
|
||||||
|
|
||||||
// use RMService to get disposition authority
|
// use RMService to get disposition authority
|
||||||
String dispositionAuthority = null;
|
String dispositionAuthority = null;
|
||||||
if (itemsToTransfer.length > 0)
|
if (itemsToTransfer.length > 0)
|
||||||
@@ -244,11 +244,19 @@ public class TransferReportPost extends BaseTransferWebScript
|
|||||||
dispositionAuthority = ds.getDispositionAuthority();
|
dispositionAuthority = ds.getDispositionAuthority();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the HTML header
|
// write the HTML header
|
||||||
writer.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
|
writer.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
|
||||||
writer.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n");
|
writer.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n");
|
||||||
writer.write("<title>Transfer Report</title></head>\n");
|
Boolean isAccession = (Boolean)this.nodeService.getProperty(transferNode, PROP_TRANSFER_ACCESSION_INDICATOR);
|
||||||
|
if (isAccession == true)
|
||||||
|
{
|
||||||
|
writer.write("<title>Accession Report</title></head>\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writer.write("<title>Transfer Report</title></head>\n");
|
||||||
|
}
|
||||||
writer.write("<style>\n");
|
writer.write("<style>\n");
|
||||||
writer.write("body { font-family: arial,verdana; font-size: 81%; color: #333; }\n");
|
writer.write("body { font-family: arial,verdana; font-size: 81%; color: #333; }\n");
|
||||||
writer.write(".records { margin-left: 20px; margin-top: 10px; }\n");
|
writer.write(".records { margin-left: 20px; margin-top: 10px; }\n");
|
||||||
@@ -257,30 +265,44 @@ public class TransferReportPost extends BaseTransferWebScript
|
|||||||
writer.write(".nodeName { font-weight: bold; }\n");
|
writer.write(".nodeName { font-weight: bold; }\n");
|
||||||
writer.write(".transferred-item { background-color: #eee; padding: 10px; margin-bottom: 15px; }\n");
|
writer.write(".transferred-item { background-color: #eee; padding: 10px; margin-bottom: 15px; }\n");
|
||||||
writer.write("</style>\n");
|
writer.write("</style>\n");
|
||||||
writer.write("<body>\n<h1>Transfer Report</h1>\n");
|
if (isAccession == true)
|
||||||
|
{
|
||||||
|
writer.write("<body>\n<h1>Accession Report</h1>\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writer.write("<body>\n<h1>Transfer Report</h1>\n");
|
||||||
|
}
|
||||||
|
|
||||||
writer.write("<table cellpadding=\"3\" cellspacing=\"3\">");
|
writer.write("<table cellpadding=\"3\" cellspacing=\"3\">");
|
||||||
writer.write("<tr><td class=\"label\">Transfer Date:</td><td>");
|
writer.write("<tr><td class=\"label\">Transfer Date:</td><td>");
|
||||||
Date transferDate = (Date)this.nodeService.getProperty(transferNode, ContentModel.PROP_CREATED);
|
Date transferDate = (Date)this.nodeService.getProperty(transferNode, ContentModel.PROP_CREATED);
|
||||||
writer.write(StringEscapeUtils.escapeHtml(transferDate.toString()));
|
writer.write(StringEscapeUtils.escapeHtml(transferDate.toString()));
|
||||||
writer.write("</td></tr>");
|
writer.write("</td></tr>");
|
||||||
writer.write("<tr><td class=\"label\">Transfer Location:</td><td>");
|
writer.write("<tr><td class=\"label\">Transfer Location:</td><td>");
|
||||||
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(transferNode,
|
if (isAccession == true)
|
||||||
|
{
|
||||||
|
writer.write("NARA");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(transferNode,
|
||||||
RecordsManagementModel.PROP_TRANSFER_LOCATION)));
|
RecordsManagementModel.PROP_TRANSFER_LOCATION)));
|
||||||
|
}
|
||||||
writer.write("</td></tr>");
|
writer.write("</td></tr>");
|
||||||
writer.write("<tr><td class=\"label\">Performed By:</td><td>");
|
writer.write("<tr><td class=\"label\">Performed By:</td><td>");
|
||||||
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(transferNode,
|
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(transferNode,
|
||||||
ContentModel.PROP_CREATOR)));
|
ContentModel.PROP_CREATOR)));
|
||||||
writer.write("</td></tr>");
|
writer.write("</td></tr>");
|
||||||
writer.write("<tr><td class=\"label\">Disposition Authority:</td><td>");
|
writer.write("<tr><td class=\"label\">Disposition Authority:</td><td>");
|
||||||
writer.write(dispositionAuthority != null ? StringEscapeUtils.escapeHtml(dispositionAuthority) : "");
|
writer.write(dispositionAuthority != null ? StringEscapeUtils.escapeHtml(dispositionAuthority) : "");
|
||||||
writer.write("</td></tr></table>\n");
|
writer.write("</td></tr></table>\n");
|
||||||
|
|
||||||
writer.write("<h2>Transferred Items</h2>\n");
|
writer.write("<h2>Transferred Items</h2>\n");
|
||||||
|
|
||||||
// write out HTML representation of items to transfer
|
// write out HTML representation of items to transfer
|
||||||
generateTransferItemsHTML(writer, itemsToTransfer);
|
generateTransferItemsHTML(writer, itemsToTransfer);
|
||||||
|
|
||||||
// write the HTML footer
|
// write the HTML footer
|
||||||
writer.write("</body></html>");
|
writer.write("</body></html>");
|
||||||
}
|
}
|
||||||
@@ -291,13 +313,13 @@ public class TransferReportPost extends BaseTransferWebScript
|
|||||||
try { writer.close(); } catch (IOException ioe) {}
|
try { writer.close(); } catch (IOException ioe) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the JSON to represent the given NodeRefs
|
* Generates the JSON to represent the given NodeRefs
|
||||||
*
|
*
|
||||||
* @param writer Writer to write to
|
* @param writer Writer to write to
|
||||||
* @param itemsToTransfer NodeRefs being transferred
|
* @param itemsToTransfer NodeRefs being transferred
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
@@ -319,10 +341,10 @@ public class TransferReportPost extends BaseTransferWebScript
|
|||||||
writer.write("</div>\n");
|
writer.write("</div>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the JSON to represent the given folder.
|
* Generates the JSON to represent the given folder.
|
||||||
*
|
*
|
||||||
* @param writer Writer to write to
|
* @param writer Writer to write to
|
||||||
* @param folderNode Folder being transferred
|
* @param folderNode Folder being transferred
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
@@ -331,19 +353,19 @@ public class TransferReportPost extends BaseTransferWebScript
|
|||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
writer.write("<span class=\"nodeName\">");
|
writer.write("<span class=\"nodeName\">");
|
||||||
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(folderNode,
|
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(folderNode,
|
||||||
ContentModel.PROP_NAME)));
|
ContentModel.PROP_NAME)));
|
||||||
writer.write("</span> (Unique Folder Identifier: ");
|
writer.write("</span> (Unique Folder Identifier: ");
|
||||||
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(folderNode,
|
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(folderNode,
|
||||||
RecordsManagementModel.PROP_IDENTIFIER)));
|
RecordsManagementModel.PROP_IDENTIFIER)));
|
||||||
writer.write(")\n");
|
writer.write(")\n");
|
||||||
|
|
||||||
writer.write("<div class=\"records\">\n");
|
writer.write("<div class=\"records\">\n");
|
||||||
|
|
||||||
// NOTE: we don't expect any nested folder structures so just render
|
// NOTE: we don't expect any nested folder structures so just render
|
||||||
// the records contained in the folder.
|
// the records contained in the folder.
|
||||||
|
|
||||||
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(folderNode,
|
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(folderNode,
|
||||||
ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
|
ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
|
||||||
for (ChildAssociationRef child : assocs)
|
for (ChildAssociationRef child : assocs)
|
||||||
{
|
{
|
||||||
@@ -353,13 +375,13 @@ public class TransferReportPost extends BaseTransferWebScript
|
|||||||
generateTransferRecordHTML(writer, childRef);
|
generateTransferRecordHTML(writer, childRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.write("\n</div>\n");
|
writer.write("\n</div>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the JSON to represent the given record.
|
* Generates the JSON to represent the given record.
|
||||||
*
|
*
|
||||||
* @param writer Writer to write to
|
* @param writer Writer to write to
|
||||||
* @param recordNode Record being transferred
|
* @param recordNode Record being transferred
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
@@ -369,29 +391,29 @@ public class TransferReportPost extends BaseTransferWebScript
|
|||||||
{
|
{
|
||||||
writer.write("<div class=\"record\">\n");
|
writer.write("<div class=\"record\">\n");
|
||||||
writer.write(" <span class=\"nodeName\">");
|
writer.write(" <span class=\"nodeName\">");
|
||||||
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode,
|
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode,
|
||||||
ContentModel.PROP_NAME)));
|
ContentModel.PROP_NAME)));
|
||||||
writer.write("</span> (Unique Record Identifier: ");
|
writer.write("</span> (Unique Record Identifier: ");
|
||||||
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode,
|
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode,
|
||||||
RecordsManagementModel.PROP_IDENTIFIER)));
|
RecordsManagementModel.PROP_IDENTIFIER)));
|
||||||
writer.write(")");
|
writer.write(")");
|
||||||
|
|
||||||
if (this.nodeService.hasAspect(recordNode, RecordsManagementModel.ASPECT_DECLARED_RECORD))
|
if (this.nodeService.hasAspect(recordNode, RecordsManagementModel.ASPECT_DECLARED_RECORD))
|
||||||
{
|
{
|
||||||
Date declaredOn = (Date)this.nodeService.getProperty(recordNode, RecordsManagementModel.PROP_DECLARED_AT);
|
Date declaredOn = (Date)this.nodeService.getProperty(recordNode, RecordsManagementModel.PROP_DECLARED_AT);
|
||||||
writer.write(" declared by ");
|
writer.write(" declared by ");
|
||||||
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode,
|
writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode,
|
||||||
RecordsManagementModel.PROP_DECLARED_BY)));
|
RecordsManagementModel.PROP_DECLARED_BY)));
|
||||||
writer.write(" on ");
|
writer.write(" on ");
|
||||||
writer.write(StringEscapeUtils.escapeHtml(declaredOn.toString()));
|
writer.write(StringEscapeUtils.escapeHtml(declaredOn.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.write("\n</div>\n");
|
writer.write("\n</div>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Files the given transfer report as a record in the given record folder.
|
* Files the given transfer report as a record in the given record folder.
|
||||||
*
|
*
|
||||||
* @param report Report to file
|
* @param report Report to file
|
||||||
* @param destination The destination record folder
|
* @param destination The destination record folder
|
||||||
* @return NodeRef of the created record
|
* @return NodeRef of the created record
|
||||||
@@ -400,17 +422,17 @@ public class TransferReportPost extends BaseTransferWebScript
|
|||||||
{
|
{
|
||||||
ParameterCheck.mandatory("report", report);
|
ParameterCheck.mandatory("report", report);
|
||||||
ParameterCheck.mandatory("destination", destination);
|
ParameterCheck.mandatory("destination", destination);
|
||||||
|
|
||||||
NodeRef record = null;
|
NodeRef record = null;
|
||||||
|
|
||||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(1);
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(1);
|
||||||
properties.put(ContentModel.PROP_NAME, report.getName());
|
properties.put(ContentModel.PROP_NAME, report.getName());
|
||||||
|
|
||||||
// file the transfer report as an undeclared record
|
// file the transfer report as an undeclared record
|
||||||
record = this.nodeService.createNode(destination,
|
record = this.nodeService.createNode(destination,
|
||||||
ContentModel.ASSOC_CONTAINS,
|
ContentModel.ASSOC_CONTAINS,
|
||||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
|
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
|
||||||
QName.createValidLocalName(report.getName())),
|
QName.createValidLocalName(report.getName())),
|
||||||
ContentModel.TYPE_CONTENT, properties).getChildRef();
|
ContentModel.TYPE_CONTENT, properties).getChildRef();
|
||||||
|
|
||||||
// Set the content
|
// Set the content
|
||||||
@@ -418,7 +440,7 @@ public class TransferReportPost extends BaseTransferWebScript
|
|||||||
writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
|
writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
|
||||||
writer.setEncoding("UTF-8");
|
writer.setEncoding("UTF-8");
|
||||||
writer.putContent(report);
|
writer.putContent(report);
|
||||||
|
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -21,6 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.script.slingshot;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -53,7 +54,7 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* RM search GET web script
|
* RM search GET web script
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public class RMSearchGet extends DeclarativeWebScript
|
public class RMSearchGet extends DeclarativeWebScript
|
||||||
@@ -63,34 +64,34 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
private static final String PARAM_SORTBY = "sortby";
|
private static final String PARAM_SORTBY = "sortby";
|
||||||
private static final String PARAM_FILTERS = "filters";
|
private static final String PARAM_FILTERS = "filters";
|
||||||
private static final String PARAM_MAX_ITEMS = "maxitems";
|
private static final String PARAM_MAX_ITEMS = "maxitems";
|
||||||
|
|
||||||
/** Records management search service */
|
/** Records management search service */
|
||||||
protected RecordsManagementSearchService recordsManagementSearchService;
|
protected RecordsManagementSearchService recordsManagementSearchService;
|
||||||
|
|
||||||
/** Site service */
|
/** Site service */
|
||||||
protected SiteService siteService;
|
protected SiteService siteService;
|
||||||
|
|
||||||
/** Namespace service */
|
/** Namespace service */
|
||||||
protected NamespaceService namespaceService;
|
protected NamespaceService namespaceService;
|
||||||
|
|
||||||
/** Node serivce */
|
/** Node serivce */
|
||||||
protected NodeService nodeService;
|
protected NodeService nodeService;
|
||||||
|
|
||||||
/** Dictionary service */
|
/** Dictionary service */
|
||||||
protected DictionaryService dictionaryService;
|
protected DictionaryService dictionaryService;
|
||||||
|
|
||||||
/** Permission service */
|
/** Permission service */
|
||||||
protected PermissionService permissionService;
|
protected PermissionService permissionService;
|
||||||
|
|
||||||
/** Person service */
|
/** Person service */
|
||||||
protected PersonService personService;
|
protected PersonService personService;
|
||||||
|
|
||||||
/** Content service */
|
/** Content service */
|
||||||
protected ContentService contentService;
|
protected ContentService contentService;
|
||||||
|
|
||||||
/** Person data cache */
|
/** Person data cache */
|
||||||
private Map<String, String> personDataCache = null;
|
private Map<String, String> personDataCache = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param recordsManagementSearchService records management search service
|
* @param recordsManagementSearchService records management search service
|
||||||
*/
|
*/
|
||||||
@@ -98,7 +99,7 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.recordsManagementSearchService = recordsManagementSearchService;
|
this.recordsManagementSearchService = recordsManagementSearchService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param siteService site service
|
* @param siteService site service
|
||||||
*/
|
*/
|
||||||
@@ -106,7 +107,7 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.siteService = siteService;
|
this.siteService = siteService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param namespaceService namespace service
|
* @param namespaceService namespace service
|
||||||
*/
|
*/
|
||||||
@@ -114,7 +115,7 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.namespaceService = namespaceService;
|
this.namespaceService = namespaceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param nodeService node service
|
* @param nodeService node service
|
||||||
*/
|
*/
|
||||||
@@ -122,7 +123,7 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dictionaryService dictionary service
|
* @param dictionaryService dictionary service
|
||||||
*/
|
*/
|
||||||
@@ -130,7 +131,7 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.dictionaryService = dictionaryService;
|
this.dictionaryService = dictionaryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param permissionService permission service
|
* @param permissionService permission service
|
||||||
*/
|
*/
|
||||||
@@ -138,7 +139,7 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.permissionService = permissionService;
|
this.permissionService = permissionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param personService person service
|
* @param personService person service
|
||||||
*/
|
*/
|
||||||
@@ -146,7 +147,7 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.personService = personService;
|
this.personService = personService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param contentService content service
|
* @param contentService content service
|
||||||
*/
|
*/
|
||||||
@@ -154,7 +155,7 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.contentService = contentService;
|
this.contentService = contentService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
||||||
*/
|
*/
|
||||||
@@ -162,7 +163,7 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
// Get the site id and confirm it is valid
|
// Get the site id and confirm it is valid
|
||||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||||
String siteId = templateVars.get("site");
|
String siteId = templateVars.get("site");
|
||||||
if (siteId == null || siteId.length() == 0)
|
if (siteId == null || siteId.length() == 0)
|
||||||
{
|
{
|
||||||
@@ -172,50 +173,55 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Site not found.");
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Site not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the query parameter
|
// Get the query parameter
|
||||||
String query = req.getParameter(PARAM_QUERY);
|
String query = req.getParameter(PARAM_QUERY);
|
||||||
// TODO check that this is there
|
// TODO check that this is there
|
||||||
|
|
||||||
String sortby = req.getParameter(PARAM_SORTBY);
|
String sortby = req.getParameter(PARAM_SORTBY);
|
||||||
// TODO this is optional
|
// TODO this is optional
|
||||||
|
|
||||||
String filters = req.getParameter(PARAM_FILTERS);
|
String filters = req.getParameter(PARAM_FILTERS);
|
||||||
// TODO this is optional
|
// TODO this is optional
|
||||||
|
|
||||||
// Convert into a rm search parameter object
|
// Convert into a rm search parameter object
|
||||||
RecordsManagementSearchParameters searchParameters =
|
RecordsManagementSearchParameters searchParameters =
|
||||||
SavedSearchDetailsCompatibility.createSearchParameters(filters, new String[]{",", "/"}, sortby, namespaceService);
|
SavedSearchDetailsCompatibility.createSearchParameters(filters, new String[]{",", "/"}, sortby, namespaceService);
|
||||||
|
|
||||||
// Set the max results
|
// Set the max results
|
||||||
String maxItems = req.getParameter(PARAM_MAX_ITEMS);
|
String maxItems = req.getParameter(PARAM_MAX_ITEMS);
|
||||||
if (maxItems != null && maxItems.length() != 0)
|
if (maxItems != null && maxItems.length() != 0)
|
||||||
{
|
{
|
||||||
searchParameters.setMaxItems(Integer.parseInt(maxItems));
|
searchParameters.setMaxItems(Integer.parseInt(maxItems));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute search
|
// Execute search
|
||||||
List<NodeRef> results = recordsManagementSearchService.search(siteId, query, searchParameters);
|
List<NodeRef> results = recordsManagementSearchService.search(siteId, query, searchParameters);
|
||||||
|
|
||||||
// Reset person data cache
|
// Reset person data cache
|
||||||
personDataCache = new HashMap<String, String>(57);
|
personDataCache = new HashMap<String, String>(57);
|
||||||
|
|
||||||
// Process the result items
|
// Process the result items
|
||||||
Item[] items = new Item[results.size()];
|
List<Item> items = new ArrayList<Item>(results.size());
|
||||||
int index = 0;
|
|
||||||
for (NodeRef nodeRef : results)
|
for (NodeRef nodeRef : results)
|
||||||
{
|
{
|
||||||
items[index] = new Item(nodeRef);
|
// FIXME: This is a workaround for DOD Recert
|
||||||
index++;
|
// TC 3-3 Create User Groups
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Item item = new Item(nodeRef);
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
catch(Exception e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return model
|
// Return model
|
||||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||||
model.put("items", items);
|
model.put("items", items);
|
||||||
return model;
|
return model;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Item class to contain information about items being placed in model.
|
* Item class to contain information about items being placed in model.
|
||||||
*/
|
*/
|
||||||
@@ -231,38 +237,38 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
private String createdBy;
|
private String createdBy;
|
||||||
private Map<QName, Serializable> nodeProperties;
|
private Map<QName, Serializable> nodeProperties;
|
||||||
private Map<String, Serializable> properties;
|
private Map<String, Serializable> properties;
|
||||||
|
|
||||||
public Item(NodeRef nodeRef)
|
public Item(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
// Set node ref
|
// Set node ref
|
||||||
this.nodeRef = nodeRef;
|
this.nodeRef = nodeRef;
|
||||||
|
|
||||||
// Get type
|
// Get type
|
||||||
QName nodeRefType = nodeService.getType(nodeRef);
|
QName nodeRefType = nodeService.getType(nodeRef);
|
||||||
this.type = nodeRefType.toPrefixString(namespaceService);
|
this.type = nodeRefType.toPrefixString(namespaceService);
|
||||||
|
|
||||||
// Get properties
|
// Get properties
|
||||||
this.nodeProperties = nodeService.getProperties(nodeRef);
|
this.nodeProperties = nodeService.getProperties(nodeRef);
|
||||||
|
|
||||||
// Determine if container or not
|
// Determine if container or not
|
||||||
isContainer = true;
|
isContainer = true;
|
||||||
if (dictionaryService.isSubClass(nodeRefType, ContentModel.TYPE_CONTENT) == true)
|
if (dictionaryService.isSubClass(nodeRefType, ContentModel.TYPE_CONTENT) == true)
|
||||||
{
|
{
|
||||||
isContainer = false;
|
isContainer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get parent node reference
|
// Get parent node reference
|
||||||
NodeRef parent = null;
|
NodeRef parent = null;
|
||||||
ChildAssociationRef assoc = nodeService.getPrimaryParent(nodeRef);
|
ChildAssociationRef assoc = nodeService.getPrimaryParent(nodeRef);
|
||||||
if (assoc != null)
|
if (assoc != null)
|
||||||
{
|
{
|
||||||
parent = assoc.getParentRef();
|
parent = assoc.getParentRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isContainer == true)
|
if (isContainer == true)
|
||||||
{
|
{
|
||||||
this.size = -1;
|
this.size = -1;
|
||||||
|
|
||||||
String displayPath = nodeService.getPath(nodeRef).toDisplayPath(nodeService, permissionService);
|
String displayPath = nodeService.getPath(nodeRef).toDisplayPath(nodeService, permissionService);
|
||||||
String[] pathElements = displayPath.split("/");
|
String[] pathElements = displayPath.split("/");
|
||||||
if (pathElements.length >= 5)
|
if (pathElements.length >= 5)
|
||||||
@@ -271,7 +277,7 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.parentFolder = (String)nodeService.getProperty(parent, ContentModel.PROP_NAME);
|
this.parentFolder = (String)nodeService.getProperty(parent, ContentModel.PROP_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
pathElements = (String[])ArrayUtils.subarray(pathElements, 5, pathElements.length);
|
pathElements = (String[])ArrayUtils.subarray(pathElements, 5, pathElements.length);
|
||||||
String newPath = StringUtils.join(pathElements, "/");
|
String newPath = StringUtils.join(pathElements, "/");
|
||||||
StringBuilder relPath = new StringBuilder("/").append(newPath);
|
StringBuilder relPath = new StringBuilder("/").append(newPath);
|
||||||
@@ -287,7 +293,7 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
catch (UnsupportedEncodingException e)
|
catch (UnsupportedEncodingException e)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Could not process search results.", e);
|
throw new AlfrescoRuntimeException("Could not process search results.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -299,27 +305,27 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.size = (int)contentData.getSize();
|
this.size = (int)contentData.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the document parent name
|
// Set the document parent name
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
{
|
{
|
||||||
this.parentFolder = (String)nodeService.getProperty(parent, ContentModel.PROP_NAME);
|
this.parentFolder = (String)nodeService.getProperty(parent, ContentModel.PROP_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the document browse URL
|
// Set the document browse URL
|
||||||
this.browseUrl = "document-details?nodeRef=" + nodeRef.toString();
|
this.browseUrl = "document-details?nodeRef=" + nodeRef.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.modifiedBy = getDisplayName(getModifiedByUser());
|
this.modifiedBy = getDisplayName(getModifiedByUser());
|
||||||
this.createdBy = getDisplayName(getCreatedByUser());
|
this.createdBy = getDisplayName(getCreatedByUser());
|
||||||
|
|
||||||
// Process the custom properties
|
// Process the custom properties
|
||||||
properties = new HashMap<String, Serializable>(nodeProperties.size());
|
properties = new HashMap<String, Serializable>(nodeProperties.size());
|
||||||
for (Map.Entry<QName, Serializable> entry : nodeProperties.entrySet())
|
for (Map.Entry<QName, Serializable> entry : nodeProperties.entrySet())
|
||||||
{
|
{
|
||||||
QName qName = entry.getKey().getPrefixedQName(namespaceService);
|
QName qName = entry.getKey().getPrefixedQName(namespaceService);
|
||||||
if (NamespaceService.SYSTEM_MODEL_1_0_URI.equals(qName.getNamespaceURI()) == false)
|
if (NamespaceService.SYSTEM_MODEL_1_0_URI.equals(qName.getNamespaceURI()) == false)
|
||||||
{
|
{
|
||||||
String prefixName = qName.getPrefixString().replace(":", "_");
|
String prefixName = qName.getPrefixString().replace(":", "_");
|
||||||
Serializable value = entry.getValue();
|
Serializable value = entry.getValue();
|
||||||
if (value instanceof NodeRef)
|
if (value instanceof NodeRef)
|
||||||
@@ -335,7 +341,7 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDisplayName(String userName)
|
private String getDisplayName(String userName)
|
||||||
{
|
{
|
||||||
String result = personDataCache.get(userName);
|
String result = personDataCache.get(userName);
|
||||||
@@ -356,85 +362,85 @@ public class RMSearchGet extends DeclarativeWebScript
|
|||||||
}
|
}
|
||||||
personDataCache.put(userName, result);
|
personDataCache.put(userName, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeRef getNodeRef()
|
public NodeRef getNodeRef()
|
||||||
{
|
{
|
||||||
return nodeRef;
|
return nodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType()
|
public String getType()
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return (String)nodeProperties.get(ContentModel.PROP_NAME);
|
return (String)nodeProperties.get(ContentModel.PROP_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle()
|
public String getTitle()
|
||||||
{
|
{
|
||||||
return (String)nodeProperties.get(ContentModel.PROP_TITLE);
|
return (String)nodeProperties.get(ContentModel.PROP_TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
return (String)nodeProperties.get(ContentModel.PROP_DESCRIPTION);
|
return (String)nodeProperties.get(ContentModel.PROP_DESCRIPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getModifiedOn()
|
public Date getModifiedOn()
|
||||||
{
|
{
|
||||||
return (Date)nodeProperties.get(ContentModel.PROP_MODIFIED);
|
return (Date)nodeProperties.get(ContentModel.PROP_MODIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModifiedByUser()
|
public String getModifiedByUser()
|
||||||
{
|
{
|
||||||
return (String)nodeProperties.get(ContentModel.PROP_MODIFIER);
|
return (String)nodeProperties.get(ContentModel.PROP_MODIFIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModifiedBy()
|
public String getModifiedBy()
|
||||||
{
|
{
|
||||||
return modifiedBy;
|
return modifiedBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreatedOn()
|
public Date getCreatedOn()
|
||||||
{
|
{
|
||||||
return (Date)nodeProperties.get(ContentModel.PROP_CREATED);
|
return (Date)nodeProperties.get(ContentModel.PROP_CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCreatedByUser()
|
public String getCreatedByUser()
|
||||||
{
|
{
|
||||||
return (String)nodeProperties.get(ContentModel.PROP_CREATOR);
|
return (String)nodeProperties.get(ContentModel.PROP_CREATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCreatedBy()
|
public String getCreatedBy()
|
||||||
{
|
{
|
||||||
return createdBy;
|
return createdBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthor()
|
public String getAuthor()
|
||||||
{
|
{
|
||||||
return (String)nodeProperties.get(ContentModel.PROP_AUTHOR);
|
return (String)nodeProperties.get(ContentModel.PROP_AUTHOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getParentFolder()
|
public String getParentFolder()
|
||||||
{
|
{
|
||||||
return parentFolder;
|
return parentFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize()
|
public int getSize()
|
||||||
{
|
{
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBrowseUrl()
|
public String getBrowseUrl()
|
||||||
{
|
{
|
||||||
return browseUrl;
|
return browseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Serializable> getProperties()
|
public Map<String, Serializable> getProperties()
|
||||||
{
|
{
|
||||||
return properties;
|
return properties;
|
||||||
|
@@ -37,15 +37,15 @@ import org.json.JSONObject;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class RecordsManagementSearchParameters
|
public class RecordsManagementSearchParameters
|
||||||
{
|
{
|
||||||
/** Default sort order */
|
/** Default sort order */
|
||||||
private static final Map<QName, Boolean> DEFAULT_SORT_ORDER = new HashMap<QName, Boolean>()
|
private static final List<SortItem> DEFAULT_SORT_ORDER = new ArrayList<SortItem>()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
put(ContentModel.PROP_NAME, Boolean.TRUE);
|
add(new SortItem(ContentModel.PROP_NAME, Boolean.TRUE));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Default templates */
|
/** Default templates */
|
||||||
private static final Map<String, String> DEFAULT_TEMPLATES = new HashMap<String, String>()
|
private static final Map<String, String> DEFAULT_TEMPLATES = new HashMap<String, String>()
|
||||||
{
|
{
|
||||||
@@ -72,24 +72,24 @@ public class RecordsManagementSearchParameters
|
|||||||
put("vitalRecordReviewPeriod", "%(rma:recordSearchVitalRecordReviewPeriod)");
|
put("vitalRecordReviewPeriod", "%(rma:recordSearchVitalRecordReviewPeriod)");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Default included container types */
|
/** Default included container types */
|
||||||
private static final List<QName> DEFAULT_INCLUDED_CONTAINER_TYPES = Collections.emptyList();
|
private static final List<QName> DEFAULT_INCLUDED_CONTAINER_TYPES = Collections.emptyList();
|
||||||
|
|
||||||
/** Max items */
|
/** Max items */
|
||||||
private int maxItems = 500;
|
private int maxItems = 500;
|
||||||
|
|
||||||
private boolean includeRecords = true;
|
private boolean includeRecords = true;
|
||||||
private boolean includeUndeclaredRecords = false;
|
private boolean includeUndeclaredRecords = false;
|
||||||
private boolean includeVitalRecords = false;
|
private boolean includeVitalRecords = false;
|
||||||
private boolean includeRecordFolders = true;
|
private boolean includeRecordFolders = true;
|
||||||
private boolean includeFrozen = false;
|
private boolean includeFrozen = false;
|
||||||
private boolean includeCutoff = false;
|
private boolean includeCutoff = false;
|
||||||
|
|
||||||
private List<QName> includedContainerTypes = DEFAULT_INCLUDED_CONTAINER_TYPES;
|
private List<QName> includedContainerTypes = DEFAULT_INCLUDED_CONTAINER_TYPES;
|
||||||
private Map<QName, Boolean> sortOrder = DEFAULT_SORT_ORDER;
|
private List<SortItem> sortOrder = DEFAULT_SORT_ORDER;
|
||||||
private Map<String, String> templates = DEFAULT_TEMPLATES;
|
private Map<String, String> templates = DEFAULT_TEMPLATES;
|
||||||
|
|
||||||
private static final String JSON_MAXITEMS = "maxitems";
|
private static final String JSON_MAXITEMS = "maxitems";
|
||||||
private static final String JSON_RECORDS = "records";
|
private static final String JSON_RECORDS = "records";
|
||||||
private static final String JSON_UNDECLAREDRECORDS = "undeclaredrecords";
|
private static final String JSON_UNDECLAREDRECORDS = "undeclaredrecords";
|
||||||
@@ -101,9 +101,9 @@ public class RecordsManagementSearchParameters
|
|||||||
private static final String JSON_SORT = "sort";
|
private static final String JSON_SORT = "sort";
|
||||||
private static final String JSON_FIELD = "field";
|
private static final String JSON_FIELD = "field";
|
||||||
private static final String JSON_ASCENDING = "ascending";
|
private static final String JSON_ASCENDING = "ascending";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {
|
* {
|
||||||
* "maxItems" : 500,
|
* "maxItems" : 500,
|
||||||
* "records" : true,
|
* "records" : true,
|
||||||
* "undeclaredrecords" : false,
|
* "undeclaredrecords" : false,
|
||||||
@@ -111,19 +111,19 @@ public class RecordsManagementSearchParameters
|
|||||||
* "recordfolders" : false,
|
* "recordfolders" : false,
|
||||||
* "frozen" : false,
|
* "frozen" : false,
|
||||||
* "cutoff" : false,
|
* "cutoff" : false,
|
||||||
* "containertypes" :
|
* "containertypes" :
|
||||||
* [
|
* [
|
||||||
* "rma:recordSeries",
|
* "rma:recordSeries",
|
||||||
* "rma:recordCategory"
|
* "rma:recordCategory"
|
||||||
* ]
|
* ]
|
||||||
* "sort" :
|
* "sort" :
|
||||||
* [
|
* [
|
||||||
* {
|
* {
|
||||||
* "field" : "cm:name",
|
* "field" : "cm:name",
|
||||||
* "ascending" : true
|
* "ascending" : true
|
||||||
* }
|
* }
|
||||||
* ]
|
* ]
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public static RecordsManagementSearchParameters createFromJSON(String json, NamespaceService namespaceService)
|
public static RecordsManagementSearchParameters createFromJSON(String json, NamespaceService namespaceService)
|
||||||
{
|
{
|
||||||
@@ -137,9 +137,9 @@ public class RecordsManagementSearchParameters
|
|||||||
throw new AlfrescoRuntimeException("Unable to create records management search parameters from json string. " + json, e);
|
throw new AlfrescoRuntimeException("Unable to create records management search parameters from json string. " + json, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param jsonObject
|
* @param jsonObject
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -148,7 +148,7 @@ public class RecordsManagementSearchParameters
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters();
|
RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters();
|
||||||
|
|
||||||
// Get the search parameter properties
|
// Get the search parameter properties
|
||||||
if (jsonObject.has(JSON_MAXITEMS) == true)
|
if (jsonObject.has(JSON_MAXITEMS) == true)
|
||||||
{
|
{
|
||||||
@@ -178,7 +178,7 @@ public class RecordsManagementSearchParameters
|
|||||||
{
|
{
|
||||||
searchParameters.setIncludeCutoff(jsonObject.getBoolean(JSON_CUTOFF));
|
searchParameters.setIncludeCutoff(jsonObject.getBoolean(JSON_CUTOFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get container types
|
// Get container types
|
||||||
if (jsonObject.has(JSON_CONTAINERTYPES) == true)
|
if (jsonObject.has(JSON_CONTAINERTYPES) == true)
|
||||||
{
|
{
|
||||||
@@ -191,43 +191,43 @@ public class RecordsManagementSearchParameters
|
|||||||
}
|
}
|
||||||
searchParameters.setIncludedContainerTypes(containerTypes);
|
searchParameters.setIncludedContainerTypes(containerTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get sort details
|
// Get sort details
|
||||||
if (jsonObject.has(JSON_SORT) == true)
|
if (jsonObject.has(JSON_SORT) == true)
|
||||||
{
|
{
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray(JSON_SORT);
|
JSONArray jsonArray = jsonObject.getJSONArray(JSON_SORT);
|
||||||
Map<QName, Boolean> sortOrder = new HashMap<QName, Boolean>(jsonArray.length());
|
List<SortItem> sortOrder = new ArrayList<SortItem>(jsonArray.length());
|
||||||
for (int i = 0; i < jsonArray.length(); i++)
|
for (int i = 0; i < jsonArray.length(); i++)
|
||||||
{
|
{
|
||||||
JSONObject sortJSONObject = jsonArray.getJSONObject(i);
|
JSONObject sortJSONObject = jsonArray.getJSONObject(i);
|
||||||
if (sortJSONObject.has(JSON_FIELD) == true &&
|
if (sortJSONObject.has(JSON_FIELD) == true &&
|
||||||
sortJSONObject.has(JSON_ASCENDING) == true)
|
sortJSONObject.has(JSON_ASCENDING) == true)
|
||||||
{
|
{
|
||||||
sortOrder.put(
|
sortOrder.add(new SortItem(
|
||||||
QName.createQName(sortJSONObject.getString(JSON_FIELD), namespaceService),
|
QName.createQName(sortJSONObject.getString(JSON_FIELD), namespaceService),
|
||||||
Boolean.valueOf(sortJSONObject.getBoolean(JSON_ASCENDING)));
|
sortJSONObject.getBoolean(JSON_ASCENDING)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
searchParameters.setSortOrder(sortOrder);
|
searchParameters.setSortOrder(sortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
return searchParameters;
|
return searchParameters;
|
||||||
}
|
}
|
||||||
catch (JSONException e)
|
catch (JSONException e)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Unable to create records management search parameters from json string. " + jsonObject.toString(), e);
|
throw new AlfrescoRuntimeException("Unable to create records management search parameters from json string. " + jsonObject.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String toJSONString(NamespaceService namespaceService)
|
public String toJSONString(NamespaceService namespaceService)
|
||||||
{
|
{
|
||||||
return toJSONObject(namespaceService).toString();
|
return toJSONObject(namespaceService).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject toJSONObject(NamespaceService namespaceService)
|
public JSONObject toJSONObject(NamespaceService namespaceService)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -240,7 +240,7 @@ public class RecordsManagementSearchParameters
|
|||||||
jsonObject.put(JSON_RECORDFOLDERES, includeRecordFolders);
|
jsonObject.put(JSON_RECORDFOLDERES, includeRecordFolders);
|
||||||
jsonObject.put(JSON_FROZEN, includeFrozen);
|
jsonObject.put(JSON_FROZEN, includeFrozen);
|
||||||
jsonObject.put(JSON_CUTOFF, includeCutoff);
|
jsonObject.put(JSON_CUTOFF, includeCutoff);
|
||||||
|
|
||||||
// Included containers
|
// Included containers
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
for (QName containerType : includedContainerTypes)
|
for (QName containerType : includedContainerTypes)
|
||||||
@@ -248,18 +248,18 @@ public class RecordsManagementSearchParameters
|
|||||||
jsonArray.put(containerType.toPrefixString(namespaceService));
|
jsonArray.put(containerType.toPrefixString(namespaceService));
|
||||||
}
|
}
|
||||||
jsonObject.put(JSON_CONTAINERTYPES, jsonArray);
|
jsonObject.put(JSON_CONTAINERTYPES, jsonArray);
|
||||||
|
|
||||||
// Sort
|
// Sort
|
||||||
JSONArray jsonSortArray = new JSONArray();
|
JSONArray jsonSortArray = new JSONArray();
|
||||||
for (Map.Entry<QName, Boolean> entry : sortOrder.entrySet())
|
for (SortItem entry : sortOrder)
|
||||||
{
|
{
|
||||||
JSONObject jsonEntry = new JSONObject();
|
JSONObject jsonEntry = new JSONObject();
|
||||||
jsonEntry.put(JSON_FIELD, entry.getKey().toPrefixString(namespaceService));
|
jsonEntry.put(JSON_FIELD, entry.property.toPrefixString(namespaceService));
|
||||||
jsonEntry.put(JSON_ASCENDING, entry.getValue().booleanValue());
|
jsonEntry.put(JSON_ASCENDING, entry.assc);
|
||||||
jsonSortArray.put(jsonEntry);
|
jsonSortArray.put(jsonEntry);
|
||||||
}
|
}
|
||||||
jsonObject.put(JSON_SORT, jsonSortArray);
|
jsonObject.put(JSON_SORT, jsonSortArray);
|
||||||
|
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
catch (JSONException e)
|
catch (JSONException e)
|
||||||
@@ -267,102 +267,102 @@ public class RecordsManagementSearchParameters
|
|||||||
throw new AlfrescoRuntimeException("Unable to generate json string for records management search parameters.", e);
|
throw new AlfrescoRuntimeException("Unable to generate json string for records management search parameters.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxItems(int maxItems)
|
public void setMaxItems(int maxItems)
|
||||||
{
|
{
|
||||||
this.maxItems = maxItems;
|
this.maxItems = maxItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxItems()
|
public int getMaxItems()
|
||||||
{
|
{
|
||||||
return maxItems;
|
return maxItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSortOrder(Map<QName, Boolean> sortOrder)
|
public void setSortOrder(List<SortItem> sortOrder)
|
||||||
{
|
{
|
||||||
this.sortOrder = sortOrder;
|
this.sortOrder = sortOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<QName, Boolean> getSortOrder()
|
public List<SortItem> getSortOrder()
|
||||||
{
|
{
|
||||||
return sortOrder;
|
return sortOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTemplates(Map<String, String> templates)
|
public void setTemplates(Map<String, String> templates)
|
||||||
{
|
{
|
||||||
this.templates = templates;
|
this.templates = templates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getTemplates()
|
public Map<String, String> getTemplates()
|
||||||
{
|
{
|
||||||
return templates;
|
return templates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIncludeRecords(boolean includeRecords)
|
public void setIncludeRecords(boolean includeRecords)
|
||||||
{
|
{
|
||||||
this.includeRecords = includeRecords;
|
this.includeRecords = includeRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncludeRecords()
|
public boolean isIncludeRecords()
|
||||||
{
|
{
|
||||||
return includeRecords;
|
return includeRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIncludeUndeclaredRecords(boolean includeUndeclaredRecords)
|
public void setIncludeUndeclaredRecords(boolean includeUndeclaredRecords)
|
||||||
{
|
{
|
||||||
this.includeUndeclaredRecords = includeUndeclaredRecords;
|
this.includeUndeclaredRecords = includeUndeclaredRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncludeUndeclaredRecords()
|
public boolean isIncludeUndeclaredRecords()
|
||||||
{
|
{
|
||||||
return includeUndeclaredRecords;
|
return includeUndeclaredRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIncludeVitalRecords(boolean includeVitalRecords)
|
public void setIncludeVitalRecords(boolean includeVitalRecords)
|
||||||
{
|
{
|
||||||
this.includeVitalRecords = includeVitalRecords;
|
this.includeVitalRecords = includeVitalRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncludeVitalRecords()
|
public boolean isIncludeVitalRecords()
|
||||||
{
|
{
|
||||||
return includeVitalRecords;
|
return includeVitalRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIncludeRecordFolders(boolean includeRecordFolders)
|
public void setIncludeRecordFolders(boolean includeRecordFolders)
|
||||||
{
|
{
|
||||||
this.includeRecordFolders = includeRecordFolders;
|
this.includeRecordFolders = includeRecordFolders;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncludeRecordFolders()
|
public boolean isIncludeRecordFolders()
|
||||||
{
|
{
|
||||||
return includeRecordFolders;
|
return includeRecordFolders;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIncludeFrozen(boolean includeFrozen)
|
public void setIncludeFrozen(boolean includeFrozen)
|
||||||
{
|
{
|
||||||
this.includeFrozen = includeFrozen;
|
this.includeFrozen = includeFrozen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncludeFrozen()
|
public boolean isIncludeFrozen()
|
||||||
{
|
{
|
||||||
return includeFrozen;
|
return includeFrozen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIncludeCutoff(boolean includeCutoff)
|
public void setIncludeCutoff(boolean includeCutoff)
|
||||||
{
|
{
|
||||||
this.includeCutoff = includeCutoff;
|
this.includeCutoff = includeCutoff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncludeCutoff()
|
public boolean isIncludeCutoff()
|
||||||
{
|
{
|
||||||
return includeCutoff;
|
return includeCutoff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIncludedContainerTypes(List<QName> includedContainerTypes)
|
public void setIncludedContainerTypes(List<QName> includedContainerTypes)
|
||||||
{
|
{
|
||||||
this.includedContainerTypes = includedContainerTypes;
|
this.includedContainerTypes = includedContainerTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<QName> getIncludedContainerTypes()
|
public List<QName> getIncludedContainerTypes()
|
||||||
{
|
{
|
||||||
return includedContainerTypes;
|
return includedContainerTypes;
|
||||||
|
@@ -182,9 +182,9 @@ public class RecordsManagementSearchServiceImpl implements RecordsManagementSear
|
|||||||
searchParameters.setNamespace(RecordsManagementModel.RM_URI);
|
searchParameters.setNamespace(RecordsManagementModel.RM_URI);
|
||||||
|
|
||||||
// set sort
|
// set sort
|
||||||
for(Entry<QName, Boolean> entry : rmSearchParameters.getSortOrder().entrySet())
|
for(SortItem entry : rmSearchParameters.getSortOrder())
|
||||||
{
|
{
|
||||||
searchParameters.addSort(entry.getKey().toPrefixString(namespaceService), entry.getValue().booleanValue());
|
searchParameters.addSort(entry.property.toPrefixString(namespaceService), entry.assc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set templates
|
// set templates
|
||||||
|
@@ -89,6 +89,8 @@ public class SavedSearchDetails extends ReportDetails
|
|||||||
public static final String SORT = "sort";
|
public static final String SORT = "sort";
|
||||||
public static final String PARAMS = "params";
|
public static final String PARAMS = "params";
|
||||||
|
|
||||||
|
private static final String DEFAULT_SITE_ID = "rm";
|
||||||
|
|
||||||
/** Site id */
|
/** Site id */
|
||||||
private String siteId;
|
private String siteId;
|
||||||
|
|
||||||
@@ -117,11 +119,11 @@ public class SavedSearchDetails extends ReportDetails
|
|||||||
JSONObject search = new JSONObject(jsonString);
|
JSONObject search = new JSONObject(jsonString);
|
||||||
|
|
||||||
// Get the site id
|
// Get the site id
|
||||||
if (search.has(SITE_ID) == false)
|
String siteId = DEFAULT_SITE_ID;
|
||||||
|
if (search.has(SITE_ID) == true)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Can not create saved search details from json, because required siteid is not present. " + jsonString);
|
siteId = search.getString(SITE_ID);
|
||||||
}
|
}
|
||||||
String siteId = search.getString(SITE_ID);
|
|
||||||
|
|
||||||
// Get the name
|
// Get the name
|
||||||
if (search.has(NAME) == false)
|
if (search.has(NAME) == false)
|
||||||
|
@@ -21,9 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.search;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
@@ -128,10 +126,6 @@ public class SavedSearchDetailsCompatibility implements RecordsManagementModel
|
|||||||
{
|
{
|
||||||
includedContainerTypes.add(TYPE_RECORD_CATEGORY);
|
includedContainerTypes.add(TYPE_RECORD_CATEGORY);
|
||||||
}
|
}
|
||||||
// else if ("series".equals(paramName) == true && Boolean.parseBoolean(paramValue) == true)
|
|
||||||
// {
|
|
||||||
// includedContainerTypes.add(DOD5015Model.TYPE_RECORD_SERIES);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
result.setIncludedContainerTypes(includedContainerTypes);
|
result.setIncludedContainerTypes(includedContainerTypes);
|
||||||
|
|
||||||
@@ -139,7 +133,7 @@ public class SavedSearchDetailsCompatibility implements RecordsManagementModel
|
|||||||
{
|
{
|
||||||
// Map the sort string into the search details
|
// Map the sort string into the search details
|
||||||
String[] sortPairs = sort.split(",");
|
String[] sortPairs = sort.split(",");
|
||||||
Map<QName, Boolean> sortOrder = new HashMap<QName, Boolean>(sortPairs.length);
|
List<SortItem> sortOrder = new ArrayList<SortItem>(sortPairs.length);
|
||||||
for (String sortPairString : sortPairs)
|
for (String sortPairString : sortPairs)
|
||||||
{
|
{
|
||||||
String[] sortPair = sortPairString.split("/");
|
String[] sortPair = sortPairString.split("/");
|
||||||
@@ -149,7 +143,7 @@ public class SavedSearchDetailsCompatibility implements RecordsManagementModel
|
|||||||
{
|
{
|
||||||
isAcsending = Boolean.TRUE;
|
isAcsending = Boolean.TRUE;
|
||||||
}
|
}
|
||||||
sortOrder.put(field, isAcsending);
|
sortOrder.add(new SortItem(field, isAcsending));
|
||||||
}
|
}
|
||||||
result.setSortOrder(sortOrder);
|
result.setSortOrder(sortOrder);
|
||||||
}
|
}
|
||||||
@@ -178,7 +172,7 @@ public class SavedSearchDetailsCompatibility implements RecordsManagementModel
|
|||||||
{
|
{
|
||||||
StringBuilder builder = new StringBuilder(64);
|
StringBuilder builder = new StringBuilder(64);
|
||||||
|
|
||||||
for (Map.Entry<QName, Boolean> entry : this.savedSearchDetails.getSearchParameters().getSortOrder().entrySet())
|
for (SortItem entry : this.savedSearchDetails.getSearchParameters().getSortOrder())
|
||||||
{
|
{
|
||||||
if (builder.length() !=0)
|
if (builder.length() !=0)
|
||||||
{
|
{
|
||||||
@@ -186,11 +180,11 @@ public class SavedSearchDetailsCompatibility implements RecordsManagementModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
String order = "desc";
|
String order = "desc";
|
||||||
if (Boolean.TRUE.equals(entry.getValue()) == true)
|
if (entry.assc == true)
|
||||||
{
|
{
|
||||||
order = "asc";
|
order = "asc";
|
||||||
}
|
}
|
||||||
builder.append(entry.getKey().toPrefixString(this.namespaceService))
|
builder.append(entry.property.toPrefixString(this.namespaceService))
|
||||||
.append("/")
|
.append("/")
|
||||||
.append(order);
|
.append(order);
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,15 @@
|
|||||||
|
package org.alfresco.module.org_alfresco_module_rm.search;
|
||||||
|
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
|
/*package*/ class SortItem
|
||||||
|
{
|
||||||
|
public QName property = null;
|
||||||
|
public boolean assc = true;
|
||||||
|
public SortItem(QName property, boolean assc)
|
||||||
|
{
|
||||||
|
this.property = property;
|
||||||
|
this.assc = assc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user