Search in sources :

Example 51 with AlfrescoRuntimeException

use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.

the class DeclarativeReportGenerator method getReportTemplate.

/**
 * Get's the report template based on the type and mimetype.
 *
 * @param mimetype
 * @return
 */
private NodeRef getReportTemplate(String mimetype) {
    // check that the template root has been correctly bootstraped
    if (!fileFolderService.exists(TEMPLATE_ROOT)) {
        throw new AlfrescoRuntimeException("Unable to get report template, because the template root folder does not exist in the data dictionary.");
    }
    String reportTemplateName = getReportTemplateName(mimetype);
    NodeRef reportTemplateNodeRef = fileFolderService.searchSimple(TEMPLATE_ROOT, reportTemplateName);
    if (reportTemplateNodeRef == null) {
        throw new AlfrescoRuntimeException("Unable to get report template, because report template " + reportTemplateName + " does not exist.");
    }
    // get localise template
    return fileFolderService.getLocalizedSibling(reportTemplateNodeRef);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 52 with AlfrescoRuntimeException

use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.

the class RecordFolderServiceImpl method isRecordFolderDeclared.

/**
 * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#isRecordFolderDeclared(NodeRef)
 */
@Override
public boolean isRecordFolderDeclared(NodeRef nodeRef) {
    ParameterCheck.mandatory("nodeRef", nodeRef);
    // Check we have a record folder
    if (!isRecordFolder(nodeRef)) {
        throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_EXPECTED));
    }
    boolean result = true;
    // Check that each record in the record folder in declared
    List<NodeRef> records = recordService.getRecords(nodeRef);
    for (NodeRef record : records) {
        if (!recordService.isDeclared(record)) {
            result = false;
            break;
        }
    }
    return result;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 53 with AlfrescoRuntimeException

use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.

the class InplaceRecordServiceImpl method moveRecord.

/**
 * @see org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService#moveRecord(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
 */
@Override
public void moveRecord(final NodeRef nodeRef, final NodeRef targetNodeRef) {
    ParameterCheck.mandatory("nodeRef", nodeRef);
    ParameterCheck.mandatory("targetNodeRef", targetNodeRef);
    NodeRef sourceParentNodeRef = null;
    NodeRef originatingLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION);
    for (ChildAssociationRef parentAssoc : nodeService.getParentAssocs(nodeRef)) {
        if (!parentAssoc.isPrimary() && parentAssoc.getParentRef().equals(originatingLocation)) {
            sourceParentNodeRef = parentAssoc.getParentRef();
            break;
        }
    }
    if (sourceParentNodeRef == null) {
        throw new AlfrescoRuntimeException("Could not find source parent node reference.");
    }
    SiteInfo sourceSite = siteService.getSite(sourceParentNodeRef);
    SiteInfo targetSite = siteService.getSite(targetNodeRef);
    if (!sourceSite.equals(targetSite)) {
        throw new AlfrescoRuntimeException("The record can only be moved within the same collaboration site.");
    }
    if (!sourceSite.getSitePreset().equals("site-dashboard")) {
        throw new AlfrescoRuntimeException("Only records within a collaboration site can be moved.");
    }
    final NodeRef source = sourceParentNodeRef;
    authenticationUtil.runAsSystem(new RunAsWork<Void>() {

        @Override
        public Void doWork() {
            try {
                // Move the record
                fileFolderService.moveFrom(nodeRef, source, targetNodeRef, null);
                // Update the originating location property
                nodeService.setProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION, targetNodeRef);
            } catch (FileExistsException | FileNotFoundException ex) {
                throw new AlfrescoRuntimeException("Can't move node: " + ex);
            }
            return null;
        }
    });
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 54 with AlfrescoRuntimeException

use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.

the class DateParameterProcessor method handleYear.

private String handleYear(String[] values) {
    String style = getStyle(values);
    String pattern;
    if (SHORT.equalsIgnoreCase(style)) {
        pattern = "yy";
    } else if (LONG.equalsIgnoreCase(style)) {
        pattern = "yyyy";
    } else if (WEEK.equalsIgnoreCase(style)) {
        pattern = "ww";
    } else {
        throw new AlfrescoRuntimeException("The pattern 'date.year." + style + "' is not supported!");
    }
    return new SimpleDateFormat(pattern).format(new Date());
}
Also used : AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 55 with AlfrescoRuntimeException

use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.

the class DateParameterProcessor method handleDay.

private String handleDay(String[] values) {
    String style = getStyle(values);
    String pattern;
    if (SHORT.equalsIgnoreCase(style)) {
        pattern = "EE";
    } else if (LONG.equalsIgnoreCase(style)) {
        pattern = "EEEE";
    } else if (NUMBER.equalsIgnoreCase(style)) {
        pattern = "uu";
    } else if (MONTH.equalsIgnoreCase(style)) {
        pattern = "dd";
    } else if (YEAR.equalsIgnoreCase(style)) {
        pattern = "DDD";
    } else {
        throw new AlfrescoRuntimeException("The pattern 'date.day." + style + "' is not supported!");
    }
    return new SimpleDateFormat(pattern).format(new Date());
}
Also used : AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)197 NodeRef (org.alfresco.service.cmr.repository.NodeRef)79 QName (org.alfresco.service.namespace.QName)39 HashMap (java.util.HashMap)38 IOException (java.io.IOException)32 ArrayList (java.util.ArrayList)31 JSONException (org.json.JSONException)23 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)22 Serializable (java.io.Serializable)20 M2Model (org.alfresco.repo.dictionary.M2Model)18 JSONObject (org.json.JSONObject)15 Date (java.util.Date)14 Map (java.util.Map)12 FacesContext (javax.faces.context.FacesContext)12 InputStream (java.io.InputStream)10 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)10 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)10 JSONArray (org.json.JSONArray)10 List (java.util.List)8 FileNotFoundException (org.alfresco.service.cmr.model.FileNotFoundException)8