Java Code Examples for org.alfresco.service.cmr.repository.NodeService#hasAspect()

The following examples show how to use org.alfresco.service.cmr.repository.NodeService#hasAspect() . 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: AbstractMimeMessage.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void setPersistedHeaders() throws MessagingException
{
    NodeService nodeService = serviceRegistry.getNodeService();
    if (nodeService.hasAspect(messageFileInfo.getNodeRef(), ImapModel.ASPECT_IMAP_MESSAGE_HEADERS))
    {
        @SuppressWarnings("unchecked")
        List<String> messageHeaders = (List<String>)nodeService.getProperty(messageFileInfo.getNodeRef(), ImapModel.PROP_MESSAGE_HEADERS);
        
        if (messageHeaders == null)
        {
            return;
        }
        
        for (String header : messageHeaders)
        {
            String headerValue = header.substring(header.indexOf(ImapModel.MESSAGE_HEADER_TO_PERSIST_SPLITTER) + 1);
            String headerName  = header.substring(0, header.indexOf(ImapModel.MESSAGE_HEADER_TO_PERSIST_SPLITTER));
            
            setHeader(headerName, headerValue);
        }
    }
}
 
Example 2
Source File: BlogDetails.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Create a BlogDetails object from a node that has the blogDetails aspect applied.
 * 
 * @param nodeService   the node service
 * @param nodeRef       the node reference
 * @return BlogDetails  the blog details 
 */
public static BlogDetails createBlogDetails(NodeService nodeService, NodeRef nodeRef)
{
    // Check for the blog details aspect
    if (nodeService.hasAspect(nodeRef, ASPECT_BLOG_DETAILS) == false)
    {
        throw new BlogIntegrationRuntimeException("Can not create blog details object since node does not have blogDetails aspect.");
    }
    
    // Get the blog details
    Map<QName, Serializable> props = nodeService.getProperties(nodeRef);
    return new BlogDetails(
            (String)props.get(PROP_BLOG_IMPLEMENTATION),
            (String)props.get(PROP_ID),
            (String)props.get(PROP_URL),
            (String)props.get(PROP_USER_NAME),
            (String)props.get(PROP_PASSWORD),
            (String)props.get(PROP_NAME),
            (String)props.get(PROP_DESCRIPTION),
            nodeRef);        
}
 
Example 3
Source File: ContentNetworkFile.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Check if the file is an MS Office document type that needs special processing
 * 
 * @param path String
 * @param sess SrvSession
 * @param nodeService NodeService
 * @param nodeRef NodeRef
 * @return boolean
 */
private static final boolean isMSOfficeSpecialFile( String path, SrvSession sess, NodeService nodeService, NodeRef nodeRef) {
	
	// Check if the file extension indicates a problem MS Office format

	path = path.toLowerCase();
	
	if ( path.endsWith( ".xls") && sess instanceof SMBSrvSession) {
	    
        // Check if the file is versionable
        
        if ( nodeService.hasAspect( nodeRef, ContentModel.ASPECT_VERSIONABLE))
            return true;
	}
	return false;
}
 
Example 4
Source File: ContentNetworkFile.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Check if the file is an OpenOffice document type that needs special processing
 * 
 * @param path String
 * @param sess SrvSession
 * @param nodeService NodeService
 * @param nodeRef NodeRef
 * @return boolean
 */
private static final boolean isOpenOfficeSpecialFile( String path, SrvSession sess, NodeService nodeService, NodeRef nodeRef) {
    
    // Check if the file extension indicates a problem OpenOffice format

    path = path.toLowerCase();
    
    if ( path.endsWith( ".odt") && sess instanceof SMBSrvSession) {
        
        // Check if the file is versionable
        
        if ( nodeService.hasAspect( nodeRef, ContentModel.ASPECT_VERSIONABLE))
            return true;
    }
    return false;
}