org.alfresco.util.ISO9075 Java Examples

The following examples show how to use org.alfresco.util.ISO9075. 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: PathHelper.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Converts a String representation of a path to a Path
 * 
 * e.g "/{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/application/1.0}dictionary/{http://www.alfresco.org/model/application/1.0}transfers/{http://www.alfresco.org/model/content/1.0}default/{http://www.alfresco.org/model/transfer/1.0}snapshotMe";
 * @param value the string representation of the path.
 * @return Path 
 */
public static Path stringToPath(String value)
{
    Path path = new Path();
    
    // pattern for QName e.g. /{stuff}stuff
    
    Pattern pattern = Pattern.compile("/\\{[a-zA-Z:./0-9]*\\}[^/]*");
    Matcher matcher = pattern.matcher(value);
    
    // This is the root node
    path.append(new SimplePathElement("/"));
           
    while ( matcher.find() )
    {
        String group = matcher.group();
        final String val = ISO9075.decode(group.substring(1));
        path.append(new SimplePathElement(val));
    }
    
    return path;
}
 
Example #2
Source File: NodeInfoFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private String getName(QName qName)
{
    String name = null;
    
    try
    {
        name = qName.toPrefixString(namespaceService);
    }
    catch (NamespaceException e)
    {
        name = qName.toPrefixString();
    }
    name = ISO9075.decode(name);
    
    return name;
}
 
Example #3
Source File: ForumTopicsFilteredGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Build the search query from the passed in parameters and SEARCH_QUERY constant
 * 
 * @param site SiteInfo
 * @param author String
 * @param daysAgo int
 * @return Pair with the query string in first and query language in second
 */
protected Pair<String, String> getSearchQuery(SiteInfo site, String author, int daysAgo)
{
   String search = String.format(SEARCH_QUERY,
         (site != null ? "cm:" + ISO9075.encode(site.getShortName()) : "*"),
         getDateXDaysAgo(daysAgo)
   );

   // If author equals 'mine' add cm:creator to the search query otherwise leave out
   if(author.equals(DEFAULT_TOPIC_AUTHOR))
   {
      search += " AND @cm:creator:\"" + AuthenticationUtil.getFullyAuthenticatedUser() + "\"";
   }

   // Add the query string and language to the returned results
   Pair<String, String> searchQuery = new Pair<String, String>(search, SearchService.LANGUAGE_FTS_ALFRESCO);

   return searchQuery;
}
 
Example #4
Source File: RepoStore.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Helper to encode the elements of a path to be used as a Lucene PATH statement
 * using the ISO9075 encoding. Note that leading and trailing '/' elements will NOT
 * be preserved.
 * 
 * @param path  Path to encode, elements separated by '/'
 * 
 * @return the encoded path, a minimum of the empty string will be returned
 */
public static String encodePathISO9075(String path)
{
    if (path == null || path.length() == 0)
    {
        return "";
    }
    StringBuilder result = new StringBuilder(path.length() + 16);
    for (StringTokenizer t = new StringTokenizer(path, "/"); t.hasMoreTokens(); /**/)
    {
        result.append(ISO9075.encode(t.nextToken()));
        if (t.hasMoreTokens())
        {
            result.append('/');
        }
    }
    return result.toString();
}
 
Example #5
Source File: TaggingServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @see org.alfresco.service.cmr.tagging.TaggingService#findTaggedNodes(StoreRef, java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
 */
public List<NodeRef> findTaggedNodes(StoreRef storeRef, String tag, NodeRef nodeRef)
{
    // Lower the case of the tag
    tag = tag.toLowerCase();
    
    // Get path
    Path nodePath = this.nodeService.getPath(nodeRef);
    String pathString = nodePath.toPrefixString(this.namespaceService);
    ResultSet resultSet = null;
    
    try
    {
        // Do query
        resultSet = this.searchService.query(
            storeRef, 
            SearchService.LANGUAGE_LUCENE, 
            "+PATH:\"" + pathString + "//*\" +PATH:\"/cm:taggable/cm:" + ISO9075.encode(tag) + "/member\"");
        List<NodeRef> nodeRefs = resultSet.getNodeRefs();
        return nodeRefs;
    }
    finally
    {
        if(resultSet != null) {resultSet.close();}
    }
}
 
Example #6
Source File: DocumentNavigator.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String getAttributeQName(Object o)
{
    QName qName = ((Property) o).qname;
    String escapedLocalName = ISO9075.encode(qName.getLocalName());
    if (EqualsHelper.nullSafeEquals(escapedLocalName, qName.getLocalName()))        
    {
        return qName.toString();
    }
    else
    {
        return QName.createQName(qName.getNamespaceURI(), escapedLocalName).toString();
    }
}
 
Example #7
Source File: Path.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
public AttributeElement(String attribute)
{
    String qNameStr = null;
    int idx = attribute.indexOf("[");
    if(idx != -1)
    {
        String positionStr = attribute.substring(idx + 1, attribute.length() - 1);
        position = Integer.parseInt(positionStr);
        qNameStr = attribute.substring(1, idx);
    }
    else
    {
        qNameStr = attribute.substring(1);
    }
    this.attribute = ISO9075.parseXPathName(qNameStr);
}
 
Example #8
Source File: DocumentNavigator.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String getElementQName(Object o)
{
    QName qName = ((ChildAssociationRef) o).getQName();
    if(qName == null)
    {
        return "";
    }
    String escapedLocalName = ISO9075.encode(qName.getLocalName());
    if (EqualsHelper.nullSafeEquals(escapedLocalName, qName.getLocalName()))        
    {
        return qName.toString();
    }
    else
    {
        return QName.createQName(qName.getNamespaceURI(), escapedLocalName).toString();
    }
}
 
Example #9
Source File: DocumentNavigator.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Iterator getChildAxisIterator(Object contextNode, String localName, String namespacePrefix, String namespaceURI) throws UnsupportedAxisException
{
    // decode the localname
    localName = ISO9075.decode(localName);
    
    // MNT-10730
    if (localName != null && (localName.equalsIgnoreCase("true") || localName.equalsIgnoreCase("false")))
    {
        return Collections.singletonList(new Boolean(Boolean.parseBoolean(localName))).iterator();
    }
    
    ChildAssociationRef assocRef = (ChildAssociationRef) contextNode;
    NodeRef childRef = assocRef.getChildRef();
    QName qName = QName.createQName(namespaceURI, localName);
    List<? extends ChildAssociationRef> list = null;
    list = nodeService.getChildAssocs(childRef, RegexQNamePattern.MATCH_ALL, qName);
    // done
    return list.iterator();
}
 
Example #10
Source File: LuceneCategoryServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private String buildXPath(Path path)
{
    StringBuilder pathBuffer = new StringBuilder(64);
    for (Iterator<Path.Element> elit = path.iterator(); elit.hasNext(); /**/)
    {
        Path.Element element = elit.next();
        if (!(element instanceof Path.ChildAssocElement))
        {
            throw new IndexerException("Confused path: " + path);
        }
        Path.ChildAssocElement cae = (Path.ChildAssocElement) element;
        if (cae.getRef().getParentRef() != null)
        {
            pathBuffer.append("/");
            pathBuffer.append(getPrefix(cae.getRef().getQName().getNamespaceURI()));
            pathBuffer.append(ISO9075.encode(cae.getRef().getQName().getLocalName()));
        }
    }
    return pathBuffer.toString();
}
 
Example #11
Source File: LuceneCategoryServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Set<NodeRef> getClassificationNodes(StoreRef storeRef, QName qname)
{
    ResultSet resultSet = null;
    try
    {
        resultSet = indexerAndSearcher.getSearcher(storeRef, false).query(storeRef, "lucene",
                "PATH:\"/" + getPrefix(qname.getNamespaceURI()) + ISO9075.encode(qname.getLocalName()) + "\"", null);
        
        Set<NodeRef> nodeRefs = new HashSet<NodeRef>(resultSet.length());
        for (ResultSetRow row : resultSet)
        {
            nodeRefs.add(row.getNodeRef());
        }
        
        return nodeRefs;
    }
    finally
    {
        if (resultSet != null)
        {
            resultSet.close();
        }
    }
}
 
Example #12
Source File: Path.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
private String createElementString(NamespacePrefixResolver resolver)
{
    StringBuilder sb = new StringBuilder(32);
    if (ref.getParentRef() == null)
    {
        sb.append("/");
    }
    else
    {
        // a parent is present
        sb.append(resolver == null ? ISO9075.getXPathName(ref.getQName()) : ISO9075.getXPathName(ref.getQName(), resolver));
    }
    if (ref.getNthSibling() > -1)
    {
        sb.append("[").append(ref.getNthSibling()).append("]");
    }
    return sb.toString();
}
 
Example #13
Source File: SiteTitleDisplayHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public FacetLabel getDisplayLabel(String value)
{
    // Solr returns the site short name encoded
    value = ISO9075.decode(value);
    String title = null;

    if (nonSiteLocationsLabels.containsKey(value))
    {
        title = nonSiteLocationsLabels.get(value);
    }
    else
    {
        SiteService siteService = serviceRegistry.getSiteService();
        SiteInfo siteInfo = siteService.getSite(value);
        title = siteInfo != null ? siteInfo.getTitle() : value;
    }

    return new FacetLabel(value, title, -1);
}
 
Example #14
Source File: TaggingServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @see org.alfresco.service.cmr.tagging.TaggingService#findTaggedNodes(StoreRef, java.lang.String)
 */
public List<NodeRef> findTaggedNodes(StoreRef storeRef, String tag)
{
    // Lower the case of the tag
    tag = tag.toLowerCase();
    ResultSet resultSet= null;
    
    try
    {
        // Do the search for nodes
        resultSet = this.searchService.query(
            storeRef, 
            SearchService.LANGUAGE_LUCENE, 
            "+PATH:\"/cm:taggable/cm:" + ISO9075.encode(tag) + "/member\"");
        List<NodeRef> nodeRefs = resultSet.getNodeRefs();
        return nodeRefs;
    }
    finally
    {
        if(resultSet != null) {resultSet.close();}
    }
}
 
Example #15
Source File: ScriptNode.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Returns the short name of the site this node is located within. If the 
 * node is not located within a site null is returned.
 * 
 * @return The short name of the site this node is located within, null
 *         if the node is not located within a site.
 */
public String getSiteShortName()
{
    if (!this.siteNameResolved)
    {
        this.siteNameResolved = true;
        
        Path path = this.services.getNodeService().getPath(getNodeRef());
        
        if (logger.isDebugEnabled())
            logger.debug("Determing if node is within a site using path: " + path);
        
        for (int i = 0; i < path.size(); i++)
        {
            if ("st:sites".equals(path.get(i).getPrefixedString(this.services.getNamespaceService())))
            {
                // we now know the node is in a site, find the next element in the array (if there is one)
                if ((i+1) < path.size())
                {
                    // get the site name
                    Path.Element siteName = path.get(i+1);
                 
                    // remove the "cm:" prefix and add to result object
                    this.siteName = ISO9075.decode(siteName.getPrefixedString(
                                this.services.getNamespaceService()).substring(3));
                }
              
                break;
            }
        }
    }
    
    if (logger.isDebugEnabled())
    {
        logger.debug(this.siteName != null ? 
                    "Node is in the site named \"" + this.siteName + "\"" : "Node is not in a site");
    }
    
    return this.siteName;
}
 
Example #16
Source File: ViewXMLExporter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void endProperty(NodeRef nodeRef, QName property)
{
    try
    {
        QName encodedProperty = QName.createQName(property.getNamespaceURI(), ISO9075.encode(property.getLocalName()));
        contentHandler.endElement(encodedProperty.getNamespaceURI(), encodedProperty.getLocalName(), toPrefixString(encodedProperty));
    }
    catch (SAXException e)
    {
        throw new ExporterException("Failed to process end property event - nodeRef " + nodeRef + "; property " + toPrefixString(property), e);
    }
}
 
Example #17
Source File: BaseContentNode.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Returns the short name of the site this node is located within. If the 
 * node is not located within a site null is returned.
 * 
 * @return The short name of the site this node is located within, null
 *         if the node is not located within a site.
 */
public String getSiteShortName()
{
    if (!this.siteNameResolved)
    {
        this.siteNameResolved = true;
        
        Path path = this.services.getNodeService().getPath(getNodeRef());
        
        for (int i = 0; i < path.size(); i++)
        {
            if ("st:sites".equals(path.get(i).getPrefixedString(this.services.getNamespaceService())))
            {
                // we now know the node is in a site, find the next element in the array (if there is one)
                if ((i+1) < path.size())
                {
                    // get the site name
                    Path.Element siteName = path.get(i+1);
                 
                    // remove the "cm:" prefix and add to result object
                    this.siteName = ISO9075.decode(siteName.getPrefixedString(
                                this.services.getNamespaceService()).substring(3));
                }
              
                break;
            }
        }
    }
    
    return this.siteName;
}
 
Example #18
Source File: Path.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
private String createElementString(NamespacePrefixResolver resolver)
{
    StringBuilder sb = new StringBuilder(32);
    sb.append("@").append(resolver == null ? ISO9075.getXPathName(attribute) : ISO9075.getXPathName(attribute, resolver));
    
    if (position > -1)
    {
        sb.append("[").append(position).append("]");
    }
    return sb.toString();
}
 
Example #19
Source File: WebDAV.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Make a unique lock token
 * 
 * @param lockNode NodeRef
 * @param owner String
 * @return String
 */
public static final String makeLockToken(NodeRef lockNode, String owner)
{
    StringBuilder str = new StringBuilder();
    
    str.append(WebDAV.OPAQUE_LOCK_TOKEN);
    str.append(lockNode.getId());
    str.append(LOCK_TOKEN_SEPERATOR);
    str.append(ISO9075.encode(owner));
    
    return str.toString();
}
 
Example #20
Source File: ViewXMLExporter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void startProperty(NodeRef nodeRef, QName property)
{
    try
    {
        QName encodedProperty = QName.createQName(property.getNamespaceURI(), ISO9075.encode(property.getLocalName()));
        contentHandler.startElement(encodedProperty.getNamespaceURI(), encodedProperty.getLocalName(), toPrefixString(encodedProperty), EMPTY_ATTRIBUTES);
    }
    catch (SAXException e)
    {
        throw new ExporterException("Failed to process start property event - nodeRef " + nodeRef + "; property " + toPrefixString(property), e);
    }
}
 
Example #21
Source File: NodeServiceXPath.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Object evaluate(List nodes, Object obj, Object patternObj, Object includeFtsObj, Navigator nav)
{
    Object attribute = null;
    if (obj instanceof List)
    {
        List list = (List) obj;
        if (list.isEmpty())
        {
            return false;
        }
        // do not recurse: only first list should unwrap
        attribute = list.get(0);
    }
    if ((attribute == null) || !nav.isAttribute(attribute))
    {
        return false;
    }
    if (nodes.size() != 1)
    {
        return false;
    }
    if (!nav.isElement(nodes.get(0)))
    {
        return false;
    }
    ChildAssociationRef car = (ChildAssociationRef) nodes.get(0);
    String pattern = StringFunction.evaluate(patternObj, nav);
    boolean includeFts = BooleanFunction.evaluate(includeFtsObj, nav);
    QName qname = QName.createQName(nav.getAttributeNamespaceUri(attribute), ISO9075.decode(nav
            .getAttributeName(attribute)));

    DocumentNavigator dNav = (DocumentNavigator) nav;
    // JSR 170 includes full text matches
    return dNav.like(car.getChildRef(), qname, pattern, includeFts);

}
 
Example #22
Source File: NodeServiceXPath.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Object evaluate(List nodes, Object pattern, Navigator nav)
{
    if (nodes.size() != 1)
    {
        return false;
    }
    QName qname = null;
    NodeRef nodeRef = null;
    if (nav.isElement(nodes.get(0)))
    {
        qname = null; // should use all attributes and full text index
        nodeRef = ((ChildAssociationRef) nodes.get(0)).getChildRef();
    }
    else if (nav.isAttribute(nodes.get(0)))
    {
        qname = QName.createQName(
                nav.getAttributeNamespaceUri(nodes.get(0)),
                ISO9075.decode(nav.getAttributeName(nodes.get(0))));
        nodeRef = ((DocumentNavigator.Property) nodes.get(0)).parent;
    }

    String patternValue = StringFunction.evaluate(pattern, nav);
    DocumentNavigator dNav = (DocumentNavigator) nav;

    return dNav.contains(nodeRef, qname, patternValue, SearchParameters.OR);

}
 
Example #23
Source File: AlfrescoScriptVirtualContext.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @return an array containing the plain qname path at index 0 and the
 *         ISO9075 element-encoded qname path at index 1
 */
private String[] createQNamePaths()
{
    final NamespaceService ns = serviceRegistry.getNamespaceService();
    final Map<String, String> cache = new HashMap<String, String>();
    final StringBuilder bufPlain = new StringBuilder(128);
    final StringBuilder bufISO9075 = new StringBuilder(128);

    final Path path = serviceRegistry.getNodeService().getPath(context.getActualNodeRef());
    for (final Path.Element e : path)
    {
        if (e instanceof Path.ChildAssocElement)
        {
            final QName qname = ((Path.ChildAssocElement) e).getRef().getQName();
            if (qname != null)
            {
                String prefix = cache.get(qname.getNamespaceURI());
                if (prefix == null)
                {
                    // first request for this namespace prefix, get and
                    // cache result
                    Collection<String> prefixes = ns.getPrefixes(qname.getNamespaceURI());
                    prefix = prefixes.size() != 0 ? prefixes.iterator().next() : "";
                    cache.put(qname.getNamespaceURI(),
                              prefix);
                }
                bufISO9075.append('/').append(prefix).append(':').append(ISO9075.encode(qname.getLocalName()));
                bufPlain.append('/').append(prefix).append(':').append(qname.getLocalName());
            }
        }
        else
        {
            bufISO9075.append('/').append(e.toString());
            bufPlain.append('/').append(e.toString());
        }
    }
    String[] qnamePaths = new String[] { bufPlain.toString(), bufISO9075.toString() };

    return qnamePaths;
}
 
Example #24
Source File: DocumentNavigator.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String getElementName(Object o)
{
    QName qName = ((ChildAssociationRef) o).getQName();
    if(qName == null)
    {
        return "";
    }
    return ISO9075.encode(qName.getLocalName());
}
 
Example #25
Source File: FolderTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public FolderTypeDefintionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping accessorMapping, 
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisClassDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new FolderTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_FOLDER);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    boolean isSystemFolder = false;
    if (BaseTypeId.CMIS_FOLDER.value().equals(typeId))
    {
        typeDef.setQueryName(ISO9075.encodeSQL(typeId));
        typeDef.setParentTypeId(null);
    } else
    {
        typeDef.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoName)));
        QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
        if (cmisMapping.isValidCmisFolder(parentQName))
        {
            typeDef.setParentTypeId(cmisMapping.getCmisTypeId(BaseTypeId.CMIS_FOLDER, parentQName));
        }

        if (alfrescoName.equals(ContentModel.TYPE_SYSTEM_FOLDER)
                || cmisMapping.getDictionaryService().isSubClass(alfrescoName, ContentModel.TYPE_SYSTEM_FOLDER))
        {
            isSystemFolder = true;
        }
    }

    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    typeDef.setIsCreatable(!isSystemFolder);
    typeDef.setIsQueryable(true);
    typeDef.setIsFulltextIndexed(true);
    typeDef.setIsControllablePolicy(false);
    typeDef.setIsControllableAcl(true);
    typeDef.setIsIncludedInSupertypeQuery(cmisClassDef.getIncludedInSuperTypeQuery());
    typeDef.setIsFileable(true);

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);

    createOwningPropertyDefinitions(cmisMapping, accessorMapping, luceneBuilderMapping, dictionaryService, cmisClassDef);
    createActionEvaluators(accessorMapping, BaseTypeId.CMIS_FOLDER);
}
 
Example #26
Source File: DocumentTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public DocumentTypeDefinitionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping accessorMapping, 
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisClassDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new DocumentTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_DOCUMENT);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    if (BaseTypeId.CMIS_DOCUMENT.value().equals(typeId))
    {
        typeDef.setQueryName(ISO9075.encodeSQL(typeId));
        typeDef.setParentTypeId(null);
    } else
    {
        typeDef.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoName)));
        QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
        if (cmisMapping.isValidCmisDocument(parentQName))
        {
            typeDef.setParentTypeId(cmisMapping.getCmisTypeId(BaseTypeId.CMIS_DOCUMENT, parentQName));
        }
    }

    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    typeDef.setIsCreatable(true);
    typeDef.setIsQueryable(true);
    typeDef.setIsFulltextIndexed(true);
    typeDef.setIsControllablePolicy(false);
    typeDef.setIsControllableAcl(true);
    typeDef.setIsIncludedInSupertypeQuery(cmisClassDef.getIncludedInSuperTypeQuery());
    typeDef.setIsFileable(true);
    typeDef.setContentStreamAllowed(ContentStreamAllowed.ALLOWED);
    typeDef.setIsVersionable(true);

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);

    createOwningPropertyDefinitions(cmisMapping, accessorMapping, luceneBuilderMapping, dictionaryService, cmisClassDef);
    createActionEvaluators(accessorMapping, BaseTypeId.CMIS_DOCUMENT);
}
 
Example #27
Source File: ItemTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ItemTypeDefinitionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping accessorMapping, 
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisClassDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new ItemTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_ITEM);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    if (BaseTypeId.CMIS_ITEM.value().equals(typeId) )
    {
        typeDef.setQueryName(ISO9075.encodeSQL(typeId));
        typeDef.setParentTypeId(null);
    }  
    else
    {
        typeDef.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoName)));
        QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
        if(parentQName != null)
        {         
            typeDef.setParentTypeId(cmisMapping.getCmisTypeId(BaseTypeId.CMIS_ITEM, parentQName));
        }
    }

    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    if (BaseTypeId.CMIS_ITEM.value().equals(typeId) )
    {
    	typeDef.setIsCreatable(false);   // cmis:item is abstract
    	 // TEMP work around for select * from cmis:item which lists folders and files
    	typeDef.setIsQueryable(false);
    }
    else
    {
    	typeDef.setIsCreatable(true);
    	typeDef.setIsQueryable(true);
    }
  
    typeDef.setIsFulltextIndexed(true);
    typeDef.setIsControllablePolicy(true);
    typeDef.setIsControllableAcl(true);
    typeDef.setIsIncludedInSupertypeQuery(cmisClassDef.getIncludedInSuperTypeQuery());
    typeDef.setIsFileable(false);

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);

    createOwningPropertyDefinitions(cmisMapping, accessorMapping, luceneBuilderMapping, dictionaryService, cmisClassDef);
    createActionEvaluators(accessorMapping, BaseTypeId.CMIS_ITEM);
}
 
Example #28
Source File: PolicyTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public PolicyTypeDefintionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping propertyAccessorMapping, 
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisClassDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new PolicyTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_POLICY);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    if (BaseTypeId.CMIS_POLICY.value().equals(typeId))
    {
        typeDef.setQueryName(ISO9075.encodeSQL(typeId));
        typeDef.setParentTypeId(null);
    } else
    {
        typeDef.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoName)));
        QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
        if (parentQName == null)
        {
            typeDef.setParentTypeId(cmisMapping.getCmisTypeId(CMISMapping.ASPECTS_QNAME));
        } else if (cmisMapping.isValidCmisPolicy(parentQName))
        {
            typeDef.setParentTypeId(cmisMapping.getCmisTypeId(BaseTypeId.CMIS_POLICY, parentQName));
        } else
        {
            throw new IllegalStateException("The CMIS type model should ignore aspects that inherit from excluded aspects");
        }
    }

    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    typeDef.setIsCreatable(false);
    typeDef.setIsQueryable(true);
    typeDef.setIsFulltextIndexed(true);
    typeDef.setIsControllablePolicy(false);
    typeDef.setIsControllableAcl(false);
    typeDef.setIsIncludedInSupertypeQuery(cmisClassDef.getIncludedInSuperTypeQuery());
    typeDef.setIsFileable(false);

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);

    createOwningPropertyDefinitions(cmisMapping, propertyAccessorMapping, luceneBuilderMapping, dictionaryService, cmisClassDef);
    createActionEvaluators(propertyAccessorMapping, BaseTypeId.CMIS_POLICY);
}
 
Example #29
Source File: RelationshipTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public RelationshipTypeDefintionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping accessorMapping,
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisClassDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new RelationshipTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_RELATIONSHIP);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    if (BaseTypeId.CMIS_RELATIONSHIP.value().equals(typeId))
    {
        typeDef.setQueryName(ISO9075.encodeSQL(typeId));
        typeDef.setParentTypeId(null);
        typeDef.setIsCreatable(false);
    } else
    {
        typeDef.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoName)));
        typeDef.setParentTypeId(BaseTypeId.CMIS_RELATIONSHIP.value());
        typeDef.setIsCreatable(true);
    }
    
    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    typeDef.setIsQueryable(false);
    typeDef.setIsFulltextIndexed(false);
    typeDef.setIsControllablePolicy(false);
    typeDef.setIsControllableAcl(false);
    typeDef.setIsIncludedInSupertypeQuery(true);
    typeDef.setIsFileable(false);

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);

    createOwningPropertyDefinitions(cmisMapping, accessorMapping, luceneBuilderMapping, dictionaryService, cmisClassDef);
    createActionEvaluators(accessorMapping, BaseTypeId.CMIS_RELATIONSHIP);
}
 
Example #30
Source File: SolrXPathHandler.java    From SearchServices with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unused")
private void addAbsolute(String nameSpace, String localName)
{
    ArrayList<StructuredFieldPosition> answer = new ArrayList<StructuredFieldPosition>(2);
    // TODO: Resolve name space
    absolutePosition++;
    if ((nameSpace == null) || (nameSpace.length() == 0))
    {

        if(localName.equals("*"))
        {
            answer.add(new AbsoluteStructuredFieldPosition("*", absolutePosition));
        }
        else if (namespacePrefixResolver.getNamespaceURI("") == null)
        {
            answer.add(new AbsoluteStructuredFieldPosition(PathTokenFilter.NO_NS_TOKEN_TEXT, absolutePosition));
        }
        else
        {
            answer.add(new AbsoluteStructuredFieldPosition(namespacePrefixResolver.getNamespaceURI(""), absolutePosition));
        }

    }
    else
    {
        answer.add(new AbsoluteStructuredFieldPosition(namespacePrefixResolver.getNamespaceURI(nameSpace), absolutePosition));
    }

    absolutePosition++;
    if ((localName == null) || (localName.length() == 0))
    {
        answer.add(new AbsoluteStructuredFieldPosition("*", absolutePosition));
    }
    else
    {
        if(localName.equals("*"))
        {
            answer.add(new AbsoluteStructuredFieldPosition(localName, absolutePosition));
        }
        else
        {
            answer.add(new AbsoluteStructuredFieldPosition(ISO9075.encode(QName.createValidLocalName(ISO9075.decode(localName))), absolutePosition));
        }
    }
    query.appendQuery(answer);

}