use of org.alfresco.service.namespace.NamespacePrefixResolver in project alfresco-repository by Alfresco.
the class TemplateFilingRule method createFilingData.
private FilingData createFilingData(Reference parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName, Map<QName, Serializable> properties) throws VirtualizationException {
NodeRef fParentRef = null;
QName fType = null;
Set<QName> fAspects = null;
Map<QName, Serializable> fProperties = null;
NamespacePrefixResolver nsPrefixResolver = env.getNamespacePrefixResolver();
if (type == null || type.length() == 0) {
fType = nodeTypeQName;
} else {
fType = QName.createQName(type, nsPrefixResolver);
if (env.isSubClass(fType, ContentModel.TYPE_FOLDER)) {
if (logger.isDebugEnabled()) {
logger.debug("CM-528 acceptance criteria 3 : we deny the creation of folders subtype " + fType + " and force cm:content instead.");
}
fType = ContentModel.TYPE_CONTENT;
}
if (env.isSubClass(nodeTypeQName, fType)) {
fType = nodeTypeQName;
}
}
fParentRef = parentNodeRefFor(parentRef, true);
fProperties = new HashMap<QName, Serializable>(properties);
Set<Entry<String, String>> propertyEntries = stringProperties.entrySet();
for (Entry<String, String> propertyEntry : propertyEntries) {
String name = propertyEntry.getKey();
QName qName = QName.createQName(name, nsPrefixResolver);
if (!fProperties.containsKey(qName)) {
fProperties.put(qName, stringProperties.get(name));
}
}
fAspects = new HashSet<>();
for (String aspect : aspects) {
fAspects.add(QName.createQName(aspect, env.getNamespacePrefixResolver()));
}
return new FilingData(fParentRef, assocTypeQName, assocQName, fType, fAspects, fProperties);
}
use of org.alfresco.service.namespace.NamespacePrefixResolver in project alfresco-repository by Alfresco.
the class TypeVirtualizationMethodUnitTest method mockNamespacePrefixResolver.
static NamespacePrefixResolver mockNamespacePrefixResolver() {
NamespacePrefixResolver mockNamespacePrefixResolver = Mockito.mock(NamespacePrefixResolver.class, new ThrowsException(new NamespaceException("Mock exception ")));
Mockito.doReturn(Arrays.<String>asList(SiteModel.SITE_MODEL_PREFIX)).when(mockNamespacePrefixResolver).getPrefixes(SiteModel.SITE_MODEL_URL);
Mockito.doReturn(SiteModel.SITE_MODEL_URL).when(mockNamespacePrefixResolver).getNamespaceURI(SiteModel.SITE_MODEL_PREFIX);
Mockito.doReturn(Arrays.<String>asList(NamespaceService.CONTENT_MODEL_PREFIX)).when(mockNamespacePrefixResolver).getPrefixes(NamespaceService.CONTENT_MODEL_1_0_URI);
Mockito.doReturn(NamespaceService.CONTENT_MODEL_1_0_URI).when(mockNamespacePrefixResolver).getNamespaceURI(NamespaceService.CONTENT_MODEL_PREFIX);
Mockito.doReturn("mock(NamespacePrefixResolver)@" + TypeVirtualizationMethod.class.toString()).when(mockNamespacePrefixResolver).toString();
return mockNamespacePrefixResolver;
}
use of org.alfresco.service.namespace.NamespacePrefixResolver in project alfresco-repository by Alfresco.
the class VirtualStoreImpl method getProperties.
@Override
public Map<QName, Serializable> getProperties(Reference reference) throws VirtualizationException {
final Protocol protocol = reference.getProtocol();
if (Protocols.VIRTUAL.protocol.equals(protocol) || Protocols.VANILLA.protocol.equals(protocol)) {
VirtualFolderDefinition folderDefinition = resolveVirtualFolderDefinition(reference);
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
// We first set default property values. They might be overridden by
// folder definition properties.
properties.put(ContentModel.PROP_NAME, folderDefinition.getName());
StoreRef storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
properties.put(ContentModel.PROP_STORE_IDENTIFIER, storeRef.getIdentifier());
properties.put(ContentModel.PROP_STORE_PROTOCOL, storeRef.getProtocol());
properties.put(ContentModel.PROP_LOCALE, Locale.UK.toString());
properties.put(ContentModel.PROP_MODIFIED, new Date());
properties.put(ContentModel.PROP_MODIFIER, AuthenticationUtil.SYSTEM_USER_NAME);
properties.put(ContentModel.PROP_CREATED, new Date());
properties.put(ContentModel.PROP_CREATOR, AuthenticationUtil.SYSTEM_USER_NAME);
properties.put(ContentModel.PROP_NODE_DBID, 0);
properties.put(ContentModel.PROP_DESCRIPTION, folderDefinition.getDescription());
// ACE-5303 : ContentModel.PROP_TITLE remains unset
// We add virtual folder definition structure properties. They might
// override the above defaults.
Map<String, String> nodeProperties = folderDefinition.getProperties();
if (nodeProperties != null) {
Set<Entry<String, String>> propertyEntries = nodeProperties.entrySet();
NamespacePrefixResolver nsPrefixResolver = environment.getNamespacePrefixResolver();
for (Entry<String, String> propertyValueEntry : propertyEntries) {
QName propertyQName = QName.createQName(propertyValueEntry.getKey(), nsPrefixResolver);
properties.put(propertyQName, propertyValueEntry.getValue().toString());
}
}
return properties;
} else {
NodeRef actual = reference.execute(new GetActualNodeRefMethod(environment));
Map<QName, Serializable> properties = environment.getProperties(actual);
properties.put(VirtualContentModel.PROP_ACTUAL_NODE_REF, actual.toString());
return properties;
}
}
Aggregations