Java Code Examples for org.alfresco.service.namespace.QName#createQName()
The following examples show how to use
org.alfresco.service.namespace.QName#createQName() .
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: CustomModelsImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override public CustomAspect getCustomAspect(String modelName, String aspectName, Parameters parameters) { if(aspectName == null) { throw new InvalidArgumentException(ASPECT_NAME_NULL_ERR); } final CustomModelDefinition modelDef = getCustomModelImpl(modelName); QName aspectQname = QName.createQName(modelDef.getName().getNamespaceURI(), aspectName); AspectDefinition customAspectDef = customModelService.getCustomAspect(aspectQname); if (customAspectDef == null) { throw new EntityNotFoundException(aspectName); } // Check if inherited properties have been requested boolean includeInheritedProps = hasSelectProperty(parameters, SELECT_ALL_PROPS); return convertToCustomAspect(customAspectDef, includeInheritedProps); }
Example 2
Source File: AuthorityDAOImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private NodeRef getOrCreateZone(String zoneName, boolean create) { NodeRef zoneContainerRef = getZoneContainer(); QName zoneQName = QName.createQName("cm", zoneName, namespacePrefixResolver); List<ChildAssociationRef> results = nodeService.getChildAssocs(zoneContainerRef, ContentModel.ASSOC_CHILDREN, zoneQName, false); if (results.isEmpty()) { if (create) { HashMap<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(ContentModel.PROP_NAME, zoneName); return nodeService.createNode(zoneContainerRef, ContentModel.ASSOC_CHILDREN, zoneQName, ContentModel.TYPE_ZONE, props).getChildRef(); } else { return null; } } else { return results.get(0).getChildRef(); } }
Example 3
Source File: ShortQNameMethod.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Helper to create a QName from either a fully qualified or short-name QName string * * @param s Fully qualified or short-name QName string * * @return QName */ private QName createQName(String s) { QName qname; if (s.indexOf(NAMESPACE_BEGIN) != -1) { qname = QName.createQName(s); } else { qname = QName.createQName(s, this.services.getNamespaceService()); } return qname; }
Example 4
Source File: RenditionService2IntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void testUpgradeRenditionService() throws InterruptedException { String ownerUserName = createRandomUser(); NodeRef sourceNodeRef = createSource(ownerUserName, "quick.jpg"); final QName doclibRendDefQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "doclib"); transactionService.getRetryingTransactionHelper() .doInTransaction(() -> AuthenticationUtil.runAs(() -> renditionService.render(sourceNodeRef, doclibRendDefQName), ownerUserName)); NodeRef oldRendition = AuthenticationUtil.runAs(() -> renditionService.getRenditionByName(sourceNodeRef, doclibRendDefQName).getChildRef(), ownerUserName); assertFalse("The rendition should be generated by old Rendition Service", AuthenticationUtil.runAs(() -> nodeService.hasAspect(oldRendition, RenditionModel.ASPECT_RENDITION2), ownerUserName)); updateContent(ownerUserName, sourceNodeRef, "quick.png"); NodeRef newRendition = waitForRendition(ownerUserName, sourceNodeRef, DOC_LIB, true); assertNotNull("The rendition should be reported via RenditionService2", newRendition); Thread.sleep(200); boolean hasRenditionedAspect = false; for (int i = 0; i < 5; i++) { hasRenditionedAspect = AuthenticationUtil.runAs(() -> nodeService.hasAspect(newRendition, RenditionModel.ASPECT_RENDITION2), ownerUserName); if (hasRenditionedAspect) { break; } else { Thread.sleep(500); } } assertTrue("The rendition should be generated by new Rendition Service", hasRenditionedAspect); }
Example 5
Source File: RenditionServiceIntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void testRenderFreeMarkerTemplate() throws Exception { final QName renditionName = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, FreemarkerRenderingEngine.NAME); this.renditionNode = transactionHelper .doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>() { @Override public NodeRef execute() throws Throwable { // create test model RenditionDefinition definition = renditionService.createRenditionDefinition(renditionName, FreemarkerRenderingEngine.NAME); definition.setParameterValue(FreemarkerRenderingEngine.PARAM_TEMPLATE_NODE, nodeWithFreeMarkerContent); ChildAssociationRef renditionAssoc = renditionService .render(nodeWithDocContent, definition); assertNotNull("The rendition association was null", renditionAssoc); return renditionAssoc.getChildRef(); } }); transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() { @Override public Void execute() throws Throwable { String output = readTextContent(renditionNode); assertNotNull("The rendition content was null.", output); // check the output contains root node Id as expected. assertTrue(output.contains(nodeWithDocContent.getId())); return null; } }); }
Example 6
Source File: QueryParserUtils.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public static PropertyDefinition matchPropertyDefinition(String defaultNameSpaceUri, NamespacePrefixResolver namespacePrefixResolver, DictionaryService dictionaryService, String string) { QName search = QName.createQName(QueryParserUtils.expandQName(defaultNameSpaceUri, namespacePrefixResolver, string)); PropertyDefinition propertyDefinition = dictionaryService.getProperty(QName.createQName(QueryParserUtils.expandQName(defaultNameSpaceUri, namespacePrefixResolver, string))); QName match = null; if (propertyDefinition == null) { for (QName definition : dictionaryService.getAllProperties(null)) { if (definition.getNamespaceURI().equalsIgnoreCase(search.getNamespaceURI())) { if (definition.getLocalName().equalsIgnoreCase(search.getLocalName())) { if (match == null) { match = definition; } else { throw new DictionaryException("Ambiguous data datype " + string); } } } } } else { return propertyDefinition; } if (match == null) { return null; } else { return dictionaryService.getProperty(match); } }
Example 7
Source File: M2ConstraintDefinition.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
@Override public QName getRef() { QName refQName = null; String ref = m2Constraint.getRef(); if (ref != null) { refQName = QName.createQName(ref, prefixResolver); } return refQName; }
Example 8
Source File: ThumbnailServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * @see org.alfresco.service.cmr.thumbnail.ThumbnailService#getThumbnailByName(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.lang.String) */ public NodeRef getThumbnailByName(NodeRef node, QName contentProperty, String thumbnailName) { // // NOTE: // // Since there is not an easy alternative and for clarity the node service is being used to retrieve the thumbnails. // If retrieval performance becomes an issue then this code can be replaced // if (logger.isDebugEnabled() == true) { logger.debug("Getting thumbnail by name (nodeRef=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; thumbnailName=" + thumbnailName + ")"); } // Thumbnails have a cm: prefix. QName namespacedThumbnailName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, thumbnailName); ChildAssociationRef existingRendition = renditionService.getRenditionByName(node, namespacedThumbnailName); NodeRef thumbnail = null; // Check the child to see if it matches the content property we are concerned about. // We can assume there will only ever be one per content property since createThumbnail enforces this. if (existingRendition != null) { NodeRef child = existingRendition.getChildRef(); Serializable contentPropertyName = this.nodeService.getProperty(child, ContentModel.PROP_CONTENT_PROPERTY_NAME); if (contentProperty.equals(contentPropertyName) == true) { if (validateThumbnail(child)) { thumbnail = child; } } } return thumbnail; }
Example 9
Source File: ScriptNode.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Helper to create a QName from either a fully qualified or short-name QName string * * @param s Fully qualified or short-name QName string * * @return QName */ protected QName createQName(String s) { QName qname; if (s.indexOf(NAMESPACE_BEGIN) != -1) { qname = QName.createQName(s); } else { qname = QName.createQName(s, this.services.getNamespaceService()); } return qname; }
Example 10
Source File: NodeServiceXPath.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public Object evaluate(List nodes, Object qnameObj, Navigator nav) { if (nodes.size() != 1) { return false; } // resolve the qname of the type we are checking for String qnameStr = StringFunction.evaluate(qnameObj, nav); if (qnameStr.equals("*")) { return true; } QName typeQName; if (qnameStr.startsWith("{")) { typeQName = QName.createQName(qnameStr); } else { typeQName = QName.createQName(qnameStr, ((DocumentNavigator) nav).getNamespacePrefixResolver()); } // resolve the noderef NodeRef nodeRef = null; if (nav.isElement(nodes.get(0))) { nodeRef = ((ChildAssociationRef) nodes.get(0)).getChildRef(); } else if (nav.isAttribute(nodes.get(0))) { nodeRef = ((DocumentNavigator.Property) nodes.get(0)).parent; } DocumentNavigator dNav = (DocumentNavigator) nav; boolean result = dNav.isSubtypeOf(nodeRef, typeQName); return result; }
Example 11
Source File: DBFTSPrefixTerm.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void prepare(NamespaceService namespaceService, DictionaryService dictionaryService, QNameDAO qnameDAO, NodeDAO nodeDAO, TenantService tenantService, Set<String> selectors, Map<String, Argument> functionArgs, FunctionEvaluationContext functionContext, boolean supportBooleanFloatAndDouble) { Argument argument = functionArgs.get(ARG_TERM); String term = (String) argument.getValue(functionContext); // strip trailing wildcard * term = term.substring(0, term.length() - 1); PropertyArgument propertyArgument = (PropertyArgument) functionArgs.get(ARG_PROPERTY); argument = functionArgs.get(ARG_TOKENISATION_MODE); AnalysisMode mode = (AnalysisMode) argument.getValue(functionContext); if (mode != AnalysisMode.IDENTIFIER) { throw new QueryModelException("Analysis mode not supported for DB " + mode); } PropertySupport propertySupport = new PropertySupport(); propertySupport.setValue(term + "%"); QName propertyQName = QName.createQName(DBQuery.expandQName(functionContext.getAlfrescoPropertyName(propertyArgument.getPropertyName()), namespaceService)); propertySupport.setPropertyQName(propertyQName); propertySupport.setPropertyDataType(DBQuery.getDataTypeDefinition(dictionaryService, propertyQName)); propertySupport.setPair(qnameDAO.getQName(propertyQName)); propertySupport.setJoinCommandType(DBQuery.getJoinCommandType(propertyQName)); propertySupport.setFieldName(DBQuery.getFieldName(dictionaryService, propertyQName, supportBooleanFloatAndDouble)); propertySupport.setCommandType(DBQueryBuilderPredicatePartCommandType.LIKE); builderSupport = propertySupport; }
Example 12
Source File: NodeLocatorWebScriptTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
private NodeRef makeChildNode(NodeRef parent, QName type) { QName qName = QName.createQName("", GUID.generate()); QName contains = ContentModel.ASSOC_CONTAINS; ChildAssociationRef result = nodeService.createNode(parent, contains, qName, type); return result.getChildRef(); }
Example 13
Source File: NodeTypeFilter.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
/** * Sets the List of node types to exclude. These node types should be in the * short form e.g. cm:myType. * * @param excludedTypesStg a List of node types which are to be excluded. */ public void setExcludedTypes(List<String> excludedTypesStg) { // Convert the Strings to QNames. this.excludedTypes = new ArrayList<QName>(excludedTypesStg.size()); for (String s : excludedTypesStg) { QName typeQName = QName.createQName(s, namespaceService); this.excludedTypes.add(typeQName); } }
Example 14
Source File: MultiUserRenditionTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * This test method ensures that users who cause renditions (thumbnails) to * be created on nodes are not made the modifier of the source node. */ @Test public void renditioningShouldNotChangeModifierOnSourceNode_ALF3991() { // Create a doc as admin AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); final NodeRef adminPdfNode = txnHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>() { public NodeRef execute() throws Throwable { return createPdfDocumentAsCurrentlyAuthenticatedUser(ADMIN_USER + "_content"); } }); this.nodesToBeTidiedUp.add(adminPdfNode); // Create another doc as non-admin AuthenticationUtil.setFullyAuthenticatedUser(NON_ADMIN_USER); final NodeRef nonAdminPdfNode = txnHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>() { public NodeRef execute() throws Throwable { return createPdfDocumentAsCurrentlyAuthenticatedUser(NON_ADMIN_USER + "_content"); } }); this.nodesToBeTidiedUp.add(nonAdminPdfNode); // Now have each user create a rendition (thumbnail) of the other user's content node. final QName doclibRendDefQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "doclib"); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); txnHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() { public Void execute() throws Throwable { renditionService.render(nonAdminPdfNode, doclibRendDefQName); return null; } }); AuthenticationUtil.setFullyAuthenticatedUser(NON_ADMIN_USER); txnHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() { public Void execute() throws Throwable { renditionService.render(adminPdfNode, doclibRendDefQName); return null; } }); // And now check that the two source nodes still have the correct modifier property. // This will ensure that the auditable properties behaviour has been correctly filtered. txnHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() { public Void execute() throws Throwable { assertEquals("Incorrect modifier property", ADMIN_USER, nodeService.getProperty(adminPdfNode, ContentModel.PROP_MODIFIER)); assertEquals("Incorrect modifier property", NON_ADMIN_USER, nodeService.getProperty(nonAdminPdfNode, ContentModel.PROP_MODIFIER)); return null; } }); // renditions get ownership from the rendered docs (not who did the rendering) txnHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() { public Void execute() throws Throwable { assertEquals("Incorrect rendition owner", ownableService.getOwner(adminPdfNode), ownableService.getOwner(renditionService.getRenditions(adminPdfNode).get(0).getChildRef())); assertEquals("Incorrect rendition owner", ownableService.getOwner(nonAdminPdfNode), ownableService.getOwner(renditionService.getRenditions(nonAdminPdfNode).get(0).getChildRef())); return null; } }); }
Example 15
Source File: RenditionService2IntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * @deprecated can be removed when we remove the original RenditionService */ @Deprecated @Test public void testUpgradeRenditionViaRender() throws InterruptedException { renditionService2.setEnabled(false); try { NodeRef sourceNodeRef = createSource(ADMIN, "quick.jpg"); final QName doclibRendDefQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "doclib"); transactionService.getRetryingTransactionHelper() .doInTransaction(() -> AuthenticationUtil.runAs(() -> renditionService.render(sourceNodeRef, doclibRendDefQName), ADMIN)); waitForRendition(ADMIN, sourceNodeRef, DOC_LIB, true); renditionService2.setEnabled(true); render(ADMIN, sourceNodeRef, DOC_LIB); Thread.sleep(200); NodeRef renditionNodeRef = waitForRendition(ADMIN, sourceNodeRef, DOC_LIB, true); boolean hasRendition2Aspect = false; for (int i = 0; i < 5; i++) { hasRendition2Aspect = AuthenticationUtil.runAs(() -> nodeService.hasAspect(renditionNodeRef, RenditionModel.ASPECT_RENDITION2), ADMIN); if (hasRendition2Aspect) { break; } else { Thread.sleep(500); } } assertTrue("Should have switched to the new rendition service", hasRendition2Aspect); } finally { renditionService2.setEnabled(true); } }
Example 16
Source File: QuickShareLinkExpiryActionImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public static QName createQName(String sharedId) { return QName.createQName(null, sharedId); }
Example 17
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 18
Source File: AuthenticationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void setUp() throws Exception { if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE) { throw new AlfrescoRuntimeException( "A previous tests did not clean up transaction: " + AlfrescoTransactionSupport.getTransactionId()); } dialect = (Dialect) ctx.getBean("dialect"); nodeService = (NodeService) ctx.getBean("nodeService"); authorityService = (AuthorityService) ctx.getBean("authorityService"); tenantService = (TenantService) ctx.getBean("tenantService"); tenantAdminService = (TenantAdminService) ctx.getBean("tenantAdminService"); compositePasswordEncoder = (CompositePasswordEncoder) ctx.getBean("compositePasswordEncoder"); ticketComponent = (TicketComponent) ctx.getBean("ticketComponent"); authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService"); pubAuthenticationService = (MutableAuthenticationService) ctx.getBean("AuthenticationService"); authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); authenticationComponentImpl = (AuthenticationComponent) ctx.getBean("authenticationComponent"); pubPersonService = (PersonService) ctx.getBean("PersonService"); personService = (PersonService) ctx.getBean("personService"); policyComponent = (PolicyComponent) ctx.getBean("policyComponent"); behaviourFilter = (BehaviourFilter) ctx.getBean("policyBehaviourFilter"); authenticationCache = (SimpleCache<String, CacheEntry>) ctx.getBean("authenticationCache"); immutableSingletonCache = (SimpleCache<String, NodeRef>) ctx.getBean("immutableSingletonCache"); // permissionServiceSPI = (PermissionServiceSPI) // ctx.getBean("permissionService"); ticketsCache = (SimpleCache<String, Ticket>) ctx.getBean("ticketsCache"); usernameToTicketIdCache = (SimpleCache<String, String>) ctx.getBean("usernameToTicketIdCache"); ChildApplicationContextFactory sysAdminSubsystem = (ChildApplicationContextFactory) ctx.getBean("sysAdmin"); assertNotNull("sysAdminSubsystem", sysAdminSubsystem); ApplicationContext sysAdminCtx = sysAdminSubsystem.getApplicationContext(); sysAdminParams = (SysAdminParamsImpl) sysAdminCtx.getBean("sysAdminParams"); dao = (MutableAuthenticationDao) ctx.getBean("authenticationDao"); // Let's look inside the alfresco authentication subsystem to get the DAO-wired authentication manager ChildApplicationContextManager authenticationChain = (ChildApplicationContextManager) ctx.getBean("Authentication"); ApplicationContext subsystem = authenticationChain.getApplicationContext(authenticationChain.getInstanceIds().iterator().next()); authenticationManager = (AuthenticationManager) subsystem.getBean("authenticationManager"); transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName()); // Clean up before we start trying to create the test user transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() { @Override public Void execute() throws Throwable { AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); try { deleteAndy(); return null; } finally { authenticationComponent.clearCurrentSecurityContext(); } } }, false, true); userTransaction = transactionService.getUserTransaction(); userTransaction.begin(); StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); rootNodeRef = nodeService.getRootNode(storeRef); QName children = ContentModel.ASSOC_CHILDREN; QName system = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "system"); QName container = ContentModel.TYPE_CONTAINER; QName types = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "people"); systemNodeRef = nodeService.createNode(rootNodeRef, children, system, container).getChildRef(); typesNodeRef = nodeService.createNode(systemNodeRef, children, types, container).getChildRef(); Map<QName, Serializable> props = createPersonProperties("Andy"); personAndyNodeRef = nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, props).getChildRef(); assertNotNull(personAndyNodeRef); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); authenticationComponent.clearCurrentSecurityContext(); }
Example 19
Source File: MiscellaneousRulesTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * ALF-14568 doesn't explicitly say so, but there is a related problem on top of the * 'creating cm:original assoc triggers rule' bug. It is the related 'deleting cm:original assoc triggers rule' bug. * This test case validates the fix for that issue. */ @Test public void alf14568_supplementary() throws Exception { final NodeRef testSiteDocLib = TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<NodeRef>() { public NodeRef execute() throws Throwable { return SITE_SERVICE.getContainer(testSite.getShortName(), SiteService.DOCUMENT_LIBRARY); } }); assertNotNull("Null doclib", testSiteDocLib); // Create a folder to put our Alfresco Rules on - but don't put any rules on it yet. final NodeRef ruleFolder = testNodes.createFolder(testSiteDocLib, "ruleFolder", TEST_USER.getUsername()); // Create a piece of content outside our Rules folder. final NodeRef originalContent = testNodes.createQuickFile(MimetypeMap.MIMETYPE_TEXT_PLAIN, testSiteDocLib, "original.txt", TEST_USER.getUsername()); // Now copy that node into the Ruled folder, which will create a cm:original assoc. final NodeRef copyNode = TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<NodeRef>() { public NodeRef execute() throws Throwable { return COPY_SERVICE.copy(originalContent, ruleFolder, ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS); } }); final QName exifAspectQName = QName.createQName("{http://www.alfresco.org/model/exif/1.0}exif"); // Only now do we create the update rule on our folder - put a marker aspect on the node. TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<Void>() { public Void execute() throws Throwable { // Clashes with the JUnit annotation @Rule org.alfresco.service.cmr.rule.Rule rule = new org.alfresco.service.cmr.rule.Rule(); rule.setRuleType(RuleType.UPDATE); rule.applyToChildren(false); rule.setRuleDisabled(false); rule.setTitle("Put EXIF aspect on changed nodes"); rule.setExecuteAsynchronously(false); Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, exifAspectQName); Action addAspectAction = ACTION_SERVICE.createAction("add-features", params); rule.setAction(addAspectAction); RULE_SERVICE.saveRule(ruleFolder, rule); return null; } }); // Now delete the original node. TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<Void>() { public Void execute() throws Throwable { NODE_SERVICE.deleteNode(originalContent); return null; } }); // The removal of the cm:original association should NOT have triggered the rule. TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<Void>() { public Void execute() throws Throwable { assertFalse("Rule executed when it shouldn't have.", NODE_SERVICE.hasAspect(copyNode, exifAspectQName)); return null; } }); }
Example 20
Source File: RatingNamingConventionsUtil.java From alfresco-repository with GNU Lesser General Public License v3.0 | 2 votes |
/** * Given a ratingSchemeName, this method returns the aspect name which would * by convention be used to store rating property rollups. * * @param ratingSchemeName the ratingSchemeName, which is the spring bean name. * @return the aspect name used to store all property rollups for that scheme. * @deprecated Use {@link #getRollupAspectNameFor(RatingScheme)} instead. This method assumes a "cm" prefix for the aspect. */ public QName getRollupAspectNameFor(String ratingSchemeName) { String result = "cm:" + ratingSchemeName + "Rollups"; return QName.createQName(result, namespaceService); }