Java Code Examples for org.alfresco.service.namespace.QName#resolveToQName()

The following examples show how to use org.alfresco.service.namespace.QName#resolveToQName() . 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: ACLEntryAfterInvocationProvider.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void afterPropertiesSet() throws Exception
{
    if (permissionService == null)
    {
        throw new IllegalArgumentException("There must be a permission service");
    }
    if (nspr == null)
    {
        throw new IllegalArgumentException("There must be a namespace service");
    }
    if (nodeService == null)
    {
        throw new IllegalArgumentException("There must be a node service");
    }
    if(unfilteredFor != null)
    {
        for(String qnameString : unfilteredFor)
        {
            QName qname = QName.resolveToQName(nspr, qnameString);
            unfilteredForClassQNames.add(qname);
        }
    }
}
 
Example 2
Source File: AbstractIndexFilter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void initIgnoringPathsByCriterion(List<String> initDataInString, Set<QName> dataForIgnoringPaths, DefinitionExistChecker dec)
{
    if (null != initDataInString)
    {
        for (String qNameInString : initDataInString)
        {
            if ((null != qNameInString) && !qNameInString.isEmpty())
            {
                try
                {
                    QName qname = QName.resolveToQName(namespaceService, qNameInString);
                    if (dec.isDefinitionExists(qname))
                    {
                        dataForIgnoringPaths.add(qname);
                    }
                }
                catch (InvalidQNameException e)
                {
                    // Just ignore
                }
            }
        }
    }
}
 
Example 3
Source File: SelectorPropertyContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
private void afterPropertiesSet_validateSelectors()
{
    PropertyCheck.mandatory(this, "selectorClassName", this.selectorClassName);
    PropertyCheck.mandatory(this, "selectorPropertyName", this.selectorPropertyName);

    this.selectorClassQName = QName.resolveToQName(this.namespaceService, this.selectorClassName);
    this.selectorPropertyQName = QName.resolveToQName(this.namespaceService, this.selectorPropertyName);
    PropertyCheck.mandatory(this, "selectorClassQName", this.selectorClassQName);
    PropertyCheck.mandatory(this, "selectorPropertyQName", this.selectorPropertyQName);

    final ClassDefinition classDefinition = this.dictionaryService.getClass(this.selectorClassQName);
    if (classDefinition == null)
    {
        throw new IllegalStateException(this.selectorClassName + " is not a valid content model class");
    }

    final PropertyDefinition propertyDefinition = this.dictionaryService.getProperty(this.selectorPropertyQName);
    if (propertyDefinition == null || !DataTypeDefinition.TEXT.equals(propertyDefinition.getDataType().getName())
            || propertyDefinition.isMultiValued())
    {
        throw new IllegalStateException(
                this.selectorPropertyName + " is not a valid content model property of type single-valued d:text");
    }
}
 
Example 4
Source File: PropertyRestrictableRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
private void afterPropertiesSet_setupRouteContentProperties()
{
    if (this.routeContentPropertyNames != null && !this.routeContentPropertyNames.isEmpty())
    {
        this.routeContentPropertyQNames = new HashSet<>();
        for (final String routePropertyName : this.routeContentPropertyNames)
        {
            final QName routePropertyQName = QName.resolveToQName(this.namespaceService, routePropertyName);
            ParameterCheck.mandatory("routePropertyQName", routePropertyQName);

            final PropertyDefinition contentPropertyDefinition = this.dictionaryService.getProperty(routePropertyQName);
            if (contentPropertyDefinition == null
                    || !DataTypeDefinition.CONTENT.equals(contentPropertyDefinition.getDataType().getName()))
            {
                throw new IllegalStateException(routePropertyName + " is not a valid content model property of type d:content");
            }
            this.routeContentPropertyQNames.add(routePropertyQName);
        }
    }
}
 
Example 5
Source File: TypeRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
private void afterPropertiesSet_setupChangePolicies()
{
    if (this.moveStoresOnChangeOptionPropertyName != null)
    {
        this.moveStoresOnChangeOptionPropertyQName = QName.resolveToQName(this.namespaceService,
                this.moveStoresOnChangeOptionPropertyName);
        PropertyCheck.mandatory(this, "moveStoresOnChangeOptionPropertyQName", this.moveStoresOnChangeOptionPropertyQName);

        final PropertyDefinition moveStoresOnChangeOptionPropertyDefinition = this.dictionaryService
                .getProperty(this.moveStoresOnChangeOptionPropertyQName);
        if (moveStoresOnChangeOptionPropertyDefinition == null
                || !DataTypeDefinition.BOOLEAN.equals(moveStoresOnChangeOptionPropertyDefinition.getDataType().getName())
                || moveStoresOnChangeOptionPropertyDefinition.isMultiValued())
        {
            throw new IllegalStateException(this.moveStoresOnChangeOptionPropertyName
                    + " is not a valid content model property of type single-valued d:boolean");
        }
    }

    if (this.moveStoresOnChange || this.moveStoresOnChangeOptionPropertyQName != null)
    {
        this.policyComponent.bindClassBehaviour(OnSetNodeTypePolicy.QNAME, ContentModel.TYPE_BASE,
                new JavaBehaviour(this, "onSetNodeType", NotificationFrequency.EVERY_EVENT));
    }
}
 
Example 6
Source File: CommonFacadingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
private void afterPropertiesSet_setupHandleContentProperties()
{
    if (this.handleContentPropertyNames != null && !this.handleContentPropertyNames.isEmpty())
    {
        this.handleContentPropertyQNames = new HashSet<>();
        for (final String facadePropertyName : this.handleContentPropertyNames)
        {
            final QName routePropertyQName = QName.resolveToQName(this.namespaceService, facadePropertyName);
            ParameterCheck.mandatory("routePropertyQName", routePropertyQName);

            final PropertyDefinition contentPropertyDefinition = this.dictionaryService.getProperty(routePropertyQName);
            if (contentPropertyDefinition == null
                    || !DataTypeDefinition.CONTENT.equals(contentPropertyDefinition.getDataType().getName()))
            {
                throw new IllegalStateException(facadePropertyName + " is not a valid content model property of type d:content");
            }
            this.handleContentPropertyQNames.add(routePropertyQName);
        }
    }
}
 
Example 7
Source File: ACLEntryVoter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void afterPropertiesSet() throws Exception
{
    if (permissionService == null)
    {
        throw new IllegalArgumentException("There must be a permission service");
    }
    if (nspr == null)
    {
        throw new IllegalArgumentException("There must be a namespace service");
    }
    if (nodeService == null)
    {
        throw new IllegalArgumentException("There must be a node service");
    }
    if (authorityService == null)
    {
        throw new IllegalArgumentException("There must be an authority service");
    }
    if(abstainFor != null)
    {
        for(String qnameString : abstainFor)
        {
            QName qname = QName.resolveToQName(nspr, qnameString);
            abstainForClassQNames.add(qname);
        }
    }

}
 
Example 8
Source File: ContentAwareScriptableQNameMap.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Object get(Object name)
{
    Object value = super.get(name);
    
    if (value == null)
    {
       // convert the key to a qname and look up the data-type for the property
       QName qname = QName.resolveToQName(getResolver(), name.toString());
       PropertyDefinition propDef = this.services.getDictionaryService().getProperty(qname);
       if (propDef != null && DataTypeDefinition.CONTENT.equals(propDef.getDataType().getName()))
       {
           // found a valid cm:content property that is not initialised
           String mimetype = null;
           if (qname.equals(ContentModel.PROP_CONTENT)) 
           {
               String fileName = (String)get("cm:name");
               if (fileName != null)
               {
                   // We don't have any content, so just use the filename when
                   //  trying to guess the mimetype for this
                   mimetype = this.services.getMimetypeService().guessMimetype(fileName);
               }
           }
           ContentData cdata = new ContentData(null, mimetype, 0L, "UTF-8");
           // create the JavaScript API object we need
           value = factory.new ScriptContentData(cdata, qname);
           // and store it so it is available to the API user
           put(name, value);
       }
    }
    
    return value;
}
 
Example 9
Source File: SolrInformationServer.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void initSkippingDescendantDocs(Properties p, Set<QName> dataForSkippingDescendantDocs, String propPrefixParent,
                                        String skipByField, DefinitionExistChecker dec)
{
    int i = 0;
    for (String key = new StringBuilder(propPrefixParent).append(i).toString(); p.containsKey(key);
         key = new StringBuilder(propPrefixParent).append(++i).toString())
    {
        String qNameInString = p.getProperty(key);
        if ((null != qNameInString) && !qNameInString.isEmpty())
        {
            QName qName = QName.resolveToQName(dataModel.getNamespaceDAO(), qNameInString);

            LOGGER.warning("QName was not found for {}", qNameInString);

            if (dec.isDefinitionExists(qName))
            {
                dataForSkippingDescendantDocs.add(qName);
            }
        }
    }

    if (null == skippingDocsQueryString)
    {
        skippingDocsQueryString = this.cloud.getQuery(skipByField, OR, dataForSkippingDescendantDocs);
    }
    else
    {
        skippingDocsQueryString += OR + this.cloud.getQuery(skipByField, OR, dataForSkippingDescendantDocs);
    }
}
 
Example 10
Source File: SelectorPropertyContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
private void afterPropertiesSet_setupChangePolicies()
{
    if (this.moveStoresOnChangeOptionPropertyName != null)
    {
        this.moveStoresOnChangeOptionPropertyQName = QName.resolveToQName(this.namespaceService,
                this.moveStoresOnChangeOptionPropertyName);
        PropertyCheck.mandatory(this, "moveStoresOnChangeOptionPropertyQName", this.moveStoresOnChangeOptionPropertyQName);

        final PropertyDefinition moveStoresOnChangeOptionPropertyDefinition = this.dictionaryService
                .getProperty(this.moveStoresOnChangeOptionPropertyQName);
        if (moveStoresOnChangeOptionPropertyDefinition == null
                || !DataTypeDefinition.BOOLEAN.equals(moveStoresOnChangeOptionPropertyDefinition.getDataType().getName())
                || moveStoresOnChangeOptionPropertyDefinition.isMultiValued())
        {
            throw new IllegalStateException(this.moveStoresOnChangeOptionPropertyName
                    + " is not a valid content model property of type single-valued d:boolean");
        }
    }

    if (this.moveStoresOnChange || this.moveStoresOnChangeOptionPropertyQName != null)
    {
        this.policyComponent.bindClassBehaviour(OnUpdatePropertiesPolicy.QNAME, this.selectorClassQName,
                new JavaBehaviour(this, "onUpdateProperties", NotificationFrequency.EVERY_EVENT));

        final ClassDefinition classDefinition = this.dictionaryService.getClass(this.selectorClassQName);
        if (classDefinition.isAspect())
        {
            this.policyComponent.bindClassBehaviour(BeforeRemoveAspectPolicy.QNAME, this.selectorClassQName,
                    new JavaBehaviour(this, "beforeRemoveAspect", NotificationFrequency.EVERY_EVENT));
            this.policyComponent.bindClassBehaviour(OnAddAspectPolicy.QNAME, this.selectorClassQName,
                    new JavaBehaviour(this, "onAddAspect", NotificationFrequency.EVERY_EVENT));
        }
    }
}
 
Example 11
Source File: SiteRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
protected void afterPropertiesSet_setupChangePolicies()
{
    if (this.moveStoresOnNodeMoveOrCopyOverridePropertyName != null)
    {
        this.moveStoresOnNodeMoveOrCopyOverridePropertyQName = QName.resolveToQName(this.namespaceService,
                this.moveStoresOnNodeMoveOrCopyOverridePropertyName);
        PropertyCheck.mandatory(this, "moveStoresOnNodeMoveOrCopyOverridePropertyQName",
                this.moveStoresOnNodeMoveOrCopyOverridePropertyQName);

        final PropertyDefinition moveStoresOnChangeOptionPropertyDefinition = this.dictionaryService
                .getProperty(this.moveStoresOnNodeMoveOrCopyOverridePropertyQName);
        if (moveStoresOnChangeOptionPropertyDefinition == null
                || !DataTypeDefinition.BOOLEAN.equals(moveStoresOnChangeOptionPropertyDefinition.getDataType().getName())
                || moveStoresOnChangeOptionPropertyDefinition.isMultiValued())
        {
            throw new IllegalStateException(this.moveStoresOnNodeMoveOrCopyOverridePropertyName
                    + " is not a valid content model property of type single-valued d:boolean");
        }
    }

    if (this.moveStoresOnNodeMoveOrCopy || this.moveStoresOnNodeMoveOrCopyOverridePropertyQName != null)
    {
        PropertyCheck.mandatory(this, "policyComponent", this.policyComponent);
        PropertyCheck.mandatory(this, "dictionaryService", this.dictionaryService);
        PropertyCheck.mandatory(this, "nodeService", this.nodeService);

        this.policyComponent.bindClassBehaviour(OnCopyCompletePolicy.QNAME, ContentModel.TYPE_BASE,
                new JavaBehaviour(this, "onCopyComplete", NotificationFrequency.EVERY_EVENT));
        this.policyComponent.bindClassBehaviour(OnMoveNodePolicy.QNAME, ContentModel.TYPE_BASE,
                new JavaBehaviour(this, "onMoveNode", NotificationFrequency.EVERY_EVENT));
    }
}
 
Example 12
Source File: SiteRoutingFileContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
protected void afterPropertiesSet_setupChangePolicies()
{
    if (this.moveStoresOnNodeMoveOrCopyOverridePropertyName != null)
    {
        this.moveStoresOnNodeMoveOrCopyOverridePropertyQName = QName.resolveToQName(this.namespaceService,
                this.moveStoresOnNodeMoveOrCopyOverridePropertyName);
        PropertyCheck.mandatory(this, "moveStoresOnNodeMoveOrCopyOverridePropertyQName",
                this.moveStoresOnNodeMoveOrCopyOverridePropertyQName);

        final PropertyDefinition moveStoresOnChangeOptionPropertyDefinition = this.dictionaryService
                .getProperty(this.moveStoresOnNodeMoveOrCopyOverridePropertyQName);
        if (moveStoresOnChangeOptionPropertyDefinition == null
                || !DataTypeDefinition.BOOLEAN.equals(moveStoresOnChangeOptionPropertyDefinition.getDataType().getName())
                || moveStoresOnChangeOptionPropertyDefinition.isMultiValued())
        {
            throw new IllegalStateException(this.moveStoresOnNodeMoveOrCopyOverridePropertyName
                    + " is not a valid content model property of type single-valued d:boolean");
        }
    }

    if (this.moveStoresOnNodeMoveOrCopy || this.moveStoresOnNodeMoveOrCopyOverridePropertyQName != null)
    {
        this.policyComponent.bindClassBehaviour(OnCopyCompletePolicy.QNAME, ContentModel.TYPE_BASE,
                new JavaBehaviour(this, "onCopyComplete", NotificationFrequency.EVERY_EVENT));
        this.policyComponent.bindClassBehaviour(OnMoveNodePolicy.QNAME, ContentModel.TYPE_BASE,
                new JavaBehaviour(this, "onMoveNode", NotificationFrequency.EVERY_EVENT));
    }
}
 
Example 13
Source File: ArchiveFileContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
public void afterPropertiesSet()
{
    super.afterPropertiesSet();

    // if we ever support more variants, OR this
    if (this.retentionViaAccessTime)
    {
        PropertyCheck.mandatory(this, "namespaceService", this.namespaceService);
        PropertyCheck.mandatory(this, "dictionaryService", this.dictionaryService);
        PropertyCheck.mandatory(this, "nodeService", this.nodeService);
        PropertyCheck.mandatory(this, "retentionDatePropertyName", this.retentionDatePropertyName);

        this.retentionDatePropertyQName = QName.resolveToQName(this.namespaceService, this.retentionDatePropertyName);
        if (this.retentionDatePropertyQName == null)
        {
            throw new IllegalStateException(this.retentionDatePropertyName + " cannot be resolved to a qualified name");
        }

        final PropertyDefinition property = this.dictionaryService.getProperty(this.retentionDatePropertyQName);
        if (property == null || !(DataTypeDefinition.DATE.equals(property.getDataType().getName())
                || DataTypeDefinition.DATETIME.equals(property.getDataType().getName())))
        {
            throw new IllegalStateException(
                    this.retentionDatePropertyName + " is not a date/datetime property defined in the data model");
        }

        if (this.prolongRetentionOnPropertyChange)
        {
            PropertyCheck.mandatory(this, "policyComponent", this.policyComponent);

            this.policyComponent.bindClassBehaviour(OnUpdatePropertiesPolicy.QNAME, property.getContainerClass().getName(),
                    new JavaBehaviour(this, "onUpdateProperties", NotificationFrequency.EVERY_EVENT));
        }
    }

    PropertyCheck.mandatory(this, "digestAlgorithm", this.digestAlgorithm);
}
 
Example 14
Source File: XMLTransferRequsiteReader.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Start Element
 */
public void startElement(String uri, String localName, String prefixName, Attributes atts)
throws SAXException
{
    QName elementQName = QName.resolveToQName(this, prefixName);
    
    HashMap<String, String> namespace = new HashMap<String, String>();
    namespaces.addFirst(namespace);
            
    /**
     * Look for any namespace attributes
     */
    for(int i = 0; i < atts.getLength(); i++)
    {
        QName attributeQName = QName.resolveToQName(this, atts.getQName(i));
        if(attributeQName.getNamespaceURI().equals(XMLNS_URI))
        {
            namespace.put(attributeQName.getLocalName(), atts.getValue(i));
        }
    }
    
    if(elementQName == null)
    {
        return;
    }
    
    if(elementQName.getNamespaceURI().equals(REQUSITE_URI));
    {
        // This is one of the transfer manifest elements
        String elementName = elementQName.getLocalName();
        
        // Simple and stupid parser for now
        if(elementName.equals(RequsiteModel.LOCALNAME_TRANSFER_REQUSITE))
        {
            // Good we got this
        }
        else if(elementName.equals(RequsiteModel.LOCALNAME_ELEMENT_CONTENT))
        {
            NodeRef nodeRef = new NodeRef(atts.getValue("", "nodeRef"));
            QName qname = QName.createQName(atts.getValue("", "qname"));
            String name = atts.getValue("", "name");
            
            processor.missingContent(nodeRef, qname, name);
        }
    } // if transfer URI       
}