Return-Path: X-Original-To: apmail-jackrabbit-dev-archive@www.apache.org Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 65A9EF746 for ; Wed, 27 Mar 2013 10:11:18 +0000 (UTC) Received: (qmail 2394 invoked by uid 500); 27 Mar 2013 10:11:18 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 2295 invoked by uid 500); 27 Mar 2013 10:11:17 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 2244 invoked by uid 99); 27 Mar 2013 10:11:15 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Mar 2013 10:11:15 +0000 Date: Wed, 27 Mar 2013 10:11:15 +0000 (UTC) From: "Ferdinand Malzer (JIRA)" To: dev@jackrabbit.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (JCR-3548) using properties property defined as OnParentVersionAction.IGNORE could not be changed without check-out (see jcr 2.0 chapter 15.2.2) description holds reproducer MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Ferdinand Malzer created JCR-3548: ------------------------------------- Summary: using properties property defined as OnParentVersionAction.IGNORE could not be changed without check-out (see jcr 2.0 chapter 15.2.2) description holds reproducer Key: JCR-3548 URL: https://issues.apache.org/jira/browse/JCR-3548 Project: Jackrabbit Content Repository Issue Type: Bug Components: jackrabbit-core Affects Versions: 2.4.3 Environment: windows xp on hpq_nc8540 Reporter: Ferdinand Malzer Priority: Minor import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.List; import javax.jcr.Binary; import javax.jcr.Node; import javax.jcr.PropertyType; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.SimpleCredentials; import javax.jcr.nodetype.NodeTypeManager; import javax.jcr.nodetype.NodeTypeTemplate; import javax.jcr.nodetype.PropertyDefinitionTemplate; import javax.jcr.query.qom.QueryObjectModelConstants; import javax.jcr.version.OnParentVersionAction; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.core.RepositoryImpl; import org.apache.jackrabbit.core.config.RepositoryConfig; import sun.net.www.MimeTable; public class ReproduceOPVIgnoreProblem { private static final String NT_RESOURCE = "my_Resource"; private static final String RESOURCE_PROP_TEST = "my_TestProperty"; private static final String CONTENT = "some information"; private static final String RES_NAME = "test.txt"; private RepositoryImpl repository; public static void main(String[] args) throws Exception { ReproduceOPVIgnoreProblem useCase = new ReproduceOPVIgnoreProblem(); useCase.run(); } private void run() throws IOException, RepositoryException { RepositoryConfig config = RepositoryConfig.install(new File("C:/JavaDev/jaRabT1/jrContent")); repository = RepositoryImpl.create(config); addResourceNodeType(); System.out.println("node type added"); createResourceAndCheckIn(); System.out.println("new node checked-in"); System.out.println("################# before change OPV property ####################"); changeOPVIgnoreproperty(); System.out.println("################# after change OPV property ####################"); deleteResource(); System.out.println("node deleted"); } private void deleteResource() throws RepositoryException { Session session = null; try { session = login(); Node node = session.getRootNode().getNode(RES_NAME); node.remove(); session.save(); } catch (Exception e) { e.printStackTrace(System.out); } finally { if (session != null) session.logout(); } } private void createResourceAndCheckIn() { Session session = null; try { session = login(); Node parentNode = session.getRootNode(); Node fileNode = parentNode.addNode(RES_NAME, NT_RESOURCE); fileNode.addMixin(JcrConstants.MIX_VERSIONABLE); fileNode.addMixin(JcrConstants.MIX_LOCKABLE); Node resNode = fileNode.addNode(JcrConstants.JCR_CONTENT, "nt:resource"); String mimeType = getMimeType(RES_NAME); resNode.setProperty("jcr:mimeType", mimeType); InputStream stream = new BufferedInputStream(new ByteArrayInputStream(CONTENT.getBytes())); Binary binary = session.getValueFactory().createBinary(stream); resNode.setProperty(JcrConstants.JCR_DATA ,binary); session.save(); session.getWorkspace().getVersionManager().checkin(fileNode.getPath()); } catch (Exception e) { e.printStackTrace(System.out); } finally { if (session != null) session.logout(); } } private void changeOPVIgnoreproperty () throws RepositoryException { Session session = null; try { session = login(); Node node = session.getRootNode().getNode(RES_NAME); node.setProperty(RESOURCE_PROP_TEST, "testValue"); session.save(); } catch (Exception e) { e.printStackTrace(System.out); } finally { if (session != null) session.logout(); } } private void addResourceNodeType() throws RepositoryException { Session session = null; try { session = login(); NodeTypeManager ntm =session.getWorkspace().getNodeTypeManager(); NodeTypeTemplate gcms_content = ntm.createNodeTypeTemplate(); gcms_content.setDeclaredSuperTypeNames(new String[]{JcrConstants.NT_FILE}); gcms_content.setName(NT_RESOURCE); gcms_content.setQueryable(true); @SuppressWarnings("unchecked") List propDefList = gcms_content.getPropertyDefinitionTemplates(); //additional properties PropertyDefinitionTemplate propDef = ntm.createPropertyDefinitionTemplate(); //ALL or REGISTERED propDef.setName(RESOURCE_PROP_TEST); propDef.setAutoCreated(false); propDef.setRequiredType(PropertyType.STRING); propDef.setAvailableQueryOperators(new String[] {QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO}); propDef.setOnParentVersion(OnParentVersionAction.IGNORE); propDefList.add(propDef); ntm.registerNodeType(gcms_content, true); } catch (Exception e) { e.printStackTrace(System.out); } finally { if (session != null) session.logout(); } } private String getMimeType(String fileName) { MimeTable mt = MimeTable.getDefaultTable(); String mimeType = mt.getContentTypeFor(fileName); if (mimeType==null) mimeType="application/octet-stream"; return mimeType; } private Session login () throws RepositoryException { return repository.login(new SimpleCredentials("admin","admin".toCharArray())); } } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira