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

The following examples show how to use org.alfresco.service.cmr.repository.NodeService#getProperties() . 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: 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 2
Source File: AbstractManifestProcessorBase.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Puts information about current <code>childRef</code> and its <code>parentRef</code> into log in TRACE level. Information includes 'name', 'fromRepositoryId', 'aliened' and
 * 'invadedBy' properties. Additionally, collects the same information for children of <code>childRef</code>
 * 
 * @param parentRef - {@link NodeRef} instance of child node
 * @param childRef - {@link NodeRef} instance of parent of the <code>childRef</code>
 * @param nodeService - {@link NodeService} instance to get properties and checking other states
 * @param log - {@link Log} instance to put log for appropriate class
 */
protected void logInvasionHierarchy(NodeRef parentRef, NodeRef childRef, NodeService nodeService, Log log)
{
    Map<QName, Serializable> properties = nodeService.getProperties(childRef);
    Map<QName, Serializable> parentProperties = nodeService.getProperties(parentRef);
    StringBuilder message = new StringBuilder("Information about '").append(properties.get(ContentModel.PROP_NAME)).append("' node:\n    fromRepositoryId: ").append(
            properties.get(TransferModel.PROP_FROM_REPOSITORY_ID)).append("\n").append("    invadedBy: ").append(properties.get(TransferModel.PROP_INVADED_BY)).append("\n")
            .append("    alien: ").append(nodeService.hasAspect(childRef, TransferModel.ASPECT_ALIEN)).append("\n").append("    repositoryId: ").append(
                    properties.get(TransferModel.PROP_REPOSITORY_ID)).append("\n").append("    parent: ").append(parentProperties.get(ContentModel.PROP_NAME)).append("(")
            .append(parentProperties.get(TransferModel.PROP_FROM_REPOSITORY_ID)).append(")").append(parentProperties.get(TransferModel.PROP_INVADED_BY)).append(": ").append(
                    nodeService.hasAspect(parentRef, TransferModel.ASPECT_ALIEN)).append("\n").append("    children:\n");

    List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(childRef);

    if ((null != childAssocs) && !childAssocs.isEmpty())
    {
        for (ChildAssociationRef child : childAssocs)
        {
            properties = nodeService.getProperties(child.getChildRef());
            message.append("        ").append(properties.get(ContentModel.PROP_NAME)).append("(").append(properties.get(TransferModel.PROP_FROM_REPOSITORY_ID)).append(")")
                    .append(properties.get(TransferModel.PROP_INVADED_BY)).append(": ").append(nodeService.hasAspect(child.getChildRef(), TransferModel.ASPECT_ALIEN)).append(
                            "\n");
        }
    }

    log.trace(message.toString());
}
 
Example 3
Source File: NodeStoreInspector.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
   * Output the node 
   * 
   * @param iIndent int
   * @param nodeService NodeService
   * @param nodeRef NodeRef
   * @return String
   */
  private static String outputNode(int iIndent, NodeService nodeService, NodeRef nodeRef)
  {
      StringBuilder builder = new StringBuilder();
      
try
{
       QName nodeType = nodeService.getType(nodeRef);
       builder.
           append(getIndent(iIndent)).
           append("node: ").
           append(nodeRef.getId()).
           append(" (").
           append(nodeType.getLocalName());
	
	Collection<QName> aspects = nodeService.getAspects(nodeRef);
	for (QName aspect : aspects) 
	{
		builder.
			append(", ").
			append(aspect.getLocalName());
	}
	
       builder.append(")\n");        

       Map<QName, Serializable> props = nodeService.getProperties(nodeRef);
       for (QName name : props.keySet())
       {
		String valueAsString = "null";
		Serializable value = props.get(name);
		if (value != null)
		{
			valueAsString = value.toString();
		}
		
           builder.
               append(getIndent(iIndent+1)).
               append("@").
               append(name.getLocalName()).
               append(" = ").
               append(valueAsString).
               append("\n");
           
       }

          Collection<ChildAssociationRef> childAssocRefs = nodeService.getChildAssocs(nodeRef);
          for (ChildAssociationRef childAssocRef : childAssocRefs)
          {
              builder.
                  append(getIndent(iIndent+1)).
                  append("-> ").
                  append(childAssocRef.getQName().toString()).
                  append(" (").
                  append(childAssocRef.getQName().toString()).
                  append(")\n");
              
              builder.append(outputNode(iIndent+2, nodeService, childAssocRef.getChildRef()));
          }

          Collection<AssociationRef> assocRefs = nodeService.getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL);
          for (AssociationRef assocRef : assocRefs)
          {
              builder.
                  append(getIndent(iIndent+1)).
                  append("-> associated to ").
                  append(assocRef.getTargetRef().getId()).
                  append("\n");
          }
}
catch (InvalidNodeRefException invalidNode)
{
	invalidNode.printStackTrace();
}
      
      return builder.toString();
  }
 
Example 4
Source File: ArchivedNodeState.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static ArchivedNodeState create(NodeRef archivedNode, ServiceRegistry serviceRegistry)
{
    ArchivedNodeState result = new ArchivedNodeState();
    
    NodeService nodeService = serviceRegistry.getNodeService();
    Map<QName, Serializable> properties = nodeService.getProperties(archivedNode);

    result.archivedNodeRef = archivedNode;
    result.archivedBy = (String) properties.get(ContentModel.PROP_ARCHIVED_BY);
    result.archivedDate = (Date) properties.get(ContentModel.PROP_ARCHIVED_DATE);
    result.name = (String) properties.get(ContentModel.PROP_NAME);
    result.title = (String) properties.get(ContentModel.PROP_TITLE);
    result.description = (String) properties.get(ContentModel.PROP_DESCRIPTION);
    QName type = nodeService.getType(archivedNode);
    result.isContentType = (type.equals(ContentModel.TYPE_CONTENT) || serviceRegistry.getDictionaryService().isSubClass(type, ContentModel.TYPE_CONTENT));
    result.nodeType = type.toPrefixString(serviceRegistry.getNamespaceService());

    PersonService personService = serviceRegistry.getPersonService();
    if (result.archivedBy != null && personService.personExists(result.archivedBy))
    {
        NodeRef personNodeRef = personService.getPerson(result.archivedBy, false);
        Map<QName, Serializable> personProps = nodeService.getProperties(personNodeRef);
        
        result.firstName = (String) personProps.get(ContentModel.PROP_FIRSTNAME);
        result.lastName = (String) personProps.get(ContentModel.PROP_LASTNAME);
    }
    
    ChildAssociationRef originalParentAssoc = (ChildAssociationRef) properties.get(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC);
    
    if (serviceRegistry.getPermissionService().hasPermission(originalParentAssoc.getParentRef(), PermissionService.READ).equals(AccessStatus.ALLOWED)
            && nodeService.exists(originalParentAssoc.getParentRef()))
    {
       result.displayPath = PathUtil.getDisplayPath(nodeService.getPath(originalParentAssoc.getParentRef()), true);
    }
    else
    {
       result.displayPath = "";
    }
    
    return result;
}