Search in sources :

Example 11 with FilePlanComponentKind

use of org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind in project records-management by Alfresco.

the class RMMetaDataGet method executeImpl.

/*
     * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
     */
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    // create model object with the lists model
    Map<String, Object> model = new HashMap<String, Object>(1);
    boolean extended = false;
    String result = "NONE";
    // Get the nodeRef and confirm it is valid
    String nodeRef = req.getParameter(PARAM_NODEREF);
    if (nodeRef == null || nodeRef.length() == 0) {
        String type = req.getParameter(PARAM_TYPE);
        if (type != null && type.length() != 0 && type.indexOf(':') != -1) {
            Matcher m = QNAME_PATTERN.matcher(type);
            if (m.matches()) {
                QName qname = QName.createQName(type, namespaceService);
                FilePlanComponentKind kind = filePlanService.getFilePlanComponentKindFromType(qname);
                if (kind != null) {
                    result = kind.toString();
                }
            }
        }
    } else {
        // quick test before running slow match for full NodeRef pattern
        if (nodeRef.indexOf(':') != -1) {
            Matcher m = NODE_REF_PATTERN.matcher(nodeRef);
            if (m.matches()) {
                NodeRef nodeRefObj = new NodeRef(nodeRef);
                FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRefObj);
                if (kind != null) {
                    result = kind.toString();
                }
                String extendedValue = req.getParameter(PARAM_EXTENDED);
                if (extendedValue != null && extendedValue.length() != 0) {
                    extended = Boolean.parseBoolean(extendedValue);
                    if (extended) {
                        // get the aspects of the node
                        model.put("aspects", getAspects(nodeRefObj));
                    }
                }
            }
        }
    }
    model.put("kind", result);
    model.put("extended", extended);
    return model;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) HashMap(java.util.HashMap) Matcher(java.util.regex.Matcher) QName(org.alfresco.service.namespace.QName) FilePlanComponentKind(org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind)

Example 12 with FilePlanComponentKind

use of org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind in project records-management by Alfresco.

the class IsKindEvaluator method evaluateImpl.

@Override
protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef) {
    boolean result = false;
    String kind = ((QName) actionCondition.getParameterValue(PARAM_KIND)).getLocalName();
    FilePlanComponentKind filePlanComponentKind = getFilePlanService().getFilePlanComponentKind(actionedUponNodeRef);
    if (filePlanComponentKind != null && filePlanComponentKind.toString().equals(kind)) {
        result = true;
    }
    return result;
}
Also used : QName(org.alfresco.service.namespace.QName) FilePlanComponentKind(org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind)

Example 13 with FilePlanComponentKind

use of org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind in project records-management by Alfresco.

the class RMv2FilePlanNodeRefPatch method executePatch.

/**
 * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
 */
@Override
protected void executePatch() {
    Pair<Long, QName> aspectPair = qnameDAO.getQName(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT);
    if (aspectPair != null) {
        List<Long> filePlanComponents = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID());
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("   ... updating " + filePlanComponents.size() + " items");
        }
        for (Long filePlanComponent : filePlanComponents) {
            Pair<Long, NodeRef> recordPair = nodeDAO.getNodePair(filePlanComponent);
            NodeRef filePlanComponentNodeRef = recordPair.getSecond();
            NodeRef filePlan = filePlanService.getFilePlan(filePlanComponentNodeRef);
            if (filePlan != null) {
                // set the file plan node reference
                if (nodeService.getProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF) == null) {
                    nodeService.setProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF, filePlan);
                }
                // only set the admin permissions on record categories, record folders and records
                FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(filePlanComponentNodeRef);
                if (FilePlanComponentKind.RECORD_CATEGORY.equals(kind) || FilePlanComponentKind.RECORD_FOLDER.equals(kind) || FilePlanComponentKind.RECORD.equals(kind)) {
                    // ensure the that the records management role has read and file on the node
                    Role adminRole = filePlanRoleService.getRole(filePlan, "Administrator");
                    if (adminRole != null) {
                        permissionService.setPermission(filePlanComponentNodeRef, adminRole.getRoleGroupName(), RMPermissionModel.FILING, true);
                    }
                    // ensure that the default vital record default values have been set (RM-753)
                    Serializable vitalRecordIndicator = nodeService.getProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR);
                    if (vitalRecordIndicator == null) {
                        nodeService.setProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR, false);
                    }
                    Serializable reviewPeriod = nodeService.getProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD);
                    if (reviewPeriod == null) {
                        nodeService.setProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD, new Period("none|0"));
                    }
                }
            } else {
                if (LOGGER.isWarnEnabled()) {
                    LOGGER.warn("   ... node " + filePlanComponent.toString() + " was skiped, beacuse there was no associated file plan.");
                }
            }
        }
    }
}
Also used : Role(org.alfresco.module.org_alfresco_module_rm.role.Role) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) QName(org.alfresco.service.namespace.QName) Period(org.alfresco.service.cmr.repository.Period) FilePlanComponentKind(org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind)

Aggregations

FilePlanComponentKind (org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind)13 NodeRef (org.alfresco.service.cmr.repository.NodeRef)5 QName (org.alfresco.service.namespace.QName)4 HashMap (java.util.HashMap)2 Period (org.alfresco.service.cmr.repository.Period)2 Serializable (java.io.Serializable)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 RecordsManagementActionDefinition (org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition)1 DispositionSchedule (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule)1 DispositionScheduleImpl (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionScheduleImpl)1 Role (org.alfresco.module.org_alfresco_module_rm.role.Role)1 ActionDefinition (org.alfresco.service.cmr.action.ActionDefinition)1 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)1 JSONObject (org.json.simple.JSONObject)1