Fixed major issues reported by sonar (If Stmts Must Use Braces)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63501 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2014-03-02 22:23:03 +00:00
parent 505e29499a
commit 8c994439be
21 changed files with 355 additions and 271 deletions

View File

@@ -285,8 +285,10 @@ public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionEx
nodeService.removeChild(nextAction.getNodeRef(), event.getNodeRef());
if (logger.isDebugEnabled())
{
logger.debug("Removed '" + eventName + "' from next action '" + nextAction.getName() +
"' (" + nextAction.getNodeRef() + ")");
}
}
}

View File

@@ -49,34 +49,36 @@ public class OpenRecordFolderAction extends RMActionExecuterAbstractBase
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
if (nodeService.exists(actionedUponNodeRef) == true &&
freezeService.isFrozen(actionedUponNodeRef) == false)
{
// TODO move re-open logic into a service method
// TODO check that the user in question has the correct permission to re-open a records folder
if (nodeService.exists(actionedUponNodeRef) == true &&
freezeService.isFrozen(actionedUponNodeRef) == false)
{
// TODO move re-open logic into a service method
// TODO check that the user in question has the correct permission to re-open a records folder
if (recordService.isRecord(actionedUponNodeRef))
{
ChildAssociationRef assocRef = nodeService.getPrimaryParent(actionedUponNodeRef);
if (assocRef != null)
{
actionedUponNodeRef = assocRef.getParentRef();
}
}
if (recordService.isRecord(actionedUponNodeRef))
{
ChildAssociationRef assocRef = nodeService.getPrimaryParent(actionedUponNodeRef);
if (assocRef != null)
{
actionedUponNodeRef = assocRef.getParentRef();
}
}
if (recordFolderService.isRecordFolder(actionedUponNodeRef) == true)
{
Boolean isClosed = (Boolean) nodeService.getProperty(actionedUponNodeRef, PROP_IS_CLOSED);
if (Boolean.TRUE.equals(isClosed) == true)
{
nodeService.setProperty(actionedUponNodeRef, PROP_IS_CLOSED, false);
}
}
else
{
if (logger.isWarnEnabled())
logger.warn(I18NUtil.getMessage(MSG_NO_OPEN_RECORD_FOLDER, actionedUponNodeRef.toString()));
}
}
if (recordFolderService.isRecordFolder(actionedUponNodeRef) == true)
{
Boolean isClosed = (Boolean) nodeService.getProperty(actionedUponNodeRef, PROP_IS_CLOSED);
if (Boolean.TRUE.equals(isClosed) == true)
{
nodeService.setProperty(actionedUponNodeRef, PROP_IS_CLOSED, false);
}
}
else
{
if (logger.isWarnEnabled())
{
logger.warn(I18NUtil.getMessage(MSG_NO_OPEN_RECORD_FOLDER, actionedUponNodeRef.toString()));
}
}
}
}
}

View File

@@ -224,10 +224,10 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
beforeRemoveReferenceDelegate = policyComponent.registerClassPolicy(BeforeRemoveReference.class);
onRemoveReferenceDelegate = policyComponent.registerClassPolicy(OnRemoveReference.class);
}
/**
* Invoke before create reference policy
*
*
* @param fromNodeRef
* @param toNodeRef
* @param reference
@@ -243,7 +243,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
/**
* Invoke on create reference policy
*
*
* @param fromNodeRef
* @param toNodeRef
* @param reference
@@ -259,7 +259,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
/**
* Invoke before remove reference policy
*
*
* @param fromNodeRef
* @param toNodeRef
* @param reference
@@ -368,7 +368,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
public Void doWork() throws Exception
{
if (dictionaryService.getAllModels().contains(RecordsManagementCustomModel.RM_CUSTOM_MODEL) == true)
{
{
NodeRef nodeRef = childAssocRef.getChildRef();
QName type = nodeService.getType(nodeRef);
while (type != null && ContentModel.TYPE_CMOBJECT.equals(type) == false)
@@ -378,7 +378,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
QName customPropertyAspect = getCustomAspect(type);
nodeService.addAspect(nodeRef, customPropertyAspect, null);
}
TypeDefinition def = dictionaryService.getType(type);
if (def != null)
{
@@ -844,7 +844,10 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName));
}
if (newName == null) return propQName;
if (newName == null)
{
return propQName;
}
QName newPropQName = getQNameForClientId(newName);
if (newPropQName != null)
@@ -888,7 +891,10 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName));
}
if (newLabel == null) return propQName;
if (newLabel == null)
{
return propQName;
}
NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI());
M2Model deserializedModel = readCustomContentModel(modelRef);
@@ -1179,7 +1185,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
nodeService.removeChildAssociation(chRef);
}
}
return null;
}
});
@@ -1619,7 +1625,10 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
{
try
{
if (contentIn != null) contentIn.close();
if (contentIn != null)
{
contentIn.close();
}
}
catch (IOException ignored)
{

View File

@@ -277,19 +277,29 @@ public abstract class AbstractCapability extends RMSecurityCommon
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final AbstractCapability other = (AbstractCapability) obj;
if (getName() == null)
{
if (other.getName() != null)
{
return false;
}
}
else if (!getName().equals(other.getName()))
{
return false;
}
return true;
}

View File

@@ -19,51 +19,51 @@
package org.alfresco.module.org_alfresco_module_rm.email;
/**
* Custom EMail Mapping
* Custom EMail Mapping
*/
public class CustomMapping
{
private String from;
private String to;
/**
* Default constructor.
*/
public CustomMapping()
{
public CustomMapping()
{
}
/**
* Default constructor.
* @param from
* @param to
*/
public CustomMapping(String from, String to)
public CustomMapping(String from, String to)
{
this.from = from;
this.to = to;
}
public void setFrom(String from)
{
this.from = from;
}
public String getFrom()
{
return from;
}
public void setTo(String to)
{
this.to = to;
}
public String getTo()
{
return to;
}
public int hashCode()
{
if(from != null && to != null)
@@ -75,7 +75,7 @@ public class CustomMapping
return 1;
}
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
@@ -84,14 +84,20 @@ public class CustomMapping
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final CustomMapping other = (CustomMapping) obj;
if (!from.equals(other.getFrom()))
{
return false;

View File

@@ -135,7 +135,7 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent
}
return false;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#canCreateEvent(java.lang.String, java.lang.String)
*/
@@ -227,7 +227,7 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent
" has an undefined eventType. ("
+ eventType + ")");
}
// Create event and add to map
RecordsManagementEvent event = new RecordsManagementEvent(eventType, eventName, eventDisplayLabel);
getEventMap().put(event.getName(), event);
@@ -301,9 +301,12 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent
String eventDisplayLabel = eventJSON.getString("eventDisplayLabel");
String translated = I18NUtil.getMessage(eventDisplayLabel);
if (translated!=null ) eventDisplayLabel = translated;
if (translated != null)
{
eventDisplayLabel = translated;
}
// Check that the eventType is valid
if (eventTypes.containsKey(eventType) == false)
{

View File

@@ -190,14 +190,14 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter
{
String aspectName = aspect.getPrefixedQName(namespaceService).toPrefixString().replace(":", "-");
String setId = RM_METADATA_PREFIX + aspectName;
String setLabel = null;
AspectDefinition aspectDefinition = dictionaryService.getAspect(aspect);
if (aspectDefinition != null)
{
setLabel = aspectDefinition.getTitle(new StaticMessageLookup());
}
addPropertyFieldsToGroup(form, dictionaryService.getPropertyDefs(aspect), setId, setLabel);
}
}
@@ -385,6 +385,8 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter
}
if (logger.isDebugEnabled())
{
logger.debug("Set 'rma:recordLevelDisposition' field to be protected as record folders or records are present");
}
}
}

View File

@@ -319,7 +319,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* Helper method to apply the search aspect
*
*
* @param nodeRef node reference
*/
private void applySearchAspect(NodeRef nodeRef)
@@ -332,7 +332,9 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
nodeService.addAspect(nodeRef, ASPECT_RM_SEARCH , null);
if (logger.isDebugEnabled())
{
logger.debug("Added search aspect to node: " + nodeRef);
}
}
}
finally
@@ -343,7 +345,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* On add record aspect behaviour implementation
*
*
* @param nodeRef node reference
* @param aspectTypeQName aspect type qname
*/
@@ -367,7 +369,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* On create record folder behaviour implmentation
*
*
* @param childAssocRef child association reference
*/
public void recordFolderCreate(final ChildAssociationRef childAssocRef)
@@ -391,7 +393,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* Helper method to setup the disposition schedule properties
*
*
* @param recordOrFolder node reference of record or record folder
*/
private void setupDispositionScheduleProperties(NodeRef recordOrFolder)
@@ -416,7 +418,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* On disposition action create behaviour implementation
*
*
* @param childAssocRef child association reference
*/
public void dispositionActionCreate(ChildAssociationRef childAssocRef)
@@ -490,7 +492,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* On update of event execution information behaviour\
*
*
* @param childAssocRef child association reference
* @param isNewNode true if a new node, false otherwise
*/
@@ -525,7 +527,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* On event execution delete behaviour implementation.
*
*
* @param childAssocRef child association reference
* @param isNodeArchived true if node is archived on delete, false otherwise
*/
@@ -552,7 +554,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* Helper method to setup disposition action events.
*
*
* @param nodeRef node reference
* @param da disposition action
*/
@@ -583,7 +585,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* On add search aspect behaviour implementation.
*
*
* @param nodeRef node reference
* @param aspectTypeQName aspect type qname
*/
@@ -607,7 +609,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* On add aspect vital record defintion behaviour implementation.
*
*
* @param nodeRef node reference
* @param aspectTypeQName aspect tyep qname
*/
@@ -623,7 +625,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
{
updateVitalRecordDefinitionValues(nodeRef);
}
return null;
}
});
@@ -631,7 +633,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* On update vital record definition properties behaviour implementation.
*
*
* @param nodeRef node reference
* @param before before properties
* @param after after properties
@@ -655,7 +657,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
updateVitalRecordDefinitionValues(nodeRef);
}
}
return null;
}
});
@@ -663,7 +665,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* Helper method to update the vital record defintion values
*
*
* @param nodeRef node reference
*/
private void updateVitalRecordDefinitionValues(NodeRef nodeRef)
@@ -685,7 +687,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* Helper method to set vital record definition details.
*
*
* @param nodeRef node reference
*/
private void setVitalRecordDefintionDetails(NodeRef nodeRef)
@@ -716,7 +718,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* On remove frozen aspect aspect behaviour implementation
*
*
* @param nodeRef node reference
* @param aspectTypeQName aspect type qname
*/
@@ -731,7 +733,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* Frozen aspect properties update behavour implementation.
*
*
* @param nodeRef node reference
* @param before before properties
* @param after after proeprties
@@ -806,7 +808,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
/**
* Helper method to set disposition schedule properties
*
*
* @param recordOrFolder node reference
* @param schedule dispostion schedule
*/
@@ -855,10 +857,10 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
return result;
}
/**
* Helper method to get the record folders contained in the provided record category.
*
*
* @param recordCategoryNode record category node reference
* @return List<NodeRef> contained record folders
*/

View File

@@ -46,7 +46,7 @@ import org.alfresco.util.PropertyMap;
/**
* rma:filePlanComponent behaviour bean
*
*
* @author Roy Wetherall
* @since 2.2
*/
@@ -58,21 +58,21 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
implements NodeServicePolicies.OnUpdatePropertiesPolicy,
NodeServicePolicies.OnAddAspectPolicy,
NodeServicePolicies.OnMoveNodePolicy
{
/** Well-known location of the scripts folder. */
private NodeRef scriptsFolderNodeRef = new NodeRef("workspace", "SpacesStore", "rm_behavior_scripts");
/** script service */
private ScriptService scriptService;
/** namespace service */
private NamespaceService namespaceService;
/** file plan service */
private FilePlanService filePlanService;
/**
* @param scriptService set script service
*/
@@ -80,15 +80,15 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
{
this.scriptService = scriptService;
}
/**
* @param namespaceService namespace service
*/
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
}
/**
* @param filePlanService file plan service
*/
@@ -96,7 +96,7 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
{
this.filePlanService = filePlanService;
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map)
*/
@@ -122,7 +122,7 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
}
}, AuthenticationUtil.getAdminUserName());
}
/**
* This method examines the old and new property sets and for those properties which
* have changed, looks for script resources corresponding to those properties.
@@ -135,7 +135,7 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
* @see #lookupScripts(Map<QName, Serializable>, Map<QName, Serializable>)
*/
private void lookupAndExecuteScripts(NodeRef nodeWithChangedProperties,
Map<QName, Serializable> oldProps,
Map<QName, Serializable> oldProps,
Map<QName, Serializable> newProps)
{
List<NodeRef> scriptRefs = lookupScripts(oldProps, newProps);
@@ -150,7 +150,7 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
scriptService.executeScript(scriptRef, null, objectModel);
}
}
/**
* This method determines which properties have changed and for each such property
* looks for a script resource in a well-known location.
@@ -179,12 +179,15 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
String expectedScriptName = shortPrefix + "_" + localName + ".js";
NodeRef nextElement = nodeService.getChildByName(scriptsFolderNodeRef, ContentModel.ASSOC_CONTAINS, expectedScriptName);
if (nextElement != null) result.add(nextElement);
if (nextElement != null)
{
result.add(nextElement);
}
}
return result;
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
*/
@@ -202,7 +205,7 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
public Void doWork() throws Exception
{
if (nodeService.exists(nodeRef) == true)
{
{
// Look up the root and set on the aspect if found
NodeRef root = filePlanService.getFilePlan(nodeRef);
if (root != null)
@@ -210,10 +213,10 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
nodeService.setProperty(nodeRef, PROP_ROOT_NODEREF, root);
}
}
return null;
}
}, AuthenticationUtil.getSystemUserName());
}, AuthenticationUtil.getSystemUserName());
}
/**
@@ -232,7 +235,7 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
@Override
public Void doWork() throws Exception
{
if (nodeService.exists(newChildAssocRef.getParentRef()) == true &&
if (nodeService.exists(newChildAssocRef.getParentRef()) == true &&
nodeService.exists(newChildAssocRef.getChildRef()) == true)
{
// Look up the root and re-set the value currently stored on the aspect
@@ -240,15 +243,15 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
// NOTE: set the null value if no root found
nodeService.setProperty(newChildAssocRef.getChildRef(), PROP_ROOT_NODEREF, root);
}
return null;
}
}, AuthenticationUtil.getSystemUserName());
}, AuthenticationUtil.getSystemUserName());
}
/**
* Copy behaviour call back
*
*
* @param classRef class reference
* @param copyDetail details of the information being copied
* @return CopyBehaviourCallback
@@ -273,7 +276,7 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
// Do not copy the associations
return null;
}
/**
* @see org.alfresco.repo.copy.CopyBehaviourCallback#getCopyProperties(org.alfresco.service.namespace.QName, org.alfresco.repo.copy.CopyDetails, java.util.Map)
*/
@@ -298,8 +301,8 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
{
// Ensure the aspect is copied
return true;
}
}
};
}
}
}

View File

@@ -307,7 +307,9 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl
else
{
if (logger.isWarnEnabled())
{
logger.warn(I18NUtil.getMessage(MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER, nodeRef.toString()));
}
}
}
}

View File

@@ -77,10 +77,10 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
private static final String MSG_FIRST_NAME = "bootstrap.rmadmin.firstName";
private static final String MSG_LAST_NAME = "bootstrap.rmadmin.lastName";
private static final String MSG_ALL_ROLES = "rm.role.all";
/** Location of bootstrap role JSON */
private static final String BOOTSTRAP_ROLE_JSON_LOCATION = "alfresco/module/org_alfresco_module_rm/security/rm-default-roles-bootstrap.json";
/** Capability service */
private CapabilityService capabilityService;
@@ -98,18 +98,18 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
/** File plan authentication service */
private FilePlanAuthenticationService filePlanAuthenticationService;
/** mutable authenticaiton service */
private MutableAuthenticationService authenticationService;
/** person service */
private PersonService personService;
private BootstrapImporterModuleComponent bootstrapImporterModule;
/** Records management role zone */
public static final String RM_ROLE_ZONE_PREFIX = "rmRoleZone";
/**
* Records Management Config Node
*/
@@ -165,15 +165,15 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
{
this.filePlanAuthenticationService = filePlanAuthenticationService;
}
/**
/**
* @param personService person service
*/
public void setPersonService(PersonService personService)
{
this.personService = personService;
}
/**
* @param authenticationService mutable authentication service
*/
@@ -181,9 +181,9 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
{
this.authenticationService = authenticationService;
}
/**
*
*
* @param bootstrapImporterModuleComponent
*/
public void setBootstrapImporterModuleComponent(BootstrapImporterModuleComponent bootstrapImporterModuleComponent)
@@ -203,7 +203,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
// This is not the spaces store - probably the archive store
return;
}
if (nodeService.exists(filePlan) == true)
{
List<NodeRef> systemContainers = AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork<List<NodeRef>>()
@@ -211,19 +211,19 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
public List<NodeRef> doWork()
{
List<NodeRef> systemContainers = new ArrayList<NodeRef>(3);
//In a multi tenant store we need to initialize the rm config if it has been done yet
NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CONFIG_NODEID);
NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CONFIG_NODEID);
if (nodeService.exists(nodeRef) == false)
{
bootstrapImporterModule.execute();
}
// Create "all" role group for root node
String allRoles = authorityService.createAuthority(
AuthorityType.GROUP,
getAllRolesGroupShortName(filePlan),
I18NUtil.getMessage(MSG_ALL_ROLES),
AuthorityType.GROUP,
getAllRolesGroupShortName(filePlan),
I18NUtil.getMessage(MSG_ALL_ROLES),
new HashSet<String>(Arrays.asList(RMAuthority.ZONE_APP_RM)));
// Set the permissions
@@ -235,10 +235,10 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
// Create the transfer and hold containers
systemContainers.add(filePlanService.createHoldContainer(filePlan));
systemContainers.add(filePlanService.createTransferContainer(filePlan));
// Create the unfiled record container
systemContainers.add(filePlanService.createUnfiledContainer(filePlan));
return systemContainers;
}
});
@@ -389,7 +389,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
{
// Create the RM Admin User if it does not already exist
createRMAdminUser();
// add the dynamic admin authority
authorityService.addAuthority(role.getRoleGroupName(), filePlanAuthenticationService.getRmAdminUserName());
}
@@ -491,7 +491,10 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
String name = getShortRoleName(groupShortName, rmRootNode);
String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority);
String translated = I18NUtil.getMessage(displayLabel);
if (translated!=null ) displayLabel = translated;
if (translated != null)
{
displayLabel = translated;
}
Set<Capability> capabilities = getCapabilitiesImpl(rmRootNode, roleAuthority);
Role role = new Role(name, displayLabel, capabilities, roleAuthority, groupShortName);
@@ -534,7 +537,10 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
String name = getShortRoleName(groupShortName, rmRootNode);
String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority);
String translated = I18NUtil.getMessage(displayLabel);
if (translated!=null ) displayLabel = translated;
if (translated != null)
{
displayLabel = translated;
}
Set<Capability> capabilities = getCapabilitiesImpl(rmRootNode, roleAuthority);
Role role = new Role(name, displayLabel, capabilities, roleAuthority, groupShortName);
@@ -697,14 +703,14 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
Set<String> zones = new HashSet<String>(2);
zones.add(getZoneName(rmRootNode));
zones.add(RMAuthority.ZONE_APP_RM);
// Look up string, default to passed value if none found
String groupDisplayLabel = I18NUtil.getMessage(roleDisplayLabel);
if (groupDisplayLabel == null)
{
groupDisplayLabel = roleDisplayLabel;
}
String roleGroup = authorityService.createAuthority(AuthorityType.GROUP, fullRoleName, groupDisplayLabel, zones);
// Add the roleGroup to the "all" role group
@@ -899,7 +905,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
{
return authorityService.getName(AuthorityType.GROUP, getAllRolesGroupShortName(filePlan));
}
/**
* Create the RMAdmin user if it does not already exist
*/
@@ -907,18 +913,18 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
{
/** generate rm admin password */
String password = GUID.generate();
String user = filePlanAuthenticationService.getRmAdminUserName();
String firstName = I18NUtil.getMessage(MSG_FIRST_NAME);
String lastName = I18NUtil.getMessage(MSG_LAST_NAME);
if (authenticationService.authenticationExists(user) == false)
{
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... creating RM Admin user");
}
authenticationService.createAuthentication(user, password.toCharArray());
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(ContentModel.PROP_USERNAME, user);

View File

@@ -55,10 +55,10 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
* they are safe to apply to a live database i.e. without side-effect to existing data and safe
* to call multiple times.
* <P>
*
*
* TODO This webscript should be removed after DOD certification as none of these patches are needed
* for a newly-installed DoD amp.
*
*
* @author neilm
*/
@Deprecated
@@ -70,7 +70,7 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
private static final String RMC_CUSTOM_RECORD_CATEGORY_PROPERTIES = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customRecordCategoryProperties";
private static final String RMC_CUSTOM_RECORD_FOLDER_PROPERTIES = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customRecordFolderProperties";
private static final String RMC_CUSTOM_RECORD_PROPERTIES = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customRecordProperties";
/** Logger */
private static Log logger = LogFactory.getLog(ApplyDodCertModelFixesGet.class);
@@ -88,11 +88,11 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
{
logger.info("Applying webscript-based patches to RM custom model in the repo.");
}
M2Model customModel = readCustomContentModel();
M2Aspect customAssocsAspect = customModel.getAspect(RecordsManagementAdminServiceImpl.RMC_CUSTOM_ASSOCS);
if (customAssocsAspect == null)
{
final String msg = "Unknown aspect: " + RecordsManagementAdminServiceImpl.RMC_CUSTOM_ASSOCS;
@@ -102,8 +102,8 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
}
throw new AlfrescoRuntimeException(msg);
}
// MOB-1573. All custom references should have many-many multiplicity.
if (logger.isInfoEnabled())
{
@@ -114,17 +114,17 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
{
classAssoc.setSourceMany(true);
classAssoc.setTargetMany(true);
}
//MOB-1621. Custom fields should be created as untokenized by default.
if (logger.isInfoEnabled())
{
logger.info("MOB-1621. Custom fields should be created as untokenized by default.");
}
List<String> allCustomPropertiesAspects = new ArrayList<String>(4);
allCustomPropertiesAspects.add(RMC_CUSTOM_RECORD_SERIES_PROPERTIES);
allCustomPropertiesAspects.add(RMC_CUSTOM_RECORD_CATEGORY_PROPERTIES);
@@ -143,9 +143,9 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
}
}
writeCustomContentModel(customModel);
if (logger.isInfoEnabled())
{
logger.info("Completed application of webscript-based patches to RM custom model in the repo.");
@@ -153,17 +153,17 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
model.put("success", true);
return model;
}
private M2Model readCustomContentModel()
{
ContentReader reader = this.contentService.getReader(RM_CUSTOM_MODEL_NODE_REF,
ContentModel.TYPE_CONTENT);
if (reader.exists() == false) {throw new AlfrescoRuntimeException("RM CustomModel has no content.");}
InputStream contentIn = null;
M2Model deserializedModel = null;
try
@@ -175,7 +175,10 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
{
try
{
if (contentIn != null) contentIn.close();
if (contentIn != null)
{
contentIn.close();
}
}
catch (IOException ignored)
{
@@ -191,10 +194,10 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
ContentModel.TYPE_CONTENT, true);
writer.setMimetype(MimetypeMap.MIMETYPE_XML);
writer.setEncoding("UTF-8");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
deserializedModel.toXML(baos);
String updatedModelXml;
try
{

View File

@@ -46,9 +46,9 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
* This webscript patches the RM custom model as fix for MOB-1573. It is only necessary for databases
* that had their RM amps initialised before the fix went in.
* There is no side-effect if it is called when it is not needed or if it is called multiple times.
*
*
* TODO This webscript should be removed after DOD certification.
*
*
* @author neilm
*/
@Deprecated
@@ -56,7 +56,7 @@ public class ApplyFixMob1573Get extends DeclarativeWebScript
implements RecordsManagementModel
{
private static final NodeRef RM_CUSTOM_MODEL_NODE_REF = new NodeRef("workspace://SpacesStore/records_management_custom_model");
private ContentService contentService;
public void setContentService(ContentService contentService)
@@ -68,17 +68,17 @@ public class ApplyFixMob1573Get extends DeclarativeWebScript
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
M2Model customModel = readCustomContentModel();
// Go through every custom reference defined in the custom model and make sure that it
// has many-to-many multiplicity
String aspectName = RecordsManagementAdminServiceImpl.RMC_CUSTOM_ASSOCS;
M2Aspect customAssocsAspect = customModel.getAspect(aspectName);
if (customAssocsAspect == null)
{
throw new AlfrescoRuntimeException("Unknown aspect: "+aspectName);
}
for (M2ClassAssociation classAssoc : customAssocsAspect.getAssociations())
{
classAssoc.setSourceMany(true);
@@ -86,20 +86,20 @@ public class ApplyFixMob1573Get extends DeclarativeWebScript
}
writeCustomContentModel(customModel);
Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
model.put("success", true);
return model;
}
private M2Model readCustomContentModel()
{
ContentReader reader = this.contentService.getReader(RM_CUSTOM_MODEL_NODE_REF,
ContentModel.TYPE_CONTENT);
if (reader.exists() == false) {throw new AlfrescoRuntimeException("RM CustomModel has no content.");}
InputStream contentIn = null;
M2Model deserializedModel = null;
try
@@ -111,7 +111,10 @@ public class ApplyFixMob1573Get extends DeclarativeWebScript
{
try
{
if (contentIn != null) contentIn.close();
if (contentIn != null)
{
contentIn.close();
}
}
catch (IOException ignored)
{
@@ -127,10 +130,10 @@ public class ApplyFixMob1573Get extends DeclarativeWebScript
ContentModel.TYPE_CONTENT, true);
writer.setMimetype(MimetypeMap.MIMETYPE_XML);
writer.setEncoding("UTF-8");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
deserializedModel.toXML(baos);
String updatedModelXml;
try
{

View File

@@ -62,7 +62,9 @@ public class AuditLogGet extends BaseAuditRetrievalWebScript
auditTrail = this.rmAuditService.getAuditTrailFile(parseQueryParameters(req), parseReportFormat(req));
if (logger.isDebugEnabled())
{
logger.debug("Streaming audit trail from file: " + auditTrail.getAbsolutePath());
}
boolean attach = false;
String attachFileName = null;
@@ -73,7 +75,9 @@ public class AuditLogGet extends BaseAuditRetrievalWebScript
attachFileName = auditTrail.getName();
if (logger.isDebugEnabled())
{
logger.debug("Exporting audit trail using file name: " + attachFileName);
}
}
// stream the file back to the client

View File

@@ -40,19 +40,19 @@ import org.json.JSONTokener;
/**
* Implementation for Java backed webscript to file an
* audit log as a record.
*
*
* @author Gavin Cornwell
*/
public class AuditLogPost extends BaseAuditRetrievalWebScript
{
/** Logger */
private static Log logger = LogFactory.getLog(AuditLogPost.class);
protected static final String PARAM_DESTINATION = "destination";
protected static final String RESPONSE_SUCCESS = "success";
protected static final String RESPONSE_RECORD = "record";
protected static final String RESPONSE_RECORD_NAME = "recordName";
@Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{
@@ -60,74 +60,78 @@ public class AuditLogPost extends BaseAuditRetrievalWebScript
{
// retrieve requested format
String format = req.getFormat();
// construct model for template
Status status = new Status();
Cache cache = new Cache(getDescription().getRequiredCache());
Map<String, Object> model = new HashMap<String, Object>();
model.put("status", status);
model.put("cache", cache);
// extract the destination parameter, ensure it's present and it is
// a record folder
JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent()));
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");
Map<String, Object> templateModel = createTemplateParameters(req, res, model);
sendStatus(req, res, status, cache, format, templateModel);
return;
}
String destinationParam = json.getString(PARAM_DESTINATION);
NodeRef destination = new NodeRef(destinationParam);
if (!this.nodeService.exists(destination))
{
status.setCode(HttpServletResponse.SC_NOT_FOUND,
status.setCode(HttpServletResponse.SC_NOT_FOUND,
"Node " + destination.toString() + " does not exist");
Map<String, Object> templateModel = createTemplateParameters(req, res, model);
sendStatus(req, res, status, cache, format, templateModel);
return;
}
// ensure the node is a filePlan object
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");
Map<String, Object> templateModel = createTemplateParameters(req, res, model);
sendStatus(req, res, status, cache, format, templateModel);
return;
}
if (logger.isDebugEnabled())
{
logger.debug("Filing audit trail as record in record folder: " + destination);
}
// parse the other parameters and get a file containing the audit trail
NodeRef record = this.rmAuditService.fileAuditTrailAsRecord(parseQueryParameters(req),
NodeRef record = this.rmAuditService.fileAuditTrailAsRecord(parseQueryParameters(req),
destination, parseReportFormat(req));
if (logger.isDebugEnabled())
{
logger.debug("Filed audit trail as new record: " + record);
}
// return success flag and record noderef as JSON
JSONObject responseJSON = new JSONObject();
responseJSON.put(RESPONSE_SUCCESS, (record != null));
if (record != null)
{
responseJSON.put(RESPONSE_RECORD, record.toString());
responseJSON.put(RESPONSE_RECORD_NAME,
responseJSON.put(RESPONSE_RECORD_NAME,
(String)nodeService.getProperty(record, ContentModel.PROP_NAME));
}
// setup response
String jsonString = responseJSON.toString();
res.setContentType(MimetypeMap.MIMETYPE_JSON);
res.setContentEncoding("UTF-8");
res.setHeader("Content-Length", Long.toString(jsonString.length()));
// write the JSON response
res.getWriter().write(jsonString);
}

View File

@@ -152,13 +152,17 @@ public class BaseAuditRetrievalWebScript extends StreamContent
{
// log a warning
if (logger.isWarnEnabled())
{
logger.warn("Failed to parse JSON parameters for audit query: " + ioe.getMessage());
}
}
catch (JSONException je)
{
// log a warning
if (logger.isWarnEnabled())
{
logger.warn("Failed to parse JSON parameters for audit query: " + je.getMessage());
}
}
}
else
@@ -185,7 +189,9 @@ public class BaseAuditRetrievalWebScript extends StreamContent
catch (NumberFormatException nfe)
{
if (logger.isWarnEnabled())
{
logger.warn("Ignoring size parameter as '" + size + "' is not a number!");
}
}
}
@@ -199,7 +205,9 @@ public class BaseAuditRetrievalWebScript extends StreamContent
catch (ParseException pe)
{
if (logger.isWarnEnabled())
{
logger.warn("Ignoring from parameter as '" + from + "' does not conform to the date pattern: " + DATE_PATTERN);
}
}
}
@@ -213,7 +221,9 @@ public class BaseAuditRetrievalWebScript extends StreamContent
catch (ParseException pe)
{
if (logger.isWarnEnabled())
{
logger.warn("Ignoring to parameter as '" + to + "' does not conform to the date pattern: " + DATE_PATTERN);
}
}
}

View File

@@ -43,22 +43,22 @@ import org.springframework.extensions.webscripts.WebScriptResponse;
/**
* Abstract base class for transfer related web scripts.
*
*
* @author Gavin Cornwell
*/
public abstract class BaseTransferWebScript extends StreamACP
public abstract class BaseTransferWebScript extends StreamACP
implements RecordsManagementModel
{
/** Logger */
private static Log logger = LogFactory.getLog(BaseTransferWebScript.class);
protected FilePlanService filePlanService;
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
*/
@@ -69,14 +69,14 @@ public abstract class BaseTransferWebScript extends StreamACP
{
// retrieve requested format
String format = req.getFormat();
// construct model for template
Status status = new Status();
Cache cache = new Cache(getDescription().getRequiredCache());
Map<String, Object> model = new HashMap<String, Object>();
model.put("status", status);
model.put("cache", cache);
// get the parameters that represent the NodeRef, we know they are present
// otherwise this webscript would not have matched
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
@@ -84,46 +84,48 @@ public abstract class BaseTransferWebScript extends StreamACP
String storeId = templateVars.get("store_id");
String nodeId = templateVars.get("id");
String transferId = templateVars.get("transfer_id");
// create and return the file plan NodeRef
NodeRef filePlan = new NodeRef(new StoreRef(storeType, storeId), nodeId);
if (logger.isDebugEnabled())
{
logger.debug("Retrieving transfer '" + transferId + "' from file plan: " + filePlan);
}
// ensure the file plan exists
if (!this.nodeService.exists(filePlan))
{
status.setCode(HttpServletResponse.SC_NOT_FOUND,
status.setCode(HttpServletResponse.SC_NOT_FOUND,
"Node " + filePlan.toString() + " does not exist");
Map<String, Object> templateModel = createTemplateParameters(req, res, model);
sendStatus(req, res, status, cache, format, templateModel);
return;
}
// ensure the node is a filePlan object
if (!TYPE_FILE_PLAN.equals(this.nodeService.getType(filePlan)))
{
status.setCode(HttpServletResponse.SC_BAD_REQUEST,
status.setCode(HttpServletResponse.SC_BAD_REQUEST,
"Node " + filePlan.toString() + " is not a file plan");
Map<String, Object> templateModel = createTemplateParameters(req, res, model);
sendStatus(req, res, status, cache, format, templateModel);
return;
}
// attempt to find the transfer node
NodeRef transferNode = findTransferNode(filePlan, transferId);
// send 404 if the transfer is not found
if (transferNode == null)
{
status.setCode(HttpServletResponse.SC_NOT_FOUND,
status.setCode(HttpServletResponse.SC_NOT_FOUND,
"Could not locate transfer with id: " + transferId);
Map<String, Object> templateModel = createTemplateParameters(req, res, model);
sendStatus(req, res, status, cache, format, templateModel);
return;
}
// execute the transfer operation
tempFile = executeTransfer(transferNode, req, res, status, cache);
}
@@ -147,10 +149,10 @@ public abstract class BaseTransferWebScript extends StreamACP
}
}
}
/**
* Abstract method subclasses implement to perform the actual logic required.
*
*
* @param transferNode The transfer node
* @param req The request
* @param res The response
@@ -160,13 +162,13 @@ public abstract class BaseTransferWebScript extends StreamACP
* @throws IOException
*/
protected abstract File executeTransfer(NodeRef transferNode,
WebScriptRequest req, WebScriptResponse res,
WebScriptRequest req, WebScriptResponse res,
Status status, Cache cache) throws IOException;
/**
* Finds a transfer object with the given id in the given file plan.
* This method returns null if a transfer with the given id is not found.
*
*
* @param filePlan The file plan to search
* @param transferId The id of the transfer being requested
* @return The transfer node or null if not found
@@ -174,11 +176,11 @@ public abstract class BaseTransferWebScript extends StreamACP
protected NodeRef findTransferNode(NodeRef filePlan, String transferId)
{
NodeRef transferNode = null;
// get all the transfer nodes and find the one we need
NodeRef transferContainer = filePlanService.getTransferContainer(filePlan);
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(transferContainer,
ContentModel.ASSOC_CONTAINS,
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(transferContainer,
ContentModel.ASSOC_CONTAINS,
RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef child : assocs)
{
@@ -188,26 +190,26 @@ public abstract class BaseTransferWebScript extends StreamACP
break;
}
}
return transferNode;
}
/**
* Returns an array of NodeRefs representing the items to be transferred.
*
*
* @param transferNode The transfer object
* @return Array of NodeRefs
*/
protected NodeRef[] getTransferNodes(NodeRef transferNode)
{
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(transferNode,
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(transferNode,
RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL);
NodeRef[] itemsToTransfer = new NodeRef[assocs.size()];
for (int idx = 0; idx < assocs.size(); idx++)
{
itemsToTransfer[idx] = assocs.get(idx).getChildRef();
}
return itemsToTransfer;
}
}

View File

@@ -158,7 +158,9 @@ public class ExportPost extends StreamACP
if (tempACPFile != null)
{
if (logger.isDebugEnabled())
{
logger.debug("Deleting temporary archive: " + tempACPFile.getAbsolutePath());
}
tempACPFile.delete();
}

View File

@@ -206,7 +206,9 @@ public class ImportPost extends DeclarativeWebScript
FileCopyUtils.copy(acpContent.getInputStream(), fos); // NOTE: this method closes both streams
if (logger.isDebugEnabled())
{
logger.debug("Importing uploaded ACP (" + acpFile.getAbsolutePath() + ") into " + nodeRef);
}
// setup the import handler
final ACPImportPackageHandler importHandler = new ACPImportPackageHandler(acpFile, "UTF-8");

View File

@@ -170,7 +170,9 @@ public class TransferReportPost extends BaseTransferWebScript
}
if (logger.isDebugEnabled())
{
logger.debug("Filing transfer report as record in record folder: " + destination);
}
// generate the report (will be in JSON format)
report = generateHTMLTransferReport(transferNode);
@@ -179,7 +181,9 @@ public class TransferReportPost extends BaseTransferWebScript
NodeRef record = fileTransferReport(report, destination);
if (logger.isDebugEnabled())
{
logger.debug("Filed transfer report as new record: " + record);
}
// return success flag and record noderef as JSON
JSONObject responseJSON = new JSONObject();

View File

@@ -29,9 +29,9 @@ import org.springframework.extensions.surf.util.I18NUtil;
/**
* Saved search details.
*
*
* Example format of posted Saved Search JSON:
*
*
* {
* "siteid" : "rm",
* "name": "search name",
@@ -39,7 +39,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
* "search": "the search sting as entered by the user",
* "public": boolean,
* "searchparams" :
* {
* {
* "maxItems" : 500,
* "records" : true,
* "undeclaredrecords" : false,
@@ -47,12 +47,12 @@ import org.springframework.extensions.surf.util.I18NUtil;
* "recordfolders" : false,
* "frozen" : false,
* "cutoff" : false,
* "containertypes" :
* "containertypes" :
* [
* "rma:recordSeries",
* "rma:recordCategory"
* ]
* "sort" :
* "sort" :
* [
* {
* "field" : "cm:name",
@@ -61,18 +61,18 @@ import org.springframework.extensions.surf.util.I18NUtil;
* ]
* }
* }
*
*
* where: name and query values are mandatory,
* searchparams contains the filters, sort, etc information about the query
* query is there for backward compatibility
* query is there for backward compatibility
* note:
* "params": "terms=keywords:xyz&undeclared=true",
* "params": "terms=keywords:xyz&undeclared=true",
* "sort": "cm:name/asc"
* "query": "the complete search query string",
* "query": "the complete search query string",
* ... are sometimes found in the place of searchparams and are migrated to the new format when re-saved
* params are in URL encoded name/value pair format
* sort is in comma separated "property/dir" packed format i.e. "cm:name/asc,cm:title/desc"
*
*
* @author Roy Wetherall
*/
public class SavedSearchDetails extends ReportDetails
@@ -85,37 +85,37 @@ public class SavedSearchDetails extends ReportDetails
public static final String PUBLIC = "public";
public static final String REPORT = "report";
public static final String SEARCHPARAMS = "searchparams";
// JSON values for backwards compatibility
public static final String QUERY = "query";
public static final String SORT = "sort";
public static final String PARAMS = "params";
private static final String DEFAULT_SITE_ID = "rm";
/** Site id */
private String siteId;
/** Indicates whether the saved search is public or not */
private boolean isPublic = true;
/** Indicates whether the saved search is a report */
private boolean isReport = false;
/** Helper method to link to search node ref if provided */
private NodeRef nodeRef = null;
/** Namespace service */
NamespaceService namespaceService;
/** Records management search service */
RecordsManagementSearchServiceImpl searchService;
/** Saves search details compatibility */
private SavedSearchDetailsCompatibility compatibility;
/**
*
*
* @param jsonString
* @return
*/
@@ -124,28 +124,31 @@ public class SavedSearchDetails extends ReportDetails
try
{
JSONObject search = new JSONObject(jsonString);
// Get the site id
String siteId = DEFAULT_SITE_ID;
if (search.has(SITE_ID) == true)
{
siteId = search.getString(SITE_ID);
}
}
// Get the name
if (search.has(NAME) == false)
{
throw new AlfrescoRuntimeException("Can not create saved search details from json, because required name is not present. " + jsonString);
}
String name = search.getString(NAME);
// Get the description
String description = "";
if (search.has(DESCRIPTION) == true)
{
description = search.getString(DESCRIPTION);
String translated = I18NUtil.getMessage(description);
if (translated!=null ) description = translated;
if (translated != null)
{
description = translated;
}
}
// Get the query
@@ -162,13 +165,13 @@ public class SavedSearchDetails extends ReportDetails
{
throw new AlfrescoRuntimeException("Can not create saved search details from json, because required search is not present. " + jsonString);
}
}
else
{
query = search.getString(SEARCH);
}
// Get the search parameters
RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters();
if (search.has(SEARCHPARAMS) == true)
@@ -185,21 +188,21 @@ public class SavedSearchDetails extends ReportDetails
searchParameters = SavedSearchDetailsCompatibility.createSearchParameters(oldParams, oldSort, namespaceService);
}
}
// Determine whether the saved query is public or not
boolean isPublic = true;
if (search.has(PUBLIC) == true)
{
isPublic = search.getBoolean(PUBLIC);
}
// Determine whether the saved query is a report or not
boolean isReport = false;
if (search.has(REPORT) == true)
{
isReport = search.getBoolean(REPORT);
}
// Create the saved search details object
SavedSearchDetails savedSearchDetails = new SavedSearchDetails(siteId, name, description, query, searchParameters, isPublic, isReport, namespaceService, searchService);
savedSearchDetails.nodeRef = nodeRef;
@@ -208,7 +211,7 @@ public class SavedSearchDetails extends ReportDetails
catch (JSONException exception)
{
throw new AlfrescoRuntimeException("Can not create saved search details from json. " + jsonString, exception);
}
}
}
/**
@@ -218,22 +221,22 @@ public class SavedSearchDetails extends ReportDetails
* @param isPublic
*/
/*package*/ SavedSearchDetails(
String siteId,
String name,
String description,
String serach,
RecordsManagementSearchParameters searchParameters,
boolean isPublic,
String siteId,
String name,
String description,
String serach,
RecordsManagementSearchParameters searchParameters,
boolean isPublic,
boolean isReport,
NamespaceService namespaceService,
RecordsManagementSearchServiceImpl searchService)
RecordsManagementSearchServiceImpl searchService)
{
super(name, description, serach, searchParameters);
ParameterCheck.mandatory("siteId", siteId);
ParameterCheck.mandatory("namespaceService", namespaceService);
ParameterCheck.mandatory("searchService", searchService);
this.siteId = siteId;
this.isPublic = isPublic;
this.isReport = isReport;
@@ -241,23 +244,23 @@ public class SavedSearchDetails extends ReportDetails
this.compatibility = new SavedSearchDetailsCompatibility(this, namespaceService, searchService);
this.searchService = searchService;
}
/**
* @return
*/
public String getSiteId()
public String getSiteId()
{
return siteId;
}
}
/**
* @return
*/
public boolean isPublic()
public boolean isPublic()
{
return isPublic;
}
/**
* @return
*/
@@ -265,12 +268,12 @@ public class SavedSearchDetails extends ReportDetails
{
return isReport;
}
public SavedSearchDetailsCompatibility getCompatibility()
{
return compatibility;
}
/**
* @return NodeRef search node ref, null if not set
*/
@@ -278,7 +281,7 @@ public class SavedSearchDetails extends ReportDetails
{
return nodeRef;
}
/**
* @return
*/
@@ -291,13 +294,13 @@ public class SavedSearchDetails extends ReportDetails
jsonObject.put(NAME, name);
jsonObject.put(DESCRIPTION, description);
jsonObject.put(SEARCH, search);
jsonObject.put(SEARCHPARAMS, searchParameters.toJSONObject(namespaceService));
jsonObject.put(SEARCHPARAMS, searchParameters.toJSONObject(namespaceService));
jsonObject.put(PUBLIC, isPublic);
// Add full query for backward compatibility
jsonObject.put(QUERY, searchService.buildQueryString(search, searchParameters));
jsonObject.put(SORT, compatibility.getSort());
return jsonObject.toString();
}
catch (JSONException exception)