Search in sources :

Example 66 with StoreRef

use of org.alfresco.service.cmr.repository.StoreRef in project records-management by Alfresco.

the class HoldsGet method getFilePlan.

/**
 * Helper method to get the file plan from the request
 *
 * @param req The webscript request
 * @return The {@link NodeRef} of the file plan
 */
private NodeRef getFilePlan(WebScriptRequest req) {
    NodeRef filePlan = null;
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    String storeType = templateVars.get("store_type");
    String storeId = templateVars.get("store_id");
    String id = templateVars.get("id");
    if (StringUtils.isNotBlank(storeType) && StringUtils.isNotBlank(storeId) && StringUtils.isNotBlank(id)) {
        filePlan = new NodeRef(new StoreRef(storeType, storeId), id);
        // check that this node is actually a file plan
        if (!nodeService.exists(filePlan) || !filePlanService.isFilePlan(filePlan)) {
            throw new WebScriptException(Status.STATUS_NOT_FOUND, "The file plan provided could not be found.");
        }
    } else {
        filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
        if (filePlan == null) {
            throw new WebScriptException(Status.STATUS_NOT_FOUND, "The default file plan node could not be found.");
        }
    }
    return filePlan;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) StoreRef(org.alfresco.service.cmr.repository.StoreRef) WebScriptException(org.springframework.extensions.webscripts.WebScriptException)

Example 67 with StoreRef

use of org.alfresco.service.cmr.repository.StoreRef in project records-management by Alfresco.

the class RmAuthoritiesRestApiTest method getFormattedFilePlanString.

/**
 * Util method to get a formatted nodeRef string
 *
 * @return Returns a formatted nodeRef string
 */
private String getFormattedFilePlanString() {
    StoreRef storeRef = filePlan.getStoreRef();
    String storeType = storeRef.getProtocol();
    String storeId = storeRef.getIdentifier();
    String id = filePlan.getId();
    StringBuffer sb = new StringBuffer(32);
    sb.append(storeType);
    sb.append("/");
    sb.append(storeId);
    sb.append("/");
    sb.append(id);
    return sb.toString();
}
Also used : StoreRef(org.alfresco.service.cmr.repository.StoreRef)

Aggregations

StoreRef (org.alfresco.service.cmr.repository.StoreRef)67 NodeRef (org.alfresco.service.cmr.repository.NodeRef)50 HashMap (java.util.HashMap)18 QName (org.alfresco.service.namespace.QName)17 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)13 StringPropertyValue (org.alfresco.solr.client.StringPropertyValue)13 PropertyValue (org.alfresco.solr.client.PropertyValue)11 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)10 ArrayList (java.util.ArrayList)9 ContentPropertyValue (org.alfresco.solr.client.ContentPropertyValue)9 MLTextPropertyValue (org.alfresco.solr.client.MLTextPropertyValue)9 IOException (java.io.IOException)7 Date (java.util.Date)6 MultiPropertyValue (org.alfresco.solr.client.MultiPropertyValue)6 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)5 PermissionService (org.alfresco.service.cmr.security.PermissionService)5 SolrCore (org.apache.solr.core.SolrCore)5 StringTokenizer (java.util.StringTokenizer)4 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)4 ServiceRegistry (org.alfresco.service.ServiceRegistry)4