Java Code Examples for org.springframework.extensions.surf.util.I18NUtil#getMessage()

The following examples show how to use org.springframework.extensions.surf.util.I18NUtil#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FixTemplatePatch.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected String applyInternal() throws Exception
{
    List<NodeRef> refs = searchService.selectNodes(
            repository.getRootHome(), 
            target, 
            null, 
            namespaceService, 
            false);
    if (refs.size() < 1)
    {
        // skip as it can be deleted
        return I18NUtil.getMessage(MSG_SKIP);
    }
    else
    {
        updateContent(refs.get(0));
    }

    return I18NUtil.getMessage(MSG_SUCCESS);
}
 
Example 2
Source File: GenericDeleteAspectForTypePatch.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected String applyInternal() throws Exception
{
    // We don't need to catch the potential InvalidQNameException here as it will be caught
    // in AbstractPatch and correctly handled there
    QName qnameType = QName.createQName(this.qnameStringType);
    QName qnameAspect = QName.createQName(this.qnameStringAspect);

    Long maxNodeId = patchDAO.getMaxAdmNodeID();
    
    Pair<Long, QName> type = qnameDAO.getQName(qnameType);
    Pair<Long, QName> aspect = qnameDAO.getQName(qnameAspect);
    
    if (type != null && aspect != null)
    {
        for (Long i = 0L; i < maxNodeId; i+=BATCH_SIZE)
        {
            Work work = new Work(type, aspect, i);
            retryingTransactionHelper.doInTransaction(work, false, true);
        }
    }

    return I18NUtil.getMessage(MSG_SUCCESS, qnameAspect, qnameType);
}
 
Example 3
Source File: NotificationServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** 
 * @see org.alfresco.service.cmr.notification.NotificationService#sendNotification(java.lang.String, org.alfresco.service.cmr.notification.NotificationContext)
 */
@Override
public void sendNotification(String notificationProvider, NotificationContext notificationContext) 
{
    // Check the mandatory params
    ParameterCheck.mandatory("notificationProvider", notificationProvider);
    ParameterCheck.mandatory("notificationContext", notificationContext);
    
    // Check that the notificaiton provider exists
    if (exists(notificationProvider) == false)
    {
        throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NP_DOES_NOT_EXIST, notificationProvider));
    }
    
    // Get the notification provider and send notification
    NotificationProvider provider = providers.get(notificationProvider);
    provider.sendNotification(notificationContext);
}
 
Example 4
Source File: CustomModelsImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void validateImportedM2Model(M2Model m2Model)
{
    List<M2Namespace> namespaces = m2Model.getNamespaces();
    if (namespaces.size() > 1)
    {
        throw new ConstraintViolatedException(I18NUtil.getMessage("cmm.rest_api.model.import_namespace_multiple_found", namespaces.size()));
    }
    else if (namespaces.isEmpty())
    {
        throw new ConstraintViolatedException("cmm.rest_api.model.import_namespace_undefined");
    }

    checkUnsupportedModelElements(m2Model.getTypes());
    checkUnsupportedModelElements(m2Model.getAspects());
}
 
Example 5
Source File: AddDutchEmailTemplatesPatch.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @see org.alfresco.repo.admin.patch.AbstractPatch#applyInternal()
 */
@Override
protected String applyInternal() throws Exception
{   
    while (currentIndex < BASE_FILES.length)
    {
        updateTemplates();  
        currentIndex ++;
    }        
    
    return I18NUtil.getMessage("patch.addDutchEmailTemplatesPatch.result");
}
 
Example 6
Source File: UpdateWorkflowNotificationTemplatesPatch.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @see org.alfresco.repo.admin.patch.AbstractPatch#applyInternal()
 */
@Override
protected String applyInternal() throws Exception
{   
    updateTemplates();        
    return I18NUtil.getMessage("patch.updateWorkflowNotificationTemplates.result");
}
 
Example 7
Source File: GenericBootstrapPatch.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected String applyInternal() throws Exception
{
    StoreRef storeRef = importerBootstrap.getStoreRef();
    NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
    if (checkPath != null)
    {
        List<NodeRef> results = searchService.selectNodes(
                rootNodeRef,
                checkPath,
                null,
                namespaceService,
                false);
        if (results.size() > 1)
        {
            throw new PatchException(ERR_MULTIPLE_FOUND, checkPath);
        }
        else if (results.size() == 1)
        {
            // nothing to do - it exists
            return I18NUtil.getMessage(MSG_EXISTS, checkPath);
            
        }
    }
    String path = bootstrapView.getProperty("path");
    List<Properties> bootstrapViews = new ArrayList<Properties>(1);
    bootstrapViews.add(bootstrapView);
    // modify the bootstrapper
    importerBootstrap.setBootstrapViews(bootstrapViews);
    importerBootstrap.setUseExistingStore(true);              // allow import into existing store

    importerBootstrap.bootstrap();
    // done
    return I18NUtil.getMessage(MSG_CREATED, path, rootNodeRef);
}
 
Example 8
Source File: SchemaVersionValidator.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void validate(DbObject referenceObj, DbObject targetObj, DiffContext ctx)
{
    Schema reference = (Schema) referenceObj;
    Schema target = (Schema) targetObj;
    
    if (target.getVersion() < reference.getVersion())
    {
        DbProperty targetProperty = new DbProperty(target, "version");
        String message = I18NUtil.getMessage(
                    "system.schema_comp.schema_version_validator",
                    reference.getVersion());
        ctx.getComparisonResults().add(new ValidationResult(targetProperty, message));
    }
}
 
Example 9
Source File: SWSDPPatch.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected String applyInternal() throws Exception
{
	SiteInfo siteInfo = siteService.getSite("swsdp");
	if(siteInfo != null)
	{
 	NodeRef nodeRef = siteInfo.getNodeRef();
 	NodeRef surfConfigNodeRef = nodeService.getChildByName(nodeRef, ContentModel.ASSOC_CONTAINS, "surf-config");
 	if(surfConfigNodeRef == null)
 	{
         return I18NUtil.getMessage(MSG_MISSING_SURFCONFIG);
 	}
 	else
 	{
  	for(ChildAssociationRef childRef : nodeService.getChildAssocs(surfConfigNodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL))
  	{
  		hiddenAspect.showNode(childRef.getChildRef(), true);
  	}
 	}

     return I18NUtil.getMessage(MSG_SITE_PATCHED);
	}
	else
	{
     return I18NUtil.getMessage(MSG_SKIPPED);
	}
}
 
Example 10
Source File: BaseTemplateRenderingEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * This method gets the parameter definition display label from the properties file.
 * It looks first for a property whose key has a fixed rendition service-specific
 * prefix and if that gets null, it then delegates to the standard bean name-based
 * approach.
 * 
 * @param paramName  the name of the parameter
 * @return           the display label of the parameter
 */
@Override
protected String getParamDisplayLabel(String paramName)
{
    // First we try to get the message using a common prefix for all template-based rendering engines.
    final String commonPropertiesPrefix = "baseTemplateRenderingAction";
    String message = I18NUtil.getMessage(commonPropertiesPrefix + "." + paramName + "." + DISPLAY_LABEL);
    
    // And if that doesn't work we delegate to the superclass.
    if (message == null)
    {
        message = super.getParamDisplayLabel(paramName);
    }
    return message;
}
 
Example 11
Source File: UpdateFollowingEmailTemplatesPatch.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @see org.alfresco.repo.admin.patch.AbstractPatch#applyInternal()
 */
@Override
protected String applyInternal() throws Exception
{   
    updateTemplates();        
    return I18NUtil.getMessage("patch.updateFollowingEmailTemplatesPatch.result");
}
 
Example 12
Source File: RepositoryExporterComponent.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public RepositoryExportHandle[] export(NodeRef repositoryDestination, String packageName)
{
    ParameterCheck.mandatory("repositoryDestination", repositoryDestination);
    FileInfo destInfo = fileFolderService.getFileInfo(repositoryDestination);
    if (destInfo == null || !destInfo.isFolder())
    {
        throw new ExporterException("Repository destination " + repositoryDestination + " is not a folder.");
    }

    List<FileExportHandle> exportHandles = exportStores(exportStores, packageName, new TempFileExporter());
    Map<String, String> mimetypeExtensions = mimetypeService.getExtensionsByMimetype();
    List<RepositoryExportHandle> repoExportHandles = new ArrayList<RepositoryExportHandle>(exportHandles.size());
    for (FileExportHandle exportHandle : exportHandles)
    {
        String name = exportHandle.packageName + "." + mimetypeExtensions.get(exportHandle.mimeType);
        String title = exportHandle.packageName;
        String description;
        if (exportHandle.storeRef != null)
        {
            description = I18NUtil.getMessage("export.store.package.description", new Object[] { exportHandle.storeRef.toString() });
        }
        else
        {
            description = I18NUtil.getMessage("export.generic.package.description");
        }
        
        NodeRef repoExportFile = addExportFile(repositoryDestination, name, title, description, exportHandle.mimeType, exportHandle.exportFile);
        RepositoryExportHandle handle = new RepositoryExportHandle();
        handle.storeRef = exportHandle.storeRef;
        handle.packageName = exportHandle.packageName;
        handle.mimeType = exportHandle.mimeType;
        handle.exportFile = repoExportFile;
        repoExportHandles.add(handle);
        
        // delete temporary export file
        exportHandle.exportFile.delete();
    }
    
    return repoExportHandles.toArray(new RepositoryExportHandle[repoExportHandles.size()]);
}
 
Example 13
Source File: InvitationServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Generates a description for the workflow
 * 
 * @param siteInfo The site to generate a description for
 * @param messageId The resource bundle key to use for the description 
 * @return The workflow description
 */
protected String generateWorkflowDescription(SiteInfo siteInfo, String messageId)
{
    String siteTitle = siteInfo.getTitle();
    if (siteTitle == null || siteTitle.length() == 0)
    {
        siteTitle = siteInfo.getShortName();
    }
    
    Locale locale = (Locale) this.nodeService.getProperty(siteInfo.getNodeRef(), ContentModel.PROP_LOCALE);
    
    return I18NUtil.getMessage(messageId, locale == null ? I18NUtil.getLocale() : locale, siteTitle);
}
 
Example 14
Source File: WorkflowModelBuilder.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
private String getOutcome(WorkflowTask task)
{
    String outcomeLabel = null;
    
    // there will only be an outcome if the task is completed
    if (task.getState().equals(WorkflowTaskState.COMPLETED))
    {
        String outcomeId = (String)task.getProperties().get(WorkflowModel.PROP_OUTCOME);
        if (outcomeId != null)
        {
            // find the transition with the matching id and get the label
            WorkflowTransition[] transitions = task.getDefinition().getNode().getTransitions();
            for (WorkflowTransition transition : transitions)
            {
                if (transition.getId() != null && transition.getId().equals(outcomeId))
                {
                    outcomeLabel = transition.getTitle();
                    break;
                }
            }
            if (outcomeLabel == null)
            {
                String translatedOutcome = I18NUtil.getMessage(TASK_OUTCOME_MESSAGE_PREFIX+outcomeId);
                if (translatedOutcome != null)
                {
                    outcomeLabel = translatedOutcome;
                } 
                else 
                {
                    outcomeLabel = outcomeId;
                }
            }
        }
    }
    
    return outcomeLabel;
}
 
Example 15
Source File: AbstractModuleComponent.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void init()
{
    // Ensure that the description gets I18N'ized
    description = I18NUtil.getMessage(description);
    // Register the component with the service
    if (moduleService != null)                  // Allows optional registration of the component
    {
        moduleService.registerComponent(this);
    }
}
 
Example 16
Source File: BaseParameterConstraint.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Get the I18N display label for a particular key
 * 
 * @param key String
 * @return String I18N value
 */
protected String getI18NLabel(String key)
{
    String result = key.toString();
    StringBuffer longKey = new StringBuffer(name).
                                append(".").
                                append(key.toString().toLowerCase());
    String i18n = I18NUtil.getMessage(longKey.toString());
    if (i18n != null)
    {
        result = i18n;
    }
    return result;
}
 
Example 17
Source File: SchemaBootstrap.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private BootstrapStopException()
{
    super(I18NUtil.getMessage(ERR_FORCED_STOP));
}
 
Example 18
Source File: DocumentLinkServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public NodeRef createDocumentLink(final NodeRef source, NodeRef destination)
{
    if (logger.isDebugEnabled())
    {
        logger.debug("Creating document link. source: " + source + ", destination: " + destination);
    }

    /* Validate input */
    PropertyCheck.mandatory(this, "source", source);
    PropertyCheck.mandatory(this, "destination", destination);

    // check if source node exists
    if (!nodeService.exists(source))
    {
        throw new IllegalArgumentException("Source NodeRef '" + source + "' does not exist");
    }
    // check if destination node exists
    if (!nodeService.exists(destination))
    {
        throw new IllegalArgumentException("Destination NodeRef '" + destination + "' does not exist");
    }
    // check if destination node is a directory
    if (!dictionaryService.isSubClass(nodeService.getType(destination), ContentModel.TYPE_FOLDER))
    {
        throw new IllegalArgumentException("Destination node NodeRef '" + source + "' must be of type " + ContentModel.TYPE_FOLDER);
    }

    /* Create link */
    String sourceName = (String) nodeService.getProperty(source, ContentModel.PROP_NAME);

    String newName = sourceName + LINK_NODE_EXTENSION;
    newName = I18NUtil.getMessage(LINK_TO_LABEL, newName);

    Map<QName, Serializable> props = new HashMap<QName, Serializable>();
    props.put(ContentModel.PROP_NAME, newName);
    props.put(ContentModel.PROP_LINK_DESTINATION, source);
    props.put(ContentModel.PROP_TITLE, newName);
    props.put(ContentModel.PROP_DESCRIPTION, newName);

    QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(newName));

    ChildAssociationRef childRef = null;
    QName sourceType = nodeService.getType(source);

    if (checkOutCheckInService.isWorkingCopy(source) || nodeService.hasAspect(source, ContentModel.ASPECT_LOCKABLE))
    {
        throw new IllegalArgumentException("Cannot perform operation since the node (id:" + source.getId() + ") is locked.");
    }

    try
    {
        if (dictionaryService.isSubClass(sourceType, ContentModel.TYPE_CONTENT))
        {
            // create File Link node
            childRef = nodeService.createNode(destination, ContentModel.ASSOC_CONTAINS, assocQName, ApplicationModel.TYPE_FILELINK, props);

        }
        else if (!dictionaryService.isSubClass(sourceType, SiteModel.TYPE_SITE)
                && dictionaryService.isSubClass(nodeService.getType(source), ContentModel.TYPE_FOLDER))
        {
            // create Folder link node
            props.put(ApplicationModel.PROP_ICON, "space-icon-link");
            childRef = nodeService.createNode(destination, ContentModel.ASSOC_CONTAINS, assocQName, ApplicationModel.TYPE_FOLDERLINK, props);
        }
        else
        {
            throw new IllegalArgumentException("Unsupported source node type : " + nodeService.getType(source));
        }
    }
    catch (DuplicateChildNodeNameException ex)
    {
        throw new IllegalArgumentException("A file with the name '" + newName + "' already exists in the destination folder", ex);
    }

    // add linked aspect to the sourceNode - run as System
    AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
    {
        public Void doWork() throws Exception
        {
            behaviourFilter.disableBehaviour(source, ContentModel.ASPECT_AUDITABLE);
            try
            {
                nodeService.addAspect(source, ApplicationModel.ASPECT_LINKED, null);
            }
            finally
            {
                behaviourFilter.enableBehaviour(source, ContentModel.ASPECT_AUDITABLE);
            }

            return null;
        }
    }, AuthenticationUtil.getSystemUserName());

    return childRef.getChildRef();
}
 
Example 19
Source File: ExporterActionExecuter.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Creates the ZIP file node in the repository for the export
 * 
 * @param ruleAction The rule being executed
 * @return The NodeRef of the newly created ZIP file
 */
private NodeRef createExportZip(Action ruleAction, NodeRef actionedUponNodeRef)
{
    // create a node in the repository to represent the export package
    NodeRef exportDest = (NodeRef)ruleAction.getParameterValue(PARAM_DESTINATION_FOLDER);
    String packageName = (String)ruleAction.getParameterValue(PARAM_PACKAGE_NAME);

    // add the default Alfresco content package extension if an extension hasn't been given
    if (!packageName.endsWith("." + ACPExportPackageHandler.ACP_EXTENSION))
    {
        packageName += (packageName.charAt(packageName.length() -1) == '.') ? ACPExportPackageHandler.ACP_EXTENSION : "." + ACPExportPackageHandler.ACP_EXTENSION;
    }
    
    // set the name for the new node
    Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(1);
    contentProps.put(ContentModel.PROP_NAME, packageName);
        
    // create the node to represent the zip file
    String assocName = QName.createValidLocalName(packageName);
    ChildAssociationRef assocRef = this.nodeService.createNode(
          exportDest, ContentModel.ASSOC_CONTAINS,
          QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, assocName),
          ContentModel.TYPE_CONTENT, contentProps);
     
    NodeRef zipNodeRef = assocRef.getChildRef();
    
    // build a description string to be set on the node representing the content package
    String desc = "";
    String storeRef = (String)ruleAction.getParameterValue(PARAM_STORE);
    NodeRef rootNode = this.nodeService.getRootNode(new StoreRef(storeRef));
    if (rootNode.equals(actionedUponNodeRef))
    {
       desc = I18NUtil.getMessage("export.root.package.description");
    }
    else
    {
       String spaceName = (String)this.nodeService.getProperty(actionedUponNodeRef, ContentModel.PROP_NAME);
       String pattern = I18NUtil.getMessage("export.package.description");
       if (pattern != null && spaceName != null)
       {
          desc = MessageFormat.format(pattern, spaceName);
       }
    }
    
    // apply the titled aspect to behave in the web client
    Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(3, 1.0f);
    titledProps.put(ContentModel.PROP_TITLE, packageName);
    titledProps.put(ContentModel.PROP_DESCRIPTION, desc);
    this.nodeService.addAspect(zipNodeRef, ContentModel.ASPECT_TITLED, titledProps);
    
    return zipNodeRef;
}
 
Example 20
Source File: ParameterizedItemAbstractBase.java    From alfresco-repository with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Gets the parameter definition display label from the properties file.
 * 
 * @param paramName  the name of the parameter
 * @return             the diaplay label of the parameter
 */
protected String getParamDisplayLabel(String paramName)
{
    return I18NUtil.getMessage(this.name + "." + paramName + "." + DISPLAY_LABEL);
}