Java Code Examples for org.alfresco.service.namespace.QName#toPrefixString()
The following examples show how to use
org.alfresco.service.namespace.QName#toPrefixString() .
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: M2Label.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
/** * Get label for data dictionary item given specified locale * * @param locale Locale * @param model ModelDefinition * @param messageLookup MessageLookup * @param type String * @param item QName * @param label String * @return String */ public static String getLabel(Locale locale, ModelDefinition model, MessageLookup messageLookup, String type, QName item, String label) { if (messageLookup == null) { return null; } String key = model.getName().toPrefixString(); if (type != null) { key += "." + type; } if (item != null) { key += "." + item.toPrefixString(); } key += "." + label; key = StringUtils.replace(key, ":", "_"); return messageLookup.getMessage(key, locale); }
Example 2
Source File: IgnoreConstraint.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private SearchParameters applyFTSDecorations(SearchParameters searchParameters, NamespacePrefixResolver nspResolver) { SearchParameters constrainedParameters = searchParameters.copy(); String theQuery = constrainedParameters.getQuery(); theQuery = "(" + theQuery + ")"; if (ignoreAspectQNames != null) { for (QName ignoredAspect : ignoreAspectQNames) { theQuery = theQuery + " and " + "!ASPECT:'" + ignoredAspect.toPrefixString(nspResolver) + "'"; } } if (ignoreTypeNames != null) { for (QName ignoredType : ignoreTypeNames) { theQuery = theQuery + " and " + "!TYPE:'" + ignoredType.toPrefixString(nspResolver) + "'"; } } constrainedParameters.setQuery(theQuery); return constrainedParameters; }
Example 3
Source File: TypeVirtualizationMethodIntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private synchronized ChildAssociationRef addTypeTemplate(QName theType, String cp) { NodeRefExpression templatesLocationExpr = virtualizationConfigTestBootstrap.getTypeTemplatesPath(); NodeRef templatesLocation = templatesLocationExpr.resolve(); assertNotNull(templatesLocation); final String prefixedType = theType.toPrefixString(environment.getNamespacePrefixResolver()); String contentName = prefixedType; contentName = contentName.replaceAll(":", "_") + ".json"; InputStream testTemplsteJsonIS = getClass().getResourceAsStream(cp); ChildAssociationRef templateContentChildRef = createContent(templatesLocation, contentName, testTemplsteJsonIS, "application/json", "UTF-8", ContentModel.TYPE_CONTENT); typeVirtualizationMethod.setQnameFilters(prefixedType); return templateContentChildRef; }
Example 4
Source File: EventGenerationBehaviours.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private Map<String, Property> getAdds(Map<QName, Serializable> before, Map<QName, Serializable> after) { Set<QName> tmp = new HashSet<QName>(after.keySet()); tmp.removeAll(before.keySet()); Map<String, Property> ret = new HashMap<String, Property>(); for(QName propQName : tmp) { Serializable value = after.get(propQName); DataType type = getPropertyType(propQName); String propName = propQName.toPrefixString(namespaceService); Property property = new Property(propName, value, type); ret.put(propName, property); } return ret; }
Example 5
Source File: AbstractNodeRelation.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
protected CollectionWithPagingInfo<Node> listNodePeerAssocs(List<AssociationRef> assocRefs, Parameters parameters, boolean returnTarget) { Map<QName, String> qnameMap = new HashMap<>(3); Map<String, UserInfo> mapUserInfo = new HashMap<>(10); List<String> includeParam = parameters.getInclude(); List<Node> collection = new ArrayList<Node>(assocRefs.size()); for (AssociationRef assocRef : assocRefs) { // minimal info by default (unless "include"d otherwise) NodeRef nodeRef = (returnTarget ? assocRef.getTargetRef() : assocRef.getSourceRef()); Node node = nodes.getFolderOrDocument(nodeRef, null, null, includeParam, mapUserInfo); QName assocTypeQName = assocRef.getTypeQName(); if (! EXCLUDED_NS.contains(assocTypeQName.getNamespaceURI())) { String assocType = qnameMap.get(assocTypeQName); if (assocType == null) { assocType = assocTypeQName.toPrefixString(namespaceService); qnameMap.put(assocTypeQName, assocType); } node.setAssociation(new Assoc(assocType)); collection.add(node); } } return listPage(collection, parameters.getPaging()); }
Example 6
Source File: EventGenerationBehaviours.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private Map<String, Property> getChanges(Map<QName, Serializable> before, Map<QName, Serializable> after) { Map<String, Property> ret = new HashMap<String, Property>(); Set<QName> intersect = new HashSet<QName>(before.keySet()); intersect.retainAll(after.keySet()); for(QName propQName : intersect) { Serializable valueBefore = before.get(propQName); Serializable valueAfter = after.get(propQName); Serializable value = null; if(valueBefore == null && valueAfter == null) { continue; } else if(valueBefore == null && valueAfter != null) { value = valueAfter; } else if(valueBefore != null && valueAfter == null) { value = valueAfter; } else if(!valueBefore.equals(valueAfter)) { value = valueAfter; } DataType type = getPropertyType(propQName); String propName = propQName.toPrefixString(namespaceService); Property property = new Property(propName, value, type); ret.put(propName, property); } return ret; }
Example 7
Source File: DataKeyMatcher.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private DataKeyInfo matchAssociation(String dataKey) { String keyName = dataKey.substring(ASSOC_DATA_PREFIX.length()); Matcher matcher = associationNamePattern.matcher(keyName); if (matcher.matches()) { QName qName = getQName(matcher); boolean isAdd = isAdd(matcher, 3); String name = qName.toPrefixString(namespaceService); return DataKeyInfo.makeAssociationDataKeyInfo(name, qName, isAdd); } return matchTransientAssociation(keyName); }
Example 8
Source File: Classification.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Get all the aspects that define a classification. * * @return String[] */ public String[] getAllClassificationAspects() { Collection<QName> aspects = services.getCategoryService().getClassificationAspects(); String[] answer = new String[aspects.size()]; int i = 0; for (QName qname : aspects) { answer[i++] = qname.toPrefixString(this.services.getNamespaceService()); } return answer; }
Example 9
Source File: EventsServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private NodeRenamedEvent nodeRenamedEvent(NodeInfo nodeInfo, String oldName, String newName) { String username = AuthenticationUtil.getFullyAuthenticatedUser(); String networkId = TenantUtil.getCurrentDomain(); String objectId = nodeInfo.getNodeId(); String siteId = nodeInfo.getSiteId(); String txnId = AlfrescoTransactionSupport.getTransactionId(); long timestamp = System.currentTimeMillis(); Long modificationTime = nodeInfo.getModificationTimestamp(); QName nodeTypeQName = nodeInfo.getType(); String nodeType = nodeTypeQName.toPrefixString(namespaceService); List<List<String>> parentNodeIds = nodeInfo.getParentNodeIds(); List<String> newPaths = nodeInfo.getPaths(); List<String> paths = null; // For site display name (title) rename events we don't want the path to be changed to the display name (title); leave it to name (id) if (nodeTypeQName.equals(SiteModel.TYPE_SITE)) { paths = newPaths; } else { nodeInfo.updateName(oldName); paths = nodeInfo.getPaths(); } Set<String> aspects = nodeInfo.getAspectsAsStrings(); Map<String, Serializable> properties = nodeInfo.getProperties(); Client alfrescoClient = getAlfrescoClient(nodeInfo.getClient()); NodeRenamedEvent event = new NodeRenamedEvent(nextSequenceNumber(), oldName, newName, txnId, timestamp, networkId, siteId, objectId, nodeType, paths, parentNodeIds, username, modificationTime, newPaths, alfrescoClient,aspects, properties); return event; }
Example 10
Source File: TypeVirtualizationMethod.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private String templateNodeNameForType(QName type) { String extension = ".json"; String typePrefixString = type.toPrefixString(namespacePrefixResolver); String typeTemplateContentName = typePrefixString.replaceAll(":", "_"); return typeTemplateContentName + extension; }
Example 11
Source File: CMISMapping.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
/** * Gets the CMIS Type Id given the Alfresco QName for the type in any * Alfresco model * * @param scope BaseTypeId * @param typeQName QName * @return String */ public String getCmisTypeId(BaseTypeId scope, QName typeQName) { String typeId = mapAlfrescoQNameToTypeId.get(typeQName); if (typeId == null) { String p = null; switch (scope) { case CMIS_DOCUMENT: p = "D"; break; case CMIS_FOLDER: p = "F"; break; case CMIS_RELATIONSHIP: p = "R"; break; case CMIS_SECONDARY: p = "P"; break; case CMIS_POLICY: p = "P"; break; case CMIS_ITEM: p = "I"; break; default: throw new CmisRuntimeException("Invalid base type!"); } return p + ":" + typeQName.toPrefixString(namespaceService); } else { return typeId; } }
Example 12
Source File: RepoService.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
public String toPrefixString(QName qname) { return qname.toPrefixString(namespaceService); }
Example 13
Source File: LinkCategoryActionExecuter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Execute action implementation */ @Override protected void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) { // Double check that the node still exists if (this.nodeService.exists(actionedUponNodeRef) == true) { // Get the rule parameter values QName categoryAspect = (QName)ruleAction.getParameterValue(PARAM_CATEGORY_ASPECT); if (categoryAspect == null) { // Use the default general classifiable aspect //cm:generalclassifiable categoryAspect = ContentModel.ASPECT_GEN_CLASSIFIABLE; } NodeRef categoryValue = (NodeRef)ruleAction.getParameterValue(PARAM_CATEGORY_VALUE); // Check that the aspect is classifiable and is currently applied to the node if (this.dictionaryService.isSubClass(categoryAspect, ContentModel.ASPECT_CLASSIFIABLE) == true) { // Get the category property qname QName categoryProperty = null; Map<QName, PropertyDefinition> propertyDefs = this.dictionaryService.getAspect(categoryAspect).getProperties(); for (Map.Entry<QName, PropertyDefinition> entry : propertyDefs.entrySet()) { if (DataTypeDefinition.CATEGORY.equals(entry.getValue().getDataType().getName()) == true) { // Found the category property categoryProperty = entry.getKey(); break; } } // Check that the category property is not null if (categoryProperty == null) { throw new AlfrescoRuntimeException("The category aspect " + categoryAspect.toPrefixString() + " does not have a category property to set."); } if (categoryAspect != null) { if (this.nodeService.hasAspect(actionedUponNodeRef, categoryAspect) == false) { // Add the aspect and set the category property value Map<QName, Serializable> properties = new HashMap<QName, Serializable>(); properties.put(categoryProperty, categoryValue); this.nodeService.addAspect(actionedUponNodeRef, categoryAspect, properties); } else { // Append the category value to the existing values Serializable value = this.nodeService.getProperty(actionedUponNodeRef, categoryProperty); Collection<NodeRef> categories = null; if (value == null) { categories = DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, categoryValue); } else { categories = DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, value); if (categories.contains(categoryValue) == false) { categories.add(categoryValue); } } this.nodeService.setProperty(actionedUponNodeRef, categoryProperty, (Serializable)categories); } } } } }
Example 14
Source File: CMISMapping.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 4 votes |
public String buildPrefixEncodedString(QName qname) { return qname.toPrefixString(namespaceService); }
Example 15
Source File: AlfrescoJsonSerializer.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
private String getJsonQName(QName name) { String nameString = name.toPrefixString(namespaceService); return nameString.replaceFirst(":", "_"); }
Example 16
Source File: AbstractUserNotifier.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public Pair<Integer, Long> notifyUser(final NodeRef personNodeRef, String subject, Object[] subjectParams, Map<String, String> siteNames, String shareUrl, int repeatIntervalMins, String templateNodeRef) { Map<QName, Serializable> personProps = nodeService.getProperties(personNodeRef); String feedUserId = (String)personProps.get(ContentModel.PROP_USERNAME); if (skipUser(personNodeRef)) { // skip return null; } // where did we get up to ? Long feedDBID = getFeedId(personNodeRef); // own + others (note: template can be changed to filter out user's own activities if needed) if (logger.isDebugEnabled()) { logger.debug("Get user feed entries: " + feedUserId + ", " + feedDBID); } List<ActivityFeedEntity> feedEntries = activityService.getUserFeedEntries(feedUserId, null, false, false, null, null, feedDBID); if (feedEntries.size() > 0) { ActivitiesFeedModelBuilder modelBuilder; try { modelBuilder = activitiesFeedModelBuilderFactory.getObject(); } catch (Exception error) { logger.warn("Unable to create model builder: " + error.getMessage()); return null; } for (ActivityFeedEntity feedEntry : feedEntries) { try { modelBuilder.addActivityFeedEntry(feedEntry); String siteId = feedEntry.getSiteNetwork(); addSiteName(siteId, siteNames); } catch (JSONException je) { // skip this feed entry logger.warn("Skip feed entry for user ("+feedUserId+"): " + je.getMessage()); continue; } } final int activityCount = modelBuilder.activityCount(); if (activityCount > 0) { Map<String, Object> model = modelBuilder.buildModel(); model.put("siteTitles", siteNames); model.put("repeatIntervalMins", repeatIntervalMins); model.put("feedItemsMax", activityService.getMaxFeedItems()); // add Share info to model model.put(TemplateService.KEY_PRODUCT_NAME, ModelUtil.getProductName(repoAdminService)); Map<String, Serializable> personPrefixProps = new HashMap<String, Serializable>(personProps.size()); for (QName propQName : personProps.keySet()) { try { String propPrefix = propQName.toPrefixString(namespaceService); personPrefixProps.put(propPrefix, personProps.get(propQName)); } catch (NamespaceException ne) { // ignore properties that do not have a registered namespace logger.warn("Ignoring property '" + propQName + "' as it's namespace is not registered"); } } model.put("personProps", personPrefixProps); // send notifyUser(personNodeRef, subject, subjectParams, model, templateNodeRef); return new Pair<Integer, Long>(activityCount, modelBuilder.getMaxFeedId()); } } return null; }
Example 17
Source File: NodeFormProcessor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected String getItemType(NodeRef item) { QName type = this.nodeService.getType(item); return type.toPrefixString(this.namespaceService); }
Example 18
Source File: Jackson2QnameSerializer.java From alfresco-mvc with Apache License 2.0 | 4 votes |
@Override public void serialize(QName value, JsonGenerator jgen, SerializerProvider provider) throws IOException { String prefixString = value.toPrefixString(serviceRegistry.getNamespaceService()); jgen.writeString(prefixString); }
Example 19
Source File: ValueDataTypeValidatorImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void validateValue(String dataType, String value) { ParameterCheck.mandatoryString("dataType", dataType); if (StringUtils.isEmpty(value)) { return; } QName typeQName = QName.createQName(dataType, this.namespaceService); DataTypeDefinition typeDef = this.dictionaryService.getDataType(typeQName); if (typeDef == null) { throw new AlfrescoRuntimeException(MSG_DATA_TYPE_UNKNOWN, new Object[] { typeQName.toPrefixString() }); } if (DataTypeDefinition.BOOLEAN.equals(typeQName)) { checkBooleanValue(value); } else { try { DefaultTypeConverter.INSTANCE.convert(typeDef, value); } catch (Exception ex) { if (DataTypeDefinition.DATE.equals(typeQName)) { throw new AlfrescoRuntimeException(MSG_INVALID_DATE, new Object[] { value }); } if (DataTypeDefinition.DATETIME.equals(typeQName)) { throw new AlfrescoRuntimeException(MSG_INVALID_DATETIME, new Object[] { value }); } throw new AlfrescoRuntimeException(MSG_INVALID_VALUE, new Object[] { value, typeQName.toPrefixString() }); } } }
Example 20
Source File: ViewXMLExporter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 2 votes |
/** * Get the prefix for the specified URI * @param qname the QName * @return the prefix (or null, if one is not registered) */ private String toPrefixString(QName qname) { return qname.toPrefixString(namespaceService); }