Java Code Examples for org.alfresco.model.ContentModel.PROP_NAME

The following are Jave code examples for showing how to use PROP_NAME of the org.alfresco.model.ContentModel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: alfresco-repository   File: VirtualStoreImpl.java   View Source Code Vote up 5 votes
@Override
public Reference getChildByName(Reference reference, QName assocTypeQName, String childName)
            throws VirtualizationException
{
    VirtualFolderDefinition structure = resolveVirtualFolderDefinition(reference);
    VirtualFolderDefinition theChild = structure.findChildByName(childName);

    if (theChild != null)
    {
        return reference.execute(new GetChildByIdMethod(theChild.getId()));
    }
    else
    {
        final VirtualQuery query = structure.getQuery();

        if (query != null)
        {
            PropertyValueConstraint constraint = new PropertyValueConstraint(new FilesFoldersConstraint(BasicConstraint.INSTANCE,
                                                                                                        true,
                                                                                                        true),
                                                                             ContentModel.PROP_NAME,
                                                                             childName,
                                                                             environment
                                                                                         .getNamespacePrefixResolver());
            PagingResults<Reference> result = query.perform(environment,
                                                            constraint,
                                                            null,
                                                            reference);
            List<Reference> page = result.getPage();

            return page == null || page.isEmpty() ? null : page.get(0);
        }
        else
        {
            return null;
        }
    }
}
 
Example 2
Project: alfresco-repository   File: VirtualQueryImpl.java   View Source Code Vote up 4 votes
/**
 * @deprecated will be replaced by
 *             {@link #perform(ActualEnvironment, VirtualQueryConstraint,Reference)}
 *             once complex constrains are implemented
 */
@Override
public PagingResults<Reference> perform(ActualEnvironment environment, boolean files, boolean folders,
            String pattern, Set<QName> searchTypeQNames, Set<QName> ignoreTypeQNames, Set<QName> ignoreAspectQNames,
            List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest, Reference parentReference)
            throws VirtualizationException
{

    if (!files && !folders)
    {
        if (logger.isDebugEnabled())
        {
            logger.debug("Deprecated query  will be skipped due do incompatible types request.");
        }

        return asPagingResults(environment,
                               pagingRequest,
                               new EmptyResultSet(),
                               parentReference);

    }
    else
    {
        VirtualQueryConstraint constraint = BasicConstraint.INSTANCE;
        constraint = new FilesFoldersConstraint(constraint,
                                                files,
                                                folders);
        if(pattern != null){
            constraint = new NamePatternPropertyValueConstraint(constraint,
                                        ContentModel.PROP_NAME,
                                        pattern,
                                        environment.getNamespacePrefixResolver());
        }
        constraint = new IgnoreConstraint(constraint,
                                          ignoreTypeQNames,
                                          ignoreAspectQNames);
        constraint = new PagingRequestConstraint(constraint,
                                                 pagingRequest);
        constraint = new SortConstraint(constraint,
                                        sortProps);

        return perform(environment,
                       constraint,
                       null,
                       parentReference);
    }

}
 
Example 3
Project: alfresco-repository   File: VirtualStoreImpl.java   View Source Code Vote up 4 votes
@Override
public List<Reference> search(Reference reference, String namePattern, boolean fileSearch, boolean folderSearch,
            boolean includeSubFolders) throws VirtualizationException
{
    VirtualFolderDefinition structure = resolveVirtualFolderDefinition(reference);
    List<Reference> result = new LinkedList<Reference>();
    List<Reference> childReferences = createChildReferences(reference,
                                                            structure);
    if (folderSearch)
    {
        result.addAll(childReferences);
    }
    if (includeSubFolders)
    {
        for (Reference childRef : childReferences)
        {
            List<Reference> childResults = search(childRef,
                                                  namePattern,
                                                  fileSearch,
                                                  folderSearch,
                                                  includeSubFolders);
            result.addAll(childResults);
        }
    }
    if (fileSearch)
    {
        final VirtualQuery query = structure.getQuery();
        if (query != null)
        {
            VirtualQueryConstraint vqConstraint = null;
            if (namePattern == null)
            {
                vqConstraint = BasicConstraint.INSTANCE;
            }
            else
            {
                vqConstraint = new NamePatternPropertyValueConstraint(new FilesFoldersConstraint(BasicConstraint.INSTANCE,
                                                                                                 true,
                                                                                                 true),
                                                                      ContentModel.PROP_NAME,
                                                                      namePattern,
                                                                      environment.getNamespacePrefixResolver());
            }
            PagingResults<Reference> queryNodes = query.perform(environment,
                                                                vqConstraint,
                                                                null,
                                                                reference);
            result.addAll(queryNodes.getPage());
        }
    }
    return result;
}
 
Example 4
Project: alfresco-repository   File: ImporterComponent.java   View Source Code Vote up 4 votes
/**
 * Get the child name to import node under
 * 
 * @param context  the node
 * @return  the child name
 */
private QName getChildName(ImportNode context)
{
    QName assocType = getAssocType(context);
    QName childQName = null;
    
    // Determine child name
    String childName = context.getChildName();
    if (childName != null)
    {
        childName = bindPlaceHolder(childName, binding);
        // <Fix for ETHREEOH-2299>
        if (ContentModel.TYPE_PERSON.equals(context.getTypeDefinition().getName())
                && assocType.equals(ContentModel.ASSOC_CHILDREN))
        {
            childName = childName.toLowerCase();
        }
        // </Fix for ETHREEOH-2299>
        String[] qnameComponents = QName.splitPrefixedQName(childName);
        childQName = QName.createQName(qnameComponents[0], QName.createValidLocalName(qnameComponents[1]), namespaceService); 
    }
    else
    {
        Map<QName, Serializable> typeProperties = context.getProperties();
        
        Serializable nameValue = typeProperties.get(ContentModel.PROP_NAME);

        if(nameValue != null && !String.class.isAssignableFrom(nameValue.getClass()))
        {
            throw new  ImporterException("Unable to use childName property: "+ ContentModel.PROP_NAME + " is not a string");  
        }
        
        String name = (String)nameValue;
        
        if (name != null && name.length() > 0)
        {
            name = bindPlaceHolder(name, binding);
            String localName = QName.createValidLocalName(name);
            childQName = QName.createQName(assocType.getNamespaceURI(), localName);
        }
    }
    
    return childQName;
}
 
Example 5
Project: alfresco-repository   File: TransformActionExecuter.java   View Source Code Vote up 4 votes
protected TransformationOptions newTransformationOptions(Action ruleAction, NodeRef sourceNodeRef)
{
    return new TransformationOptions(sourceNodeRef, ContentModel.PROP_NAME, null, ContentModel.PROP_NAME);
}
 
Example 6
Project: alfresco-repository   File: NameProperty.java   View Source Code Vote up 4 votes
public QName getMappedProperty()
{
    return ContentModel.PROP_NAME;
}
 
Example 7
Project: alfresco-repository   File: ContentStreamFileNameProperty.java   View Source Code Vote up 4 votes
public ContentStreamFileNameProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
    super(serviceRegistry, connector, PropertyIds.CONTENT_STREAM_FILE_NAME, ContentModel.PROP_NAME);
}