Java Code Examples for org.apache.chemistry.opencmis.commons.enums.IncludeRelationships#NONE

The following examples show how to use org.apache.chemistry.opencmis.commons.enums.IncludeRelationships#NONE . 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: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Returns {@code IncludeRelationships.NONE} if {@code value} is
 * {@code null}.
 */
protected IncludeRelationships getDefault(IncludeRelationships value) {
    if (value == null) {
        return IncludeRelationships.NONE;
    }

    return value;
}
 
Example 2
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private ObjectData createCMISObjectImpl(final CMISNodeInfo info, Properties nodeProps, String filter,
        boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
        boolean includePolicyIds, boolean includeAcl)
{
    final ObjectDataImpl result = new ObjectDataImpl();

    // set allowable actions
    if (includeAllowableActions)
    {
        result.setAllowableActions(getAllowableActions(info));
    }

    // set policy ids
    if (includePolicyIds)
    {
        result.setPolicyIds(new PolicyIdListImpl());
    }

    if (info.isRelationship())
    {
        // set properties
        result.setProperties(getAssocProperties(info, filter));

        // set ACL
        if (includeAcl)
        {
            // association have no ACL - return an empty list of ACEs
            result.setAcl(new AccessControlListImpl((List<Ace>) Collections.EMPTY_LIST));
            result.setIsExactAcl(Boolean.FALSE);
        }
    }
    else
    {
        // set properties
        result.setProperties(nodeProps);

        // set relationships
        if (includeRelationships != IncludeRelationships.NONE)
        {
            result.setRelationships(getRelationships(info.getNodeRef(), includeRelationships));
        }

        // set renditions
        if (!RENDITION_NONE.equals(renditionFilter))
        {
            List<RenditionData> renditions = getRenditions(info.getNodeRef(), renditionFilter, null, null);
            if ((renditions != null) && (!renditions.isEmpty()))
            {
                result.setRenditions(renditions);
            }
            else
            {
            	result.setRenditions(Collections.EMPTY_LIST);
            }
        }

        // set ACL
        if (includeAcl)
        {
        	AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
        	{
	@Override
	public Void doWork() throws Exception
	{
	    Acl acl = getACL(info.getCurrentNodeNodeRef(), false);
              if (acl != null)
              {
	        result.setAcl(acl);
	        result.setIsExactAcl(acl.isExact());
              }
		return null;
	}
        	});
        }

        // add aspects
        List<CmisExtensionElement> extensions = getAspectExtensions(info, filter, result.getProperties()
                .getProperties().keySet());

        if (!extensions.isEmpty())
        {
            result.getProperties().setExtensions(
                    Collections.singletonList((CmisExtensionElement) new CmisExtensionElementImpl(
                            ALFRESCO_EXTENSION_NAMESPACE, ASPECTS, null, extensions)));
        }
    }
    return result;
}
 
Example 3
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public IncludeRelationships getRequestParameterIncludeRelationships()
{
    QueryStringHttpServletRequestWrapper httpServletRequest = getHttpServletRequest();
    String value = httpServletRequest == null ? null : httpServletRequest.getParameter("includeRelationships");
    return value == null ? IncludeRelationships.NONE : CmisEnumHelper.fromValue(value, IncludeRelationships.class);
}
 
Example 4
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void setRelaionshipsToObjectInfo(ObjectData object, ObjectInfoImpl info)
{
    info.setRelationshipSourceIds(null);
    info.setRelationshipTargetIds(null);

    IncludeRelationships includeRelationships = getRequestParameterIncludeRelationships();
    if (includeRelationships != IncludeRelationships.NONE)
    {
        List<ObjectData> relationships = object.getRelationships();
        if (relationships != null && relationships.size() > 0)
        {
            List<String> sourceIds = new ArrayList<String>();
            List<String> targetIds = new ArrayList<String>();
            for (ObjectData relationship : relationships)
            {
                String sourceId = getIdProperty(relationship, PropertyIds.SOURCE_ID);
                String targetId = getIdProperty(relationship, PropertyIds.TARGET_ID);
                if (object.getId().equals(sourceId))
                {
                    sourceIds.add(relationship.getId());
                }
                if (object.getId().equals(targetId))
                {
                    targetIds.add(relationship.getId());
                }
            }
            if (sourceIds.size() > 0 &&
                (includeRelationships == IncludeRelationships.SOURCE ||
                 includeRelationships == IncludeRelationships.BOTH))
            {
                info.setRelationshipSourceIds(sourceIds);
            }
            if (targetIds.size() > 0 &&
                (includeRelationships == IncludeRelationships.TARGET ||
                 includeRelationships == IncludeRelationships.BOTH))
            {
                info.setRelationshipTargetIds(targetIds);
            }
        }
    }
}