org.alfresco.model.ContentModel Java Examples
The following examples show how to use
org.alfresco.model.ContentModel.
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: BaseNodeServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 7 votes |
/** * Checks that the {@link ContentModel#ASPECT_REFERENCEABLE referencable} properties * are present */ @Test public void testGetReferencableProperties() throws Exception { // check individual property retrieval Serializable wsProtocol = nodeService.getProperty(rootNodeRef, ContentModel.PROP_STORE_PROTOCOL); Serializable wsIdentifier = nodeService.getProperty(rootNodeRef, ContentModel.PROP_STORE_IDENTIFIER); Serializable nodeUuid = nodeService.getProperty(rootNodeRef, ContentModel.PROP_NODE_UUID); Serializable nodeDbId = nodeService.getProperty(rootNodeRef, ContentModel.PROP_NODE_DBID); assertNotNull("Workspace Protocol property not present", wsProtocol); assertNotNull("Workspace Identifier property not present", wsIdentifier); assertNotNull("Node UUID property not present", nodeUuid); assertNotNull("Node DB ID property not present", nodeDbId); assertEquals("Workspace Protocol property incorrect", rootNodeRef.getStoreRef().getProtocol(), wsProtocol); assertEquals("Workspace Identifier property incorrect", rootNodeRef.getStoreRef().getIdentifier(), wsIdentifier); assertEquals("Node UUID property incorrect", rootNodeRef.getId(), nodeUuid); // check mass property retrieval Map<QName, Serializable> properties = nodeService.getProperties(rootNodeRef); assertTrue("Workspace Protocol property not present in map", properties.containsKey(ContentModel.PROP_STORE_PROTOCOL)); assertTrue("Workspace Identifier property not present in map", properties.containsKey(ContentModel.PROP_STORE_IDENTIFIER)); assertTrue("Node UUID property not present in map", properties.containsKey(ContentModel.PROP_NODE_UUID)); assertTrue("Node DB ID property not present in map", properties.containsKey(ContentModel.PROP_NODE_DBID)); }
Example #2
Source File: BaseNodeServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void beforeDeleteNode(NodeRef nodeRef) { // Get the node's properties nodeService.getProperties(nodeRef); // add the child to the list beforeDeleteNodeRefs.add(nodeRef); if(beforeDeleteCreateChild) { System.out.println("before delete node - add child."); // add a new child to the child, i.e. just before it is deleted ChildAssociationRef assocRef = nodeService.createNode( nodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("pre-delete new child"), ContentModel.TYPE_CONTAINER); // set some child node properties nodeService.setProperty(nodeRef, PROP_QNAME_BOOLEAN_VALUE, "true"); // add an aspect to the child nodeService.addAspect(nodeRef, ASPECT_QNAME_TEST_TITLED, null); } }
Example #3
Source File: LikesRatingScheme.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void applyRating(NodeRef nodeRef, Object rating) { try { Float ratingServiceRating = getRatingServiceRating(rating); ratingService.applyRating(nodeRef, ratingServiceRating, getRatingServiceName()); QName nodeType = nodeService.getType(nodeRef); boolean isContainer = dictionaryService.isSubClass(nodeType, ContentModel.TYPE_FOLDER) && !dictionaryService.isSubClass(nodeType, ContentModel.TYPE_SYSTEM_FOLDER); postActivity(nodeRef, isContainer ? ActivityType.FOLDER_LIKED : ActivityType.FILE_LIKED); } catch(RatingServiceException e) { throw new InvalidArgumentException(e.getMessage()); } }
Example #4
Source File: PersonSearchTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
private void createUser(String userName) { if (this.authenticationService.authenticationExists(userName) == false) { this.authenticationService.createAuthentication(userName, "PWD".toCharArray()); PropertyMap ppOne = new PropertyMap(4); ppOne.put(ContentModel.PROP_USERNAME, userName); ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName"); ppOne.put(ContentModel.PROP_LASTNAME, "lastName"); ppOne.put(ContentModel.PROP_EMAIL, "[email protected]"); ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle"); this.personService.createPerson(ppOne); } }
Example #5
Source File: SetPropertyValueActionExecuterTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Test execution */ @Test public void testExecution() { // Execute the action ActionImpl action = new ActionImpl(null, ID, SetPropertyValueActionExecuter.NAME, null); action.setParameterValue(SetPropertyValueActionExecuter.PARAM_PROPERTY, ContentModel.PROP_NAME); action.setParameterValue(SetPropertyValueActionExecuter.PARAM_VALUE, TEST_VALUE); this.executer.execute(action, this.nodeRef); // Check that the property value has been set assertEquals(TEST_VALUE, this.nodeService.getProperty(this.nodeRef, ContentModel.PROP_NAME)); // Check what happens when a bad property name is set action.setParameterValue(SetPropertyValueActionExecuter.PARAM_PROPERTY, QName.createQName("{test}badProperty")); try { this.executer.execute(action, this.nodeRef); fail("We would expect and exception to be thrown since the property name is invalid."); } catch (Throwable exception) { // Good .. we where expecting this } }
Example #6
Source File: NodeArchiveServiceRestApiTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
private void createUser(String userName) { AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); if (this.authenticationService.authenticationExists(userName) == false) { this.authenticationService.createAuthentication(userName, "password".toCharArray()); PropertyMap map = new PropertyMap(5); map.put(ContentModel.PROP_USERNAME, userName); map.put(ContentModel.PROP_FIRSTNAME, "firstName"); map.put(ContentModel.PROP_LASTNAME, "lastName"); map.put(ContentModel.PROP_EMAIL, "[email protected]"); map.put(ContentModel.PROP_JOBTITLE, "jobTitle"); this.personService.createPerson(map); this.createdPeople.add(userName); } }
Example #7
Source File: RateableAspect.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Initialise method */ public void init() { // Prevent the ratebale aspect from being copied bindNoCopyBehaviour(ContentModel.ASPECT_RATEABLE); // Prevent the roll up aspects from being copied for (RatingScheme ratingScheme : ratingSchemeRegistry.getRatingSchemes().values()) { if (ratingScheme.getPropertyRollups() != null && ratingScheme.getPropertyRollups().size() > 0) { QName rollupAspectName = ratingNamingConventions.getRollupAspectNameFor(ratingScheme); bindNoCopyBehaviour(rollupAspectName); } } }
Example #8
Source File: HasVersionHistoryEvaluator.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#evaluateImpl(org.alfresco.service.cmr.action.ActionCondition, org.alfresco.service.cmr.repository.NodeRef) */ public boolean evaluateImpl(ActionCondition ruleCondition, NodeRef actionedUponNodeRef) { boolean result = false; if (this.nodeService.exists(actionedUponNodeRef) == true && this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE) == true) { VersionHistory versionHistory = this.versionService.getVersionHistory(actionedUponNodeRef); if (versionHistory != null && versionHistory.getAllVersions().size() != 0) { result = true; } } return result; }
Example #9
Source File: TemplateFilingRuleTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testFilingPath_specialCharacters() throws Exception { NodeRef vfNodeRef = createVirtualizedFolder(testRootFolder.getNodeRef(), "Template 6 With Spaces", TEST_TEMPLATE_5_JSON_SYS_PATH); NodeRef sfpNodeRef = nodeService.getChildByName(vfNodeRef, ContentModel.ASSOC_CONTAINS, "SpecialFilingPath4"); Reference sfpReference = Reference.fromNodeRef(sfpNodeRef); ApplyTemplateMethod applyTemplateMethod = new ApplyTemplateMethod(environment); VirtualFolderDefinition structure = sfpReference.execute(applyTemplateMethod); FilingRule filingRule = structure.getFilingRule(); assertTrue(filingRule instanceof TemplateFilingRule); NodeRef fn = filingRule.filingNodeRefFor(new FilingParameters(sfpReference)); assertNotNull(fn); }
Example #10
Source File: MessageServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private void addMessageResource(NodeRef rootNodeRef, String name, InputStream resourceStream) throws Exception { Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(); contentProps.put(ContentModel.PROP_NAME, name); ChildAssociationRef association = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), ContentModel.TYPE_CONTENT, contentProps); NodeRef content = association.getChildRef(); ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.setEncoding("UTF-8"); writer.putContent(resourceStream); resourceStream.close(); }
Example #11
Source File: CheckOutCheckInServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testCheckInLockableAspectDoesntCopies_ALF16194() { // Check-out nodeRef NodeRef workingCopy = this.cociService.checkout( this.nodeRef, this.rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("workingCopy")); assertNotNull(workingCopy); // Check-in Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(); versionProperties.put(Version.PROP_DESCRIPTION, "This is a test version"); cociService.checkin(workingCopy, versionProperties); if(nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE)) { fail("Lockable aspect should not be copied from the working copy to the original document"); } }
Example #12
Source File: TransferWebScriptTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
private void createUser(String userName) { if (this.authenticationService.authenticationExists(userName) == false) { this.authenticationService.createAuthentication(userName, "password".toCharArray()); PropertyMap personProps = new PropertyMap(); personProps.put(ContentModel.PROP_USERNAME, userName); personProps.put(ContentModel.PROP_FIRSTNAME, "myFirstName"); personProps.put(ContentModel.PROP_LASTNAME, "myLastName"); personProps.put(ContentModel.PROP_EMAIL, "[email protected]"); personProps.put(ContentModel.PROP_JOBTITLE, "myJobTitle"); personProps.put(ContentModel.PROP_JOBTITLE, "myOrganisation"); this.personService.createPerson(personProps); this.createdPeople.add(userName); } }
Example #13
Source File: HiddenAspectTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@SuppressWarnings("unused") @Test public void testCheckHidden() throws Exception { String nodeName = GUID.generate(); interceptor.setEnabled(false); try { // Create some nodes that should be hidden but aren't NodeRef node = fileFolderService.create(topNodeRef, nodeName, ContentModel.TYPE_FOLDER).getNodeRef(); NodeRef node11 = fileFolderService.create(node, nodeName + ".11", ContentModel.TYPE_FOLDER).getNodeRef(); NodeRef node12 = fileFolderService.create(node, ".12", ContentModel.TYPE_CONTENT).getNodeRef(); NodeRef node21 = fileFolderService.create(node11, nodeName + ".21", ContentModel.TYPE_FOLDER).getNodeRef(); NodeRef node22 = fileFolderService.create(node11, nodeName + ".22", ContentModel.TYPE_CONTENT).getNodeRef(); NodeRef node31 = fileFolderService.create(node21, ".31", ContentModel.TYPE_FOLDER).getNodeRef(); NodeRef node41 = fileFolderService.create(node31, nodeName + ".41", ContentModel.TYPE_CONTENT).getNodeRef(); txn.commit(); } finally { interceptor.setEnabled(true); } }
Example #14
Source File: RenditionDefinitionPersisterImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void saveRenditionDefinition(RenditionDefinition renderingAction) { NodeRef actionNodeRef = findOrCreateActionNode(renderingAction); // ALF-9166 describes a problem whereby versionable saved rendition definition nodes cause problems on upgrade. // This appears to be due to a rule defined on Company Home. The behaviour suppression below is a workaround for that issue. try { behaviourFilter.disableBehaviour(actionNodeRef, ContentModel.ASPECT_VERSIONABLE); // TODO Serialize using JSON content instead. // The current serialization mechanism creates a complex content model // structure which is verbose and a JSON-based approach using a simplified // content model perhaps could offer performance improvements. runtimeActionService.saveActionImpl(actionNodeRef, renderingAction); } finally { behaviourFilter.enableBehaviour(actionNodeRef, ContentModel.ASPECT_VERSIONABLE); } }
Example #15
Source File: PersonServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Publish new user event * * @param eventType String * @param properties Map<QName, Serializable> */ private void publishEvent(String eventType, Map<QName, Serializable> properties) { if(properties == null) return; final String managedUsername = (String)properties.get(ContentModel.PROP_USERNAME); final String managedFirstname = (String)properties.get(ContentModel.PROP_FIRSTNAME); final String managedLastname = (String)properties.get(ContentModel.PROP_LASTNAME); final String eventTType = eventType; eventPublisher.publishEvent(new EventPreparator(){ @Override public Event prepareEvent(String user, String networkId, String transactionId) { return new UserManagementEvent(eventTType , transactionId, networkId,new Date().getTime(), user, managedUsername,managedFirstname,managedLastname); } }); }
Example #16
Source File: CMISMapping.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
public boolean isValidCmisRelationshipEndPoint(QName typeQName) { if(dictionaryService.getClass(typeQName).isAspect()) { return true; } if (typeQName.equals(FOLDER_QNAME)) { return true; } if (typeQName.equals(DOCUMENT_QNAME)) { return true; } if (dictionaryService.isSubClass(typeQName, ContentModel.TYPE_BASE)) { return true; } return false; }
Example #17
Source File: MLContainerTypeTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private boolean setLocaleProp(NodeRef node, Locale locale) throws Exception { Map<QName, Serializable> props = nodeService.getProperties(node); props.put(ContentModel.PROP_LOCALE, locale); boolean exceptionCatched = false; try { nodeService.setProperties(node, props); } catch (IllegalArgumentException ignore) { exceptionCatched = true; } catch(Exception ex) { throw new Exception(ex); } return exceptionCatched; }
Example #18
Source File: ContentServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Test getWriter */ @Test public void testGetWriter() { // Create a new versionable node NodeRef versionableNode = createNewVersionableNode(); // Create a new version Version version = createVersion(versionableNode, this.versionProperties); // Get writer is not supported by the version content service try { ContentWriter contentWriter = this.contentService.getWriter( version.getFrozenStateNodeRef(), ContentModel.PROP_CONTENT, true); contentWriter.putContent("bobbins"); fail("This operation is not supported."); } catch (Exception exception) { // An exception should be raised } }
Example #19
Source File: DictionaryModelType.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void onCreateNode(ChildAssociationRef childAssocRef) { NodeRef nodeRef = childAssocRef.getChildRef(); if (logger.isTraceEnabled()) { logger.trace("onCreateNode: nodeRef="+nodeRef+ " ["+AlfrescoTransactionSupport.getTransactionId()+"]"); } if (nodeService.getType(nodeRef).equals(ContentModel.TYPE_DICTIONARY_MODEL)) { Boolean value = (Boolean)nodeService.getProperty(nodeRef, ContentModel.PROP_MODEL_ACTIVE); if ((value != null) && (value == true)) { queueModel(nodeRef); } } }
Example #20
Source File: TransferServiceImpl2.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Get all transfer targets in the specified group */ public Set<TransferTarget> getTransferTargets(String groupName) { NodeRef home = getTransferHome(); // get group with assoc groupName NodeRef groupNode = nodeService.getChildByName(home, ContentModel.ASSOC_CONTAINS, groupName); if(groupNode == null) { // No transfer group. throw new TransferException(MSG_NO_GROUP, new Object[]{groupName}); } return getTransferTargets(groupNode); }
Example #21
Source File: CalendarRestApiTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
private void createUser(String userName, String role) { // if user with given user name doesn't already exist then create user if (this.authenticationService.authenticationExists(userName) == false) { // create user this.authenticationService.createAuthentication(userName, "password".toCharArray()); // create person properties PropertyMap personProps = new PropertyMap(); personProps.put(ContentModel.PROP_USERNAME, userName); personProps.put(ContentModel.PROP_FIRSTNAME, "FirstName123"); personProps.put(ContentModel.PROP_LASTNAME, "LastName123"); personProps.put(ContentModel.PROP_EMAIL, "[email protected]"); personProps.put(ContentModel.PROP_JOBTITLE, "JobTitle123"); personProps.put(ContentModel.PROP_JOBTITLE, "Organisation123"); // create person node for user this.personService.createPerson(personProps); } // add the user as a member with the given role this.siteService.setMembership(SITE_SHORT_NAME_CALENDAR, userName, role); }
Example #22
Source File: FileImporterImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Get the type of child association that should be created. * * @param parentNodeRef the parent * @return Returns the appropriate child association type qualified name for the type of the * parent. Null will be returned if it can't be determined. */ private QName getAssocTypeQName(NodeRef parentNodeRef) { // check the parent node's type to determine which association to use QName parentNodeTypeQName = nodeService.getType(parentNodeRef); QName assocTypeQName = null; if (dictionaryService.isSubClass(parentNodeTypeQName, ContentModel.TYPE_CONTAINER)) { // it may be a root node or something similar assocTypeQName = ContentModel.ASSOC_CHILDREN; } else if (dictionaryService.isSubClass(parentNodeTypeQName, ContentModel.TYPE_FOLDER)) { // more like a directory assocTypeQName = ContentModel.ASSOC_CONTAINS; } return assocTypeQName; }
Example #23
Source File: BaseNodeServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isArchivedNode) { // add the child to the list deletedNodeRefs.add(childAssocRef.getChildRef()); if(onDeleteCreateChild) { System.out.println("on delete node - add sibling."); // now perform some nasties on the node's parent, i.e. add a new child NodeRef parentRef = childAssocRef.getParentRef(); NodeRef childRef = childAssocRef.getChildRef(); ChildAssociationRef assocRef = nodeService.createNode( parentRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("post-delete new child"), ContentModel.TYPE_CONTAINER); } }
Example #24
Source File: AbstractNodeImporter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
protected final MetadataLoader.Metadata loadMetadata(ImportableItem.ContentAndMetadata contentAndMetadata) { MetadataLoader.Metadata result = new MetadataLoader.Metadata(); // Load "standard" metadata from the filesystem if (contentAndMetadata != null && contentAndMetadata.contentFileExists()) { final String filename = contentAndMetadata.getContentFile().getFileName().toString().trim().replaceFirst(DirectoryAnalyser.VERSION_SUFFIX_REGEX, ""); // Strip off the version suffix (if any) final Date modified = contentAndMetadata.getContentFileModifiedDate(); final Date created = contentAndMetadata.getContentFileCreatedDate(); result.setType(ImportableItem.FileType.FILE.equals(contentAndMetadata.getContentFileType()) ? ContentModel.TYPE_CONTENT : ContentModel.TYPE_FOLDER); result.addProperty(ContentModel.PROP_NAME, filename); result.addProperty(ContentModel.PROP_TITLE, filename); result.addProperty(ContentModel.PROP_CREATED, created); result.addProperty(ContentModel.PROP_MODIFIED, modified); } if (metadataLoader != null) { metadataLoader.loadMetadata(contentAndMetadata, result); } return(result); }
Example #25
Source File: VersionServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testAR807() { QName prop = QName.createQName("http://www.alfresco.org/test/versionstorebasetest/1.0", "intProp"); ChildAssociationRef childAssociation = nodeService.createNode(this.rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("http://www.alfresco.org/test/versionstorebasetest/1.0", "integerTest"), TEST_TYPE_QNAME); NodeRef newNode = childAssociation.getChildRef(); nodeService.setProperty(newNode, prop, 1); Object editionCode = nodeService.getProperty(newNode, prop); assertEquals(editionCode.getClass(), Integer.class); Map<String, Serializable> versionProps = new HashMap<String, Serializable>(1); versionProps.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); Version version = versionService.createVersion(newNode, versionProps); NodeRef versionNodeRef = version.getFrozenStateNodeRef(); assertNotNull(versionNodeRef); Object editionCodeArchive = nodeService.getProperty(versionNodeRef, prop); assertEquals(editionCodeArchive.getClass(), Integer.class); }
Example #26
Source File: TestCMIS.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
private NodeRef makeRenditionNode(NodeRef parent, String title, String name, String mimetype) { Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(ContentModel.PROP_NAME, name); props.put(ContentModel.PROP_TITLE, title); QName assocQName = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, name); ChildAssociationRef assoc = nodeService.createNode(parent, RenditionModel.ASSOC_RENDITION, assocQName, ContentModel.TYPE_THUMBNAIL, props); NodeRef childRef = assoc.getChildRef(); if (!nodeService.hasAspect(parent, RenditionModel.ASPECT_RENDITIONED)) { nodeService.addAspect(parent, RenditionModel.ASPECT_RENDITIONED, null); } ContentWriter writer = contentService.getWriter(childRef, ContentModel.PROP_CONTENT, true); writer.setMimetype(mimetype); writer.setEncoding("UTF-8"); writer.putContent("Dummy "+name+" content"); return childRef; }
Example #27
Source File: ADMRemoteStore.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
/** * Updates an existing document. * <p> * Update methods are user authenticated, so the modification of site config must be * allowed for the current user. * * @param path document path to update * @param content content to update the document with */ @Override protected void updateDocument(final WebScriptResponse res, String store, final String path, final InputStream content) { final String runAsUser = getPathRunAsUser(path); AuthenticationUtil.runAs(new RunAsWork<Void>() { @SuppressWarnings("synthetic-access") public Void doWork() throws Exception { final String encpath = encodePath(path); final FileInfo fileInfo = resolveFilePath(encpath); if (fileInfo == null || fileInfo.isFolder()) { res.setStatus(Status.STATUS_NOT_FOUND); return null; } try { ContentWriter writer = contentService.getWriter(fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true); writer.putContent(content); if (logger.isDebugEnabled()) logger.debug("updateDocument: " + fileInfo.toString()); } catch (AccessDeniedException ae) { res.setStatus(Status.STATUS_UNAUTHORIZED); throw ae; } return null; } }, runAsUser); }
Example #28
Source File: RepoRemoteService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public NodeRef createDirectory(NodeRef base, String path) { Pair<NodeRef, String> parentChild = getParentChildRelative(base, path); FileInfo created = fFileFolderService.create(parentChild.getFirst(), parentChild.getSecond(), ContentModel.TYPE_FOLDER); return created.getNodeRef(); }
Example #29
Source File: HasAspectEvaluatorTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void testFail() { ActionCondition condition = new ActionConditionImpl(ID, HasAspectEvaluator.NAME, null); condition.setParameterValue(HasAspectEvaluator.PARAM_ASPECT, ContentModel.ASPECT_VERSIONABLE); assertFalse(this.evaluator.evaluate(condition, this.nodeRef)); }
Example #30
Source File: NodePropertyHelperTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Tests simple, well-typed values that need conversion */ public void testConvertableKnownValues() throws Throwable { Map<QName, Serializable> in = new HashMap<QName, Serializable>(17); in.put(ContentModel.PROP_AUTO_VERSION, "TRUE"); in.put(ContentModel.PROP_HITS, "1"); in.put(ContentModel.PROP_SIZE_CURRENT, "2"); in.put(ContentModel.PROP_RATING_SCORE, "3.0"); in.put(ContentModel.PROP_NAME, new MLText("four")); in.put(ContentModel.PROP_TITLE, "five"); in.put(ContentModel.PROP_REFERENCE, "protocol://identifier/six"); in.put(VersionModel.PROP_QNAME_VALUE, "en_CA_"); marshallAndUnmarshall(in, false); }