As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
<sv:node [color=#FF0000]sv:name="NOMBREESPACIO"[/color]> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>cm:folder</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>sys:referenceable</sv:value> <sv:value>cm:auditable</sv:value> <sv:value>app:uifacets</sv:value> <sv:value>mix:referenceable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>555ec997-f07d-464e-9433-384958891895</sv:value> </sv:property> <sv:property sv:name="app:icon" sv:type="String"> <sv:value>space-icon-default</sv:value> </sv:property> <sv:property sv:name="cm:name" sv:type="String"> [color=#008040]<sv:value>nombreespacio</sv:value>[/color] </sv:property> <sv:property sv:name="sys:node-dbid" sv:type="Long"> <sv:value>66935</sv:value> </sv:property> <sv:property sv:name="sys:store-identifier" sv:type="String"> <sv:value>SpacesStore</sv:value> </sv:property> <sv:property sv:name="cm:title" sv:type="String"> [color=#008040]<sv:value>nombreespacio</sv:value>[/color] </sv:property> <sv:property sv:name="sys:node-uuid" sv:type="String"> <sv:value>555ec997-f07d-464e-9422-324987643223</sv:value> </sv:property> <sv:property sv:name="cm:modified" sv:type="Date"> <sv:value>2009-03-24T16:26:01.265+01:00</sv:value> </sv:property> <sv:property sv:name="cm:created" sv:type="Date"> <sv:value>2009-03-24T16:07:40.750+01:00</sv:value> </sv:property> <sv:property sv:name="sys:store-protocol" sv:type="String"> <sv:value>workspace</sv:value> </sv:property> <sv:property sv:name="cm:creator" sv:type="String"> <sv:value>usuario</sv:value> </sv:property> <sv:property sv:name="cm:description" sv:type="String"> <sv:value></sv:value> </sv:property> <sv:property sv:name="cm:modifier" sv:type="String"> <sv:value>usuario</sv:value> </sv:property>
/* * Copyright (C) 2005-2007 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * As a special exception to the terms and conditions of version 2.0 of * the GPL, you may redistribute this Program in connection with Free/Libre * and Open Source Software ("FLOSS") applications as described in Alfresco's * FLOSS exception. You should have recieved a copy of the text describing * the FLOSS exception, and it is also available here: * http://www.alfresco.com/legal/licensing" */ package org.alfresco.sample; import javax.jcr.Node; import javax.jcr.Repository; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.SimpleCredentials; import org.alfresco.jcr.api.JCRNodeRef; import org.alfresco.model.ContentModel; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Simple client example demonstrating the use of the Alfresco JCR (JSR-170) API. * * The client creates a content node in the "Company Home" folder. The content * may be viewed and operated on within the Alfresco Web Client. Note: the web client * will need to be re-started after executing this sample to see the changes in * effect. * * This client demonstrates the "Embedded Repository" deployment option as described * in the Alfresco Respotiory Architecture docucment - * http://wiki.alfresco.com/wiki/Alfresco_Repository_Architecture */ public class FirstJCRClient { public static void main(String[] args) throws Exception { // access the Alfresco JCR Repository (here it's via programmatic approach, but it could also be injected) ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml"); Repository repository = (Repository)context.getBean("JCR.Repository"); // login to workspace (here we rely on the default workspace defined by JCR.Repository bean) Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray())); try { // first, access the company home Node rootNode = session.getRootNode(); Node companyHome = rootNode.getNode("app:company_home"); // create the content node String name = "JCR sample (" + System.currentTimeMillis() + ")"; Node content = companyHome.addNode("cm:" + name, "cm:content"); content.setProperty("cm:name", name); // add titled aspect (for Web Client display) content.addMixin("cm:titled"); content.setProperty("cm:title", name); content.setProperty("cm:description", name); // // write some content to new node // content.setProperty("cm:content", "The quick brown fox jumps over the lazy dog"); // // To set the content mime type, we need to use an Alfresco native service // as there isn't an equivalent call in JCR // setMimeType(context, content, MimetypeMap.MIMETYPE_TEXT_PLAIN); // save changes session.save(); } finally { session.logout(); System.exit(0); } } /** * Demonstrates the mixed use of JCR API calls and Alfresco Foundation API calls. * * Here, the Foundation API is used to set the mimetype of the content. * * @param context application context * @param node the JCR Node to adjust * @param mimeType the mimetype to set * @throws RepositoryException */ private static void setMimeType(ApplicationContext context, Node node, String mimeType) throws RepositoryException { // retrieve service registry ServiceRegistry serviceRegistry = (ServiceRegistry) context.getBean(ServiceRegistry.SERVICE_REGISTRY); NodeService nodeService = serviceRegistry.getNodeService(); // convert the JCR Node to an Alfresco Node Reference NodeRef nodeRef = JCRNodeRef.getNodeRef(node); // retrieve the Content Property (represented as a ContentData object in Alfresco) ContentData content = (ContentData)nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT); // update the Mimetype content = ContentData.setMimetype(content, mimeType); nodeService.setProperty(nodeRef, ContentModel.PROP_CONTENT, content); } }