exo-jcr SVN: r2435 - core/trunk/packaging/module/src/main/javascript.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-05-26 09:25:20 -0400 (Wed, 26 May 2010)
New Revision: 2435
Modified:
core/trunk/packaging/module/src/main/javascript/core.packaging.module.js
Log:
EXOJCR-640: updating packaging JS with correct pdfbox version
Modified: core/trunk/packaging/module/src/main/javascript/core.packaging.module.js
===================================================================
--- core/trunk/packaging/module/src/main/javascript/core.packaging.module.js 2010-05-26 09:00:09 UTC (rev 2434)
+++ core/trunk/packaging/module/src/main/javascript/core.packaging.module.js 2010-05-26 13:25:20 UTC (rev 2435)
@@ -38,7 +38,7 @@
module.component.documents =
new Project("org.exoplatform.core", "exo.core.component.document", "jar", module.version).
- addDependency(new Project("pdfbox", "pdfbox", "jar", "0.7.3")).
+ addDependency(new Project("org.apache.pdfbox", "pdfbox", "jar", "1.1.0")).
addDependency(new Project("com.lowagie", "itext", "jar", "2.1.0")).
addDependency(new Project("bouncycastle", "bcmail-jdk14", "jar", "136")).
addDependency(new Project("bouncycastle", "bcprov-jdk14", "jar", "136")).
15 years, 11 months
exo-jcr SVN: r2434 - kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-05-26 05:00:09 -0400 (Wed, 26 May 2010)
New Revision: 2434
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java
Log:
EXOJCR-743: InitialContextBinder bind twice same datasource in some case
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java 2010-05-26 08:54:41 UTC (rev 2433)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java 2010-05-26 09:00:09 UTC (rev 2434)
@@ -31,6 +31,7 @@
import java.util.Map.Entry;
+import javax.naming.NameAlreadyBoundException;
import javax.naming.NamingException;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
@@ -153,7 +154,14 @@
private void bind(String bindName, Reference reference) throws NamingException
{
- initialContextInitializer.getInitialContext().bind(bindName, reference);
+ try
+ {
+ initialContextInitializer.getInitialContext().bind(bindName, reference);
+ }
+ catch (NameAlreadyBoundException e)
+ {
+ initialContextInitializer.getInitialContext().rebind(bindName, reference);
+ }
bindings.put(bindName, reference);
}
15 years, 11 months
exo-jcr SVN: r2433 - in jcr/trunk/applications/exo.jcr.applications.backupconsole: bin and 1 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-05-26 04:54:41 -0400 (Wed, 26 May 2010)
New Revision: 2433
Added:
jcr/trunk/applications/exo.jcr.applications.backupconsole/readme.txt
Modified:
jcr/trunk/applications/exo.jcr.applications.backupconsole/bin/jcrbackup.cmd
jcr/trunk/applications/exo.jcr.applications.backupconsole/bin/jcrbackup.sh
jcr/trunk/applications/exo.jcr.applications.backupconsole/pom.xml
jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/assemblies/binary-assembly.xml
Log:
EXOJCR-741 Scripts and assembliy updated to not contain the version of product; deploy moved to a separate pfrofile; readme added
Modified: jcr/trunk/applications/exo.jcr.applications.backupconsole/bin/jcrbackup.cmd
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.backupconsole/bin/jcrbackup.cmd 2010-05-25 13:14:26 UTC (rev 2432)
+++ jcr/trunk/applications/exo.jcr.applications.backupconsole/bin/jcrbackup.cmd 2010-05-26 08:54:41 UTC (rev 2433)
@@ -1 +1 @@
-java -jar exo.jcr.applications.backupconsole-1.12.2-GA-SNAPSHOT.jar %*
+java -jar exo.jcr.applications.backupconsole-binary.jar %*
Modified: jcr/trunk/applications/exo.jcr.applications.backupconsole/bin/jcrbackup.sh
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.backupconsole/bin/jcrbackup.sh 2010-05-25 13:14:26 UTC (rev 2432)
+++ jcr/trunk/applications/exo.jcr.applications.backupconsole/bin/jcrbackup.sh 2010-05-26 08:54:41 UTC (rev 2433)
@@ -1,3 +1,3 @@
#!/bin/sh
-java -jar exo.jcr.applications.backupconsole-1.12.2-GA-SNAPSHOT.jar $*
+java -jar exo.jcr.applications.backupconsole-binary.jar $*
Modified: jcr/trunk/applications/exo.jcr.applications.backupconsole/pom.xml
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.backupconsole/pom.xml 2010-05-25 13:14:26 UTC (rev 2432)
+++ jcr/trunk/applications/exo.jcr.applications.backupconsole/pom.xml 2010-05-26 08:54:41 UTC (rev 2433)
@@ -80,26 +80,36 @@
</configuration>
</plugin>
</plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptors>
- <descriptor>${basedir}/src/main/assemblies/binary-assembly.xml</descriptor>
- </descriptors>
- <finalName>backupconsole</finalName>
- </configuration>
- <executions>
- <execution>
- <id>binary</id>
- <phase>package</phase>
- <goals>
- <goal>directory-single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ </pluginManagement>
+ </build>
+ <profiles>
+ <profile>
+ <id>deploy</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>${basedir}/src/main/assemblies/binary-assembly.xml</descriptor>
+ </descriptors>
+ <finalName>backupconsole</finalName>
+ </configuration>
+ <executions>
+ <execution>
+ <id>binary</id>
+ <phase>package</phase>
+ <goals>
+ <goal>directory-single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Added: jcr/trunk/applications/exo.jcr.applications.backupconsole/readme.txt
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.backupconsole/readme.txt (rev 0)
+++ jcr/trunk/applications/exo.jcr.applications.backupconsole/readme.txt 2010-05-26 08:54:41 UTC (rev 2433)
@@ -0,0 +1 @@
+To build backup console binary run "mvn clean install -P deploy"
Modified: jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/assemblies/binary-assembly.xml
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/assemblies/binary-assembly.xml 2010-05-25 13:14:26 UTC (rev 2432)
+++ jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/assemblies/binary-assembly.xml 2010-05-26 08:54:41 UTC (rev 2433)
@@ -21,50 +21,16 @@
<assembly>
<id>binary</id>
<includeBaseDirectory>false</includeBaseDirectory>
- <fileSets>
- <fileSet>
- <directory>bin</directory>
- <outputDirectory>/</outputDirectory>
- <includes>
- <include>**/*.cmd</include>
- <include>**/*.sh</include>
- </includes>
- </fileSet>
- <fileSet>
- <outputDirectory>/</outputDirectory>
- <includes>
- <include>bin/**/*</include>
- </includes>
- <excludes>
- <exclude>bin/**/*.cmd</exclude>
- <exclude>bin/**/*.sh</exclude>
- </excludes>
- </fileSet>
- <fileSet>
- <includes>
- <include>logs/**/*</include>
- </includes>
- </fileSet>
- <!--fileSet>
- <directory>target</directory>
- <outputDirectory>/</outputDirectory>
- <includes>
- <include>*.jar</include>
- </includes>
- </fileSet-->
- </fileSets>
- <!--files>
+ <files>
<file>
- <source/>
- <outputDirectory/>
- <destName/>
- <fileMode/>
- <lineEnding/>
- <filtered/>
+ <source>target/${project.artifactId}-${project.version}.jar</source>
+ <destName>${project.artifactId}-binary.jar</destName>
</file>
- </files-->
-
-
+ <file>
+ <source>target/${project.artifactId}-${project.version}-sources.jar</source>
+ <destName>${project.artifactId}-binary-sources.jar</destName>
+ </file>
+ </files>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
@@ -75,6 +41,7 @@
<exclude>commons-lang:commons-lang</exclude>
<exclude>xpp3:xpp3</exclude>
<exclude>org.exoplatform.tool:exo.tool.framework.junit</exclude>
+ <exclude>org.exoplatform.jcr:exo.jcr.applications.backupconsole</exclude>
<exclude>javax.portlet:portlet-api</exclude>
<exclude>javax.faces:jsf-api</exclude>
<exclude>javax.servlet:servlet-api</exclude>
@@ -95,7 +62,16 @@
<exclude>javax.transaction:jta</exclude>
<exclude>stax:stax-api</exclude>
</excludes>
-
</dependencySet>
</dependencySets>
+ <fileSets>
+ <fileSet>
+ <directory>${basedir}/bin</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>*.cmd</include>
+ <include>*.sh</include>
+ </includes>
+ </fileSet>
+ </fileSets>
</assembly>
15 years, 11 months
exo-jcr SVN: r2432 - in core/trunk/exo.core.component.document/src: test/java/org/exoplatform/services/document/test and 1 other directories.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-05-25 09:14:26 -0400 (Tue, 25 May 2010)
New Revision: 2432
Added:
core/trunk/exo.core.component.document/src/test/resources/testCDATA.xml
core/trunk/exo.core.component.document/src/test/resources/testUTF8.xml
Modified:
core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/XMLDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestXMLDocumentReader.java
Log:
EXOJCR-738: XMLDocumentReader now uses SAXParser. Test added.
Modified: core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/XMLDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/XMLDocumentReader.java 2010-05-25 07:37:50 UTC (rev 2431)
+++ core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/XMLDocumentReader.java 2010-05-25 13:14:26 UTC (rev 2432)
@@ -19,15 +19,19 @@
package org.exoplatform.services.document.impl;
import org.exoplatform.services.document.DocumentReadException;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.StringWriter;
+import java.io.Writer;
import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
/**
* Created by The eXo Platform SAS A parser of XML files.
*
@@ -61,14 +65,15 @@
}
try
{
- byte[] buffer = new byte[2048];
- int len;
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- while ((len = is.read(buffer)) > 0)
- bos.write(buffer, 0, len);
- bos.close();
- String xml = new String(bos.toByteArray());
- return delete(xml);
+
+ // byte[] buffer = new byte[2048];
+ // int len;
+ // ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ // while ((len = is.read(buffer)) > 0)
+ // bos.write(buffer, 0, len);
+ // bos.close();
+ // String xml = new String(bos.toByteArray());
+ return parse(is);
}
finally
{
@@ -113,27 +118,74 @@
* @param str the string which contain a text with user's tags.
* @return The string cleaned from user's tags and their bodies.
*/
- private String delete(String str)
+ private String parse(InputStream is)
{
+ SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
+ // saxParserFactory.setNamespaceAware(true);
+ // saxParserFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ SAXParser saxParser;
+ StringWriter writer = new StringWriter();
+
+ DefaultHandler dh = new WriteOutContentHandler(writer);
try
{
- StringBuffer input = new StringBuffer(str);
- String patternString = "<+[^>]*>+";
- Pattern pattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE + Pattern.DOTALL);
- Matcher matcher = pattern.matcher(input);
- while (matcher.find())
+ saxParser = saxParserFactory.newSAXParser();
+ saxParser.parse(is, dh);
+ }
+ catch (SAXException e)
+ {
+ return "";
+ }
+ catch (IOException e)
+ {
+ return "";
+ }
+ catch (ParserConfigurationException e)
+ {
+ return "";
+ }
+
+ return writer.toString();
+
+ }
+
+ class WriteOutContentHandler extends DefaultHandler
+ {
+ private final Writer writer;
+
+ public WriteOutContentHandler(Writer writer)
+ {
+ this.writer = writer;
+ }
+
+ /**
+ * Writes the given characters to the given character stream.
+ */
+ @Override
+ public void characters(char[] ch, int start, int length) throws SAXException
+ {
+ try
{
- int start = matcher.start();
- int end = matcher.end();
- input.delete(start, end);
- matcher = pattern.matcher(input);
+ writer.write(ch, start, length);
}
- return input.substring(0, input.length());
+ catch (IOException e)
+ {
+ throw new SAXException(e.getMessage(), e);
+ }
}
- catch (PatternSyntaxException e)
+
+ @Override
+ public void endDocument() throws SAXException
{
+ try
+ {
+ writer.flush();
+ }
+ catch (IOException e)
+ {
+ throw new SAXException(e.getMessage(), e);
+ }
}
- return "";
}
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestXMLDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestXMLDocumentReader.java 2010-05-25 07:37:50 UTC (rev 2431)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestXMLDocumentReader.java 2010-05-25 13:14:26 UTC (rev 2432)
@@ -45,7 +45,26 @@
{
InputStream is = TestXMLDocumentReader.class.getResourceAsStream("/test.xml");
String text = service_.getDocumentReader("text/xml").getContentAsText(is);
- String etalon = "\n\n John\n" + " Alice\n" + " Reminder\n" + " Don't forget it this weekend!\n\n";
- assertEquals("Wrong string returned", etalon, text);
+ String expected = "John\n" + " Alice\n" + " Reminder\n" + " Don't forget it this weekend!";
+ assertEquals("Wrong string returned", expected, text.trim());
}
+
+ public void testCDATAGetContentAsString() throws Exception
+ {
+ InputStream is = TestXMLDocumentReader.class.getResourceAsStream("/testCDATA.xml");
+ String text = service_.getDocumentReader("text/xml").getContentAsText(is);
+ String expected = "This is a text inside CDATA.";
+ assertEquals("Wrong string returned", expected, text.trim());
+ }
+
+ public void testI18ngetContentAsString() throws Exception
+ {
+ InputStream is = TestXMLDocumentReader.class.getResourceAsStream("/testUTF8.xml");
+ String text = service_.getDocumentReader("text/xml").getContentAsText(is);
+ final String expected =
+ "\u0426\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u0438\u0439 \u0442\u0435\u043a\u0441\u0442.\n"
+ + "Archim\u00E8de et Lius \u00E0 Ch\u00E2teauneuf testing chars en \u00E9t\u00E9";
+ assertEquals("Wrong string returned", expected, text.trim());
+ }
+
}
Added: core/trunk/exo.core.component.document/src/test/resources/testCDATA.xml
===================================================================
--- core/trunk/exo.core.component.document/src/test/resources/testCDATA.xml (rev 0)
+++ core/trunk/exo.core.component.document/src/test/resources/testCDATA.xml 2010-05-25 13:14:26 UTC (rev 2432)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<Module>
+ <ModulePrefs title="Hello World! title" />
+ <Content type="html">
+<![CDATA[This is a text inside CDATA.]]></Content>
+</Module>
\ No newline at end of file
Added: core/trunk/exo.core.component.document/src/test/resources/testUTF8.xml
===================================================================
--- core/trunk/exo.core.component.document/src/test/resources/testUTF8.xml (rev 0)
+++ core/trunk/exo.core.component.document/src/test/resources/testUTF8.xml 2010-05-25 13:14:26 UTC (rev 2432)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<Module>
+ <ModulePrefs title="Hello World! title" />
+ <Content type="html">
+ <Title>Це тестовий текст.</Title>
+<![CDATA[Archimède et Lius à Châteauneuf testing chars en été]]></Content>
+</Module>
\ No newline at end of file
15 years, 11 months
exo-jcr SVN: r2431 - jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-05-25 03:37:50 -0400 (Tue, 25 May 2010)
New Revision: 2431
Modified:
jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
Log:
EXOJCR-157: Disable deleting of the repository which is set as default
Modified: jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java 2010-05-21 12:21:59 UTC (rev 2430)
+++ jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java 2010-05-25 07:37:50 UTC (rev 2431)
@@ -108,6 +108,9 @@
public boolean canRemoveRepository(String name) throws RepositoryException
{
+ if (name.equals(config.getDefaultRepositoryName()))
+ return false;
+
RepositoryImpl repo = (RepositoryImpl)getRepository(name);
try
{
15 years, 11 months
exo-jcr SVN: r2430 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core and 4 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-05-21 08:21:59 -0400 (Fri, 21 May 2010)
New Revision: 2430
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsValidator.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/NodeTypeData.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemDefinitionImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeDefinitionImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDefinitionImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/PropertyDefinitionImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDataValidator.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsMatcher.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/nodetypes/TestValueConstraints.java
Log:
EXOJCR-668 default values format validation added on NT registration
EXOJCR-740 constraint ranges support added; BOOLEAN constraint support added
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/NodeTypeData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/NodeTypeData.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/NodeTypeData.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -25,17 +25,12 @@
/**
* @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
- * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
+ * @version $Id$
*
*/
public interface NodeTypeData
{
-// /**
-// * @return the isAbstract
-// */
-// public boolean isAbstract();
-
/**
*
* @return
@@ -91,13 +86,4 @@
* @throws NodeTypeReadException
*/
public boolean isMixin();
-
-// /**
-// *
-// * @return
-// * @throws RepositoryException
-// * @throws NodeTypeReadException
-// */
-// public boolean isQueryable();
-
}
\ No newline at end of file
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/NodeTypeData.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -74,7 +74,7 @@
* Created by The eXo Platform SAS.
*
* @author Gennady Azarenkov
- * @version $Id: ItemImpl.java 14590 2008-05-22 08:51:29Z pnedonosko $
+ * @version $Id$
*/
public abstract class ItemImpl implements Item
{
@@ -459,7 +459,9 @@
}
if (defs == null || defs.getAnyDefinition() == null)
+ {
throw new RepositoryException("Property definition '" + propertyName.getAsString() + "' is not found.");
+ }
PropertyDefinitionData def = defs.getDefinition(isMultiValue);
if (def != null && def.isProtected())
@@ -941,9 +943,8 @@
}
private void checkValueConstraints(PropertyDefinitionData def, List<ValueData> newValues, int type)
- throws ConstraintViolationException, RepositoryException
+ throws RepositoryException
{
-
ValueConstraintsMatcher constraints =
new ValueConstraintsMatcher(def.getValueConstraints(), session.getLocationFactory(), session
.getTransientNodesManager(), session.getWorkspace().getNodeTypesHolder());
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -788,7 +788,7 @@
new InternalQName[]{requiredName}, null, true);
this.nodeDefinition =
new NodeDefinitionImpl(ntData, nodeTypesHolder, nodeTypeManager, sysLocFactory, session
- .getValueFactory());
+ .getValueFactory(), session.getTransientNodesManager());
}
}
else
@@ -815,7 +815,7 @@
nodeDefinition =
new NodeDefinitionImpl(definition, nodeTypesHolder, nodeTypeManager, sysLocFactory, session
- .getValueFactory());
+ .getValueFactory(), session.getTransientNodesManager());
}
}
@@ -1935,9 +1935,9 @@
public void setPermissions(Map permissions) throws RepositoryException, AccessDeniedException,
AccessControlException
{
-
+
checkValid();
-
+
if (!isNodeType(Constants.EXO_PRIVILEGEABLE))
{
throw new AccessControlException("Node is not exo:privilegeable " + getPath());
@@ -1967,7 +1967,7 @@
aces.add(ace);
}
}
-
+
AccessControlList acl = new AccessControlList(getACL().getOwner(), aces);
setACL(acl);
updatePermissions(acl);
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -337,8 +337,7 @@
return new PropertyDefinitionImpl(propertyDef, session.getWorkspace().getNodeTypesHolder(),
(ExtendedNodeTypeManager)session.getWorkspace().getNodeTypeManager(), session.getSystemLocationFactory(),
- session.getValueFactory());
-
+ session.getValueFactory(), session.getTransientNodesManager());
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -275,7 +275,8 @@
public NodeTypeManager getNodeTypeManager() throws RepositoryException
{
// incl Session mapping
- return new NodeTypeManagerImpl(session.getLocationFactory(), session.getValueFactory(), nodeTypeManager);
+ return new NodeTypeManagerImpl(session.getLocationFactory(), session.getValueFactory(), nodeTypeManager, session
+ .getTransientNodesManager());
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemDefinitionImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemDefinitionImpl.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemDefinitionImpl.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.core.nodetype.ExtendedNodeTypeManager;
import org.exoplatform.services.jcr.core.nodetype.ItemDefinitionData;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
+import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
@@ -51,6 +52,8 @@
protected final ExtendedNodeTypeManager nodeTypeManager;
protected final ValueFactory valueFactory;
+
+ protected final ItemDataConsumer dataManager;
private final ItemDefinitionData itemDefinitionData;
@@ -63,14 +66,14 @@
* @param protectedItem
*/
public ItemDefinitionImpl(ItemDefinitionData itemDefinitionData, NodeTypeDataManager nodeTypeDataManager,
- ExtendedNodeTypeManager nodeTypeManager, LocationFactory locationFactory, ValueFactory valueFactory)
+ ExtendedNodeTypeManager nodeTypeManager, LocationFactory locationFactory, ValueFactory valueFactory, ItemDataConsumer dataManager)
{
-
this.itemDefinitionData = itemDefinitionData;
this.nodeTypeDataManager = nodeTypeDataManager;
this.nodeTypeManager = nodeTypeManager;
this.locationFactory = locationFactory;
this.valueFactory = valueFactory;
+ this.dataManager = dataManager;
}
/**
@@ -78,9 +81,8 @@
*/
public NodeType getDeclaringNodeType()
{
-
return new NodeTypeImpl(nodeTypeDataManager.getNodeType(itemDefinitionData.getDeclaringNodeType()),
- nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory);
+ nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory, dataManager);
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeDefinitionImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeDefinitionImpl.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeDefinitionImpl.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.core.nodetype.NodeDefinitionData;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
+import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.log.ExoLogger;
@@ -55,11 +56,11 @@
* @param valueFactory
*/
public NodeDefinitionImpl(NodeDefinitionData nodeDefinitionData, NodeTypeDataManager nodeTypeDataManager,
- ExtendedNodeTypeManager nodeTypeManager, LocationFactory locationFactory, ValueFactory valueFactory)
+ ExtendedNodeTypeManager nodeTypeManager, LocationFactory locationFactory, ValueFactory valueFactory,
+ ItemDataConsumer dataManager)
{
- super(nodeDefinitionData, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory);
+ super(nodeDefinitionData, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory, dataManager);
this.nodeDefinitionData = nodeDefinitionData;
-
}
/**
@@ -85,7 +86,7 @@
if (nodeDefinitionData.getDefaultPrimaryType() == null)
return null;
return new NodeTypeImpl(nodeTypeDataManager.getNodeType(nodeDefinitionData.getDefaultPrimaryType()),
- nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory);
+ nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory, dataManager);
}
/**
@@ -162,7 +163,9 @@
LOG.error("NODE TYPE NOT FOUND " + requiredPrimaryTypes[i].getAsString());
}
else
- result[i] = new NodeTypeImpl(ntData, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory);
+ result[i] =
+ new NodeTypeImpl(ntData, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory,
+ dataManager);
}
return result;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -100,6 +100,10 @@
protected final NodeTypeRepository nodeTypeRepository;
+ protected final NodeTypeConverter nodeTypeConverter;
+
+ protected final NodeTypeDataValidator nodeTypeDataValidator;
+
/**
* Listeners (soft references)
*/
@@ -109,37 +113,21 @@
private boolean started = false;
- public NodeTypeDataManagerImpl(final RepositoryEntry config, final LocationFactory locationFactory,
- final NamespaceRegistry namespaceRegistry, final NodeTypeDataPersister persister,
- final ItemDataConsumer dataManager, final RepositoryIndexSearcherHolder indexSearcherHolder)
- throws RepositoryException
- {
-
- this.namespaceRegistry = namespaceRegistry;
-
- this.locationFactory = locationFactory;
- this.dataManager = dataManager;
- this.indexSearcherHolder = indexSearcherHolder;
-
- this.valueFactory = new ValueFactoryImpl(locationFactory);
- this.accessControlPolicy = config.getAccessControl();
-
- this.nodeTypeRepository = new InmemoryNodeTypeRepository(persister);
- this.listeners = Collections.synchronizedMap(new WeakHashMap<NodeTypeManagerListener, NodeTypeManagerListener>());
- this.buildInNodeTypesNames = new HashSet<InternalQName>();
- }
-
/**
- * @param accessControlPolicy
- * @param locationFactory
- * @param namespaceRegistry
- * @param persister
- * @throws RepositoryException
+ * NodeTypeDataManagerImpl constructor.
+ *
+ * @param accessControlPolicy String
+ * @param locationFactory LocationFactory
+ * @param namespaceRegistry NamespaceRegistry
+ * @param persister NodeTypeDataPersister
+ * @param dataManager ItemDataConsumer
+ * @param indexSearcherHolder RepositoryIndexSearcherHolder
+ * @param nodeTypeRepository NodeTypeRepository
*/
public NodeTypeDataManagerImpl(final String accessControlPolicy, final LocationFactory locationFactory,
final NamespaceRegistry namespaceRegistry, final NodeTypeDataPersister persister,
final ItemDataConsumer dataManager, final RepositoryIndexSearcherHolder indexSearcherHolder,
- final NodeTypeRepository nodeTypeRepository) throws RepositoryException
+ final NodeTypeRepository nodeTypeRepository)
{
this.namespaceRegistry = namespaceRegistry;
@@ -153,9 +141,30 @@
this.nodeTypeRepository = nodeTypeRepository;
this.listeners = Collections.synchronizedMap(new WeakHashMap<NodeTypeManagerListener, NodeTypeManagerListener>());
this.buildInNodeTypesNames = new HashSet<InternalQName>();
+
+ this.nodeTypeConverter = new NodeTypeConverter(this.locationFactory, this.accessControlPolicy);
+ this.nodeTypeDataValidator = new NodeTypeDataValidator(this.locationFactory, this.nodeTypeRepository);
}
/**
+ * Constructor for in-container use.
+ *
+ * @param config RepositoryEntry
+ * @param locationFactory LocationFactory
+ * @param namespaceRegistry NamespaceRegistry
+ * @param persister NodeTypeDataPersister
+ * @param dataManager ItemDataConsumer
+ * @param indexSearcherHolder RepositoryIndexSearcherHolder
+ */
+ public NodeTypeDataManagerImpl(final RepositoryEntry config, final LocationFactory locationFactory,
+ final NamespaceRegistry namespaceRegistry, final NodeTypeDataPersister persister,
+ final ItemDataConsumer dataManager, final RepositoryIndexSearcherHolder indexSearcherHolder)
+ {
+ this(config.getAccessControl(), locationFactory, namespaceRegistry, persister, dataManager, indexSearcherHolder,
+ new InmemoryNodeTypeRepository(persister));
+ }
+
+ /**
* Add a <code>NodeTypeRegistryListener</code>
*
* @param listener the new listener to be informed on (un)registration of node
@@ -580,9 +589,6 @@
public List<NodeTypeData> registerNodeTypes(final InputStream is, final int alreadyExistsBehaviour,
final String contentType) throws RepositoryException
{
-
- final NodeTypeConverter nodeTypeConverter = new NodeTypeConverter(this.locationFactory, this.accessControlPolicy);
- final NodeTypeDataValidator nodeTypeDataValidator = new NodeTypeDataValidator(this.nodeTypeRepository);
NodeTypeDataPersister serializer = null;
if (contentType.equalsIgnoreCase(TEXT_XML))
{
@@ -611,9 +617,6 @@
public List<NodeTypeData> registerNodeTypes(final List<NodeTypeValue> ntvalues, final int alreadyExistsBehaviour)
throws RepositoryException
{
-
- final NodeTypeConverter nodeTypeConverter = new NodeTypeConverter(this.locationFactory, this.accessControlPolicy);
- final NodeTypeDataValidator nodeTypeDataValidator = new NodeTypeDataValidator(this.nodeTypeRepository);
// convert to Node data.
final List<NodeTypeData> nodeTypes = nodeTypeConverter.convertFromValueToData(ntvalues);
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDefinitionImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDefinitionImpl.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDefinitionImpl.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.core.nodetype.ExtendedNodeTypeManager;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
+import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -53,6 +54,8 @@
protected final ValueFactory valueFactory;
+ protected final ItemDataConsumer dataManager;
+
/**
* @param name
* @param declaredChildNodeDefinitions
@@ -64,7 +67,8 @@
* @param primaryItemName
*/
public NodeTypeDefinitionImpl(NodeTypeData nodeTypeData, NodeTypeDataManager nodeTypeDataManager,
- ExtendedNodeTypeManager nodeTypeManager, LocationFactory locationFactory, ValueFactory valueFactory)
+ ExtendedNodeTypeManager nodeTypeManager, LocationFactory locationFactory, ValueFactory valueFactory,
+ ItemDataConsumer dataManager)
{
super();
this.nodeTypeData = nodeTypeData;
@@ -72,7 +76,7 @@
this.nodeTypeManager = nodeTypeManager;
this.locationFactory = locationFactory;
this.valueFactory = valueFactory;
-
+ this.dataManager = dataManager;
}
/**
@@ -118,7 +122,7 @@
{
result[i] =
new NodeDefinitionImpl(nodeTypeData.getDeclaredChildNodeDefinitions()[i], nodeTypeDataManager,
- nodeTypeManager, locationFactory, valueFactory);
+ nodeTypeManager, locationFactory, valueFactory, dataManager);
}
return result;
}
@@ -133,7 +137,7 @@
{
result[i] =
new PropertyDefinitionImpl(nodeTypeData.getDeclaredPropertyDefinitions()[i], nodeTypeDataManager,
- nodeTypeManager, locationFactory, valueFactory);
+ nodeTypeManager, locationFactory, valueFactory, dataManager);
}
return result;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeImpl.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeImpl.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -24,10 +24,12 @@
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionData;
import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionDatas;
+import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
-import org.exoplatform.services.jcr.impl.core.nodetype.registration.NodeTypeReadException;
+import org.exoplatform.services.jcr.impl.core.value.BaseValue;
+import org.exoplatform.services.jcr.impl.core.value.ValueConstraintsMatcher;
import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -66,19 +68,20 @@
protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.NodeTypeImpl");
/**
- * @param nodeTypeData
- * @param nodeTypeDataManager
- * @param nodeTypeManager
- * @param locationFactory
- * @param valueFactory
- * @throws RepositoryException
- * @throws NodeTypeReadException
+ * NodeTypeImpl contructor.
+ *
+ * @param nodeTypeData NodeTypeData
+ * @param nodeTypeDataManager NodeTypeDataManager
+ * @param nodeTypeManager ExtendedNodeTypeManager
+ * @param locationFactory LocationFactory
+ * @param valueFactory ValueFactory
+ * @param dataManager ItemDataConsumer
*/
public NodeTypeImpl(NodeTypeData nodeTypeData, NodeTypeDataManager nodeTypeDataManager,
- ExtendedNodeTypeManager nodeTypeManager, LocationFactory locationFactory, ValueFactory valueFactory)
+ ExtendedNodeTypeManager nodeTypeManager, LocationFactory locationFactory, ValueFactory valueFactory,
+ ItemDataConsumer dataManager)
{
- super(nodeTypeData, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory);
-
+ super(nodeTypeData, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory, dataManager);
}
/**
@@ -86,7 +89,6 @@
*/
public boolean canAddChildNode(String childNodeName)
{
-
try
{
InternalQName cname = locationFactory.parseJCRName(childNodeName).getInternalName();
@@ -169,14 +171,20 @@
if (pd != null)
{
if (pd.isProtected())
+ {
// can set (edit)
return false;
+ }
else if (value != null)
+ {
// can set (add or edit)
return canSetPropertyForType(pd.getRequiredType(), value, pd.getValueConstraints());
+ }
else
+ {
// can remove
return !pd.isMandatory();
+ }
}
}
return false;
@@ -202,8 +210,10 @@
if (pd != null)
{
if (pd.isProtected())
+ {
// can set (edit)
return false;
+ }
else if (values != null)
{
// can set (add or edit)
@@ -211,16 +221,22 @@
for (Value value : values)
{
if (canSetPropertyForType(pd.getRequiredType(), value, pd.getValueConstraints()))
+ {
res++;
+ }
}
return res == values.length;
}
else
+ {
// can remove
return !pd.isMandatory();
+ }
}
else
+ {
return false;
+ }
}
catch (RepositoryException e)
{
@@ -240,7 +256,9 @@
for (int i = 0; i < nodeDefs.length; i++)
{
NodeDefinitionData cnd = nodeDefs[i];
- ndefs[i] = new NodeDefinitionImpl(cnd, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory);
+ ndefs[i] =
+ new NodeDefinitionImpl(cnd, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory,
+ dataManager);
}
return ndefs;
@@ -256,7 +274,9 @@
for (int i = 0; i < cndefs.length; i++)
{
NodeDefinitionData cnd = cndefs[i];
- ndefs[i] = new NodeDefinitionImpl(cnd, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory);
+ ndefs[i] =
+ new NodeDefinitionImpl(cnd, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory,
+ dataManager);
}
return ndefs;
@@ -281,7 +301,8 @@
{
NodeTypeData superNodeTypeData = nodeTypeDataManager.getNodeType(snames[i]);
supers[i] =
- new NodeTypeImpl(superNodeTypeData, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory);
+ new NodeTypeImpl(superNodeTypeData, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory,
+ dataManager);
}
return supers;
@@ -421,35 +442,35 @@
*
* @param requiredType - type.
* @param value - value.
- * @param constrains - constrains.
+ * @param constraints - constraints.
* @return a boolean.
*/
- private boolean canSetPropertyForType(int requiredType, Value value, String[] constrains)
+ private boolean canSetPropertyForType(int requiredType, Value value, String[] constraints)
{
if (requiredType == value.getType())
{
- return checkValueConstraints(constrains, value);
+ return checkValueConstraints(requiredType, constraints, value);
}
else if (requiredType == PropertyType.BINARY
&& (value.getType() == PropertyType.STRING || value.getType() == PropertyType.DATE
|| value.getType() == PropertyType.LONG || value.getType() == PropertyType.DOUBLE
|| value.getType() == PropertyType.NAME || value.getType() == PropertyType.PATH || value.getType() == PropertyType.BOOLEAN))
{
- return checkValueConstraints(constrains, value);
+ return checkValueConstraints(requiredType, constraints, value);
}
else if (requiredType == PropertyType.BOOLEAN)
{
if (value.getType() == PropertyType.STRING)
{
- return checkValueConstraints(constrains, value);
+ return checkValueConstraints(requiredType, constraints, value);
}
else if (value.getType() == PropertyType.BINARY)
{
try
{
return isCharsetString(value.getString(), Constants.DEFAULT_ENCODING)
- && checkValueConstraints(constrains, value);
+ && checkValueConstraints(requiredType, constraints, value);
}
catch (Exception e)
{
@@ -477,7 +498,7 @@
}
else if (value.getType() == PropertyType.DOUBLE || value.getType() == PropertyType.LONG)
{
- return checkValueConstraints(constrains, value);
+ return checkValueConstraints(requiredType, constraints, value);
}
else
{
@@ -486,7 +507,7 @@
// try parse...
JCRDateFormat.parse(likeDataString);
// validate
- return checkValueConstraints(constrains, value);
+ return checkValueConstraints(requiredType, constraints, value);
}
catch (Exception e)
{
@@ -513,14 +534,14 @@
}
else if (value.getType() == PropertyType.LONG)
{
- return checkValueConstraints(constrains, value);
+ return checkValueConstraints(requiredType, constraints, value);
}
else
{
return false;
}
Double doubleValue = new Double(likeDoubleString);
- return doubleValue != null && checkValueConstraints(constrains, value);
+ return doubleValue != null && checkValueConstraints(requiredType, constraints, value);
}
catch (Exception e)
{
@@ -554,7 +575,7 @@
return false;
}
Long longValue = new Long(likeLongString);
- return longValue != null && checkValueConstraints(constrains, value);
+ return longValue != null && checkValueConstraints(requiredType, constraints, value);
}
catch (Exception e)
{
@@ -591,11 +612,11 @@
// Path is relative
// TRUE if it is one element long
// and has no index
- return checkValueConstraints(constrains, value);
+ return checkValueConstraints(requiredType, constraints, value);
}
else if (pathString.startsWith("/") && pathString.lastIndexOf("/") < 1 && pathString.indexOf("[") < 0)
{
- return checkValueConstraints(constrains, value);
+ return checkValueConstraints(requiredType, constraints, value);
}
else
{
@@ -609,7 +630,7 @@
try
{
Value nameValue = valueFactory.createValue(likeNameString, requiredType);
- return nameValue != null && checkValueConstraints(constrains, value);
+ return nameValue != null && checkValueConstraints(requiredType, constraints, value);
}
catch (Exception e)
{
@@ -636,7 +657,7 @@
}
else if (value.getType() == PropertyType.NAME)
{
- return checkValueConstraints(constrains, value);
+ return checkValueConstraints(requiredType, constraints, value);
}
else
{
@@ -645,7 +666,7 @@
try
{
Value nameValue = valueFactory.createValue(likeNameString, requiredType);
- return nameValue != null && checkValueConstraints(constrains, value);
+ return nameValue != null && checkValueConstraints(requiredType, constraints, value);
}
catch (Exception e)
{
@@ -676,7 +697,7 @@
{
return false;
}
- return likeStringString != null && checkValueConstraints(constrains, value);
+ return likeStringString != null && checkValueConstraints(requiredType, constraints, value);
}
catch (Exception e)
{
@@ -685,7 +706,7 @@
}
else if (requiredType == PropertyType.UNDEFINED)
{
- return checkValueConstraints(constrains, value);
+ return checkValueConstraints(requiredType, constraints, value);
}
else
{
@@ -696,34 +717,47 @@
/**
* Check value constrains.
*
+ * @param requiredType int
* @param constraints - string constrains.
* @param value - value to check.
* @return result of check.
*/
- private boolean checkValueConstraints(String[] constraints, Value value)
+ private boolean checkValueConstraints(int requiredType, String[] constraints, Value value)
{
+ ValueConstraintsMatcher constrMatcher =
+ new ValueConstraintsMatcher(constraints, locationFactory, dataManager, nodeTypeDataManager);
- if (constraints != null && constraints.length > 0)
+ try
{
- for (int i = 0; i < constraints.length; i++)
- {
- try
- {
- if (constraints[i].equals(value.getString()))
- {
- return true;
- }
- }
- catch (RepositoryException e)
- {
- LOG.error("Can't get value's string value " + e, e);
- }
- }
+ return constrMatcher.match(((BaseValue)value).getInternalData(), requiredType);
}
- else
- return true;
+ catch (RepositoryException e1)
+ {
+ return false;
+ }
- return false;
+ // TODO old code
+ // if (constraints != null && constraints.length > 0)
+ // {
+ // for (int i = 0; i < constraints.length; i++)
+ // {
+ // try
+ // {
+ // if (constraints[i].equals(value.getString()))
+ // {
+ // return true;
+ // }
+ // }
+ // catch (RepositoryException e)
+ // {
+ // LOG.error("Can't get value's string value " + e, e);
+ // }
+ // }
+ // }
+ // else
+ // return true;
+ //
+ // return false;
}
private String getCharsetString(String source, String charSetName)
@@ -764,7 +798,8 @@
for (int i = 0; i < pdefs.length; i++)
{
propertyDefinitions[i] =
- new PropertyDefinitionImpl(pdefs[i], nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory);
+ new PropertyDefinitionImpl(pdefs[i], nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory,
+ dataManager);
}
return propertyDefinitions;
}
@@ -781,30 +816,4 @@
return false;
}
}
-
- /**
- * @param nodeTypeData
- * @return
- * @throws NoSuchNodeTypeException
- * @throws RepositoryException
- */
- private NodeDefinition makeNodeDefinition(NodeDefinitionData nodeTypeData) throws NoSuchNodeTypeException,
- RepositoryException
- {
- InternalQName[] rnames = nodeTypeData.getRequiredPrimaryTypes();
- NodeType[] rnts = new NodeType[rnames.length];
- for (int j = 0; j < rnames.length; j++)
- {
- rnts[j] = nodeTypeManager.findNodeType(rnames[j]);
- }
-
- String name =
- locationFactory
- .createJCRName(nodeTypeData.getName() != null ? nodeTypeData.getName() : Constants.JCR_ANY_NAME)
- .getAsString();
- NodeType defType =
- nodeTypeData.getDefaultPrimaryType() != null ? nodeTypeManager.findNodeType(nodeTypeData
- .getDefaultPrimaryType()) : null;
- return new NodeDefinitionImpl(nodeTypeData, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory);
- }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeManagerImpl.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeManagerImpl.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -26,6 +26,7 @@
import org.exoplatform.services.jcr.core.nodetype.NodeTypeValue;
import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionData;
import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionValue;
+import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
@@ -53,8 +54,7 @@
* Created by The eXo Platform SAS.
*
* @author <a href="mailto:geaz@users.sourceforge.net">Gennady Azarenkov </a>
- * @version $Id: NodeTypeManagerImpl.java 13986 2008-05-08 10:48:43Z pnedonosko
- * $
+ * @version $Id: NodeTypeManagerImpl.java 13986 2008-05-08 10:48:43Z pnedonosko$
*/
public class NodeTypeManagerImpl implements ExtendedNodeTypeManager
{
@@ -68,14 +68,16 @@
protected final LocationFactory locationFactory;
protected final NodeTypeDataManager typesManager;
+
+ protected final ItemDataConsumer dataManager;
public NodeTypeManagerImpl(LocationFactory locationFactory, ValueFactoryImpl valueFactory,
- NodeTypeDataManager typesManager)
+ NodeTypeDataManager typesManager, ItemDataConsumer dataManager)
{
this.valueFactory = valueFactory;
this.locationFactory = locationFactory;
this.typesManager = typesManager;
-
+ this.dataManager = dataManager;
}
// JSR-170 stuff ================================
@@ -85,8 +87,9 @@
NodeTypeData ntdata = typesManager.getNodeType(nodeTypeName);
if (ntdata != null)
- return new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory);
-
+ {
+ return new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory, dataManager);
+ }
throw new NoSuchNodeTypeException("Nodetype not found " + nodeTypeName.getAsString());
}
@@ -99,8 +102,9 @@
List<NodeTypeData> allNts = typesManager.getAllNodeTypes();
for (NodeTypeData ntdata : allNts)
- ec.add(new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory));
-
+ {
+ ec.add(new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory, dataManager));
+ }
return ec;
}
@@ -120,8 +124,9 @@
for (NodeTypeData nodeTypeData : allNodeTypes)
{
if (nodeTypeData.isMixin())
- ec.add(new NodeTypeImpl(nodeTypeData, typesManager, this, locationFactory, valueFactory));
-
+ {
+ ec.add(new NodeTypeImpl(nodeTypeData, typesManager, this, locationFactory, valueFactory, dataManager));
+ }
}
return ec;
}
@@ -133,8 +138,9 @@
{
NodeTypeData ntdata = typesManager.getNodeType(locationFactory.parseJCRName(nodeTypeName).getInternalName());
if (ntdata != null)
- return new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory);
-
+ {
+ return new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory, dataManager);
+ }
throw new NoSuchNodeTypeException("Nodetype not found " + nodeTypeName);
}
@@ -193,7 +199,6 @@
}
throw new NoSuchNodeTypeException("Nodetype not found " + nodeTypeName);
-
}
/**
@@ -210,7 +215,9 @@
{
NodeType type = allTypes.nextNodeType();
if (!type.isMixin())
+ {
ec.add(type);
+ }
}
return ec;
}
@@ -245,12 +252,12 @@
public NodeTypeIterator registerNodeTypes(List<NodeTypeValue> values, int alreadyExistsBehaviour)
throws UnsupportedRepositoryOperationException, RepositoryException
{
-
Collection<NodeTypeData> nts = typesManager.registerNodeTypes(values, alreadyExistsBehaviour);
EntityCollection types = new EntityCollection();
for (NodeTypeData ntdata : nts)
- types.add(new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory));
-
+ {
+ types.add(new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory, dataManager));
+ }
return types;
}
@@ -262,12 +269,12 @@
public NodeTypeIterator registerNodeTypes(InputStream xml, int alreadyExistsBehaviour, String contentType)
throws RepositoryException
{
-
Collection<NodeTypeData> nts = typesManager.registerNodeTypes(xml, alreadyExistsBehaviour, contentType);
EntityCollection types = new EntityCollection();
for (NodeTypeData ntdata : nts)
- types.add(new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory));
-
+ {
+ types.add(new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory, dataManager));
+ }
return types;
}
@@ -285,8 +292,9 @@
typesManager.registerNodeTypes(xml, alreadyExistsBehaviour, NodeTypeDataManager.TEXT_XML);
EntityCollection types = new EntityCollection();
for (NodeTypeData ntdata : nts)
- types.add(new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory));
-
+ {
+ types.add(new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory, dataManager));
+ }
return types;
}
@@ -298,7 +306,9 @@
{
InternalQName nodeTypeName = locationFactory.parseJCRName(name).getInternalName();
if (typesManager.getNodeType(nodeTypeName) == null)
+ {
throw new NoSuchNodeTypeException(name);
+ }
typesManager.unregisterNodeType(nodeTypeName);
}
@@ -312,7 +322,6 @@
{
unregisterNodeType(names[i]);
}
-
}
private NodeDefinitionValue convert(NodeDefinitionData data) throws RepositoryException
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeManagerImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/PropertyDefinitionImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/PropertyDefinitionImpl.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/PropertyDefinitionImpl.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.core.nodetype.ExtendedNodeTypeManager;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionData;
+import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -53,12 +54,13 @@
* @param nodeTypeManager
* @param locationFactory
* @param valueFactory
+ * @param dataManager
*/
public PropertyDefinitionImpl(PropertyDefinitionData propertyDefinitionData,
NodeTypeDataManager nodeTypeDataManager, ExtendedNodeTypeManager nodeTypeManager,
- LocationFactory locationFactory, ValueFactory valueFactory)
+ LocationFactory locationFactory, ValueFactory valueFactory, ItemDataConsumer dataManager)
{
- super(propertyDefinitionData, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory);
+ super(propertyDefinitionData, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory, dataManager);
this.propertyDefinitionData = propertyDefinitionData;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDataValidator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDataValidator.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDataValidator.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -20,37 +20,97 @@
import org.exoplatform.services.jcr.core.nodetype.NodeDefinitionData;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
+import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionData;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeRepository;
+import org.exoplatform.services.jcr.impl.core.value.ValueConstraintsValidator;
+import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
/**
* Created by The eXo Platform SAS.
*
* @author <a href="mailto:Sergey.Kabashnyuk@gmail.com">Sergey Kabashnyuk</a>
- * @version $Id: $
+ * @version $Id$
*/
public class NodeTypeDataValidator
{
/**
* Class logger.
*/
- private final Log log = ExoLogger.getLogger("exo.jcr.component.core.NodeTypeDataValidator");
+ private final static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.NodeTypeDataValidator");
protected final NodeTypeRepository hierarchy;
- public NodeTypeDataValidator(NodeTypeRepository hierarchy)
+ protected final ValueFactoryImpl valueFactory;
+
+ protected class ValidatorValueFactory extends ValueFactoryImpl
{
- super();
+ ValidatorValueFactory(LocationFactory locationFactory)
+ {
+ super(locationFactory);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Value createValue(String value, int type) throws ValueFormatException
+ {
+ if (type == PropertyType.BINARY)
+ {
+ LOG.warn("Not supported Value type: BINARY");
+ return null;
+ }
+
+ return super.createValue(value, type);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Value createValue(InputStream value)
+ {
+ LOG.warn("Not supported Value type: BINARY");
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Value loadValue(ValueData data, int type) throws RepositoryException
+ {
+ if (type == PropertyType.BINARY)
+ {
+ LOG.warn("Not supported Value type: BINARY");
+ return null;
+ }
+
+ return super.loadValue(data, type);
+ }
+ }
+
+ public NodeTypeDataValidator(LocationFactory locationFactory, NodeTypeRepository hierarchy)
+ {
this.hierarchy = hierarchy;
+
+ this.valueFactory = new ValidatorValueFactory(locationFactory);
}
public void validateNodeType(List<NodeTypeData> nodeTypeDataList) throws RepositoryException
@@ -100,7 +160,6 @@
&& !resolvedDependecies.contains(childnodeDefinitionData.getDefaultPrimaryType()))
{
unresolvedDependecies.add(childnodeDefinitionData.getDefaultPrimaryType());
-
}
}
}
@@ -133,36 +192,77 @@
throw new RepositoryException("NodeType object " + nodeType + " is null");
}
- for (int i = 0; i < nodeType.getDeclaredSupertypeNames().length; i++)
+ if (nodeType.getName() == null)
{
- if (!nodeType.getName().equals(Constants.NT_BASE)
- && nodeType.getName().equals(nodeType.getDeclaredSupertypeNames()[i]))
+ throw new RepositoryException("NodeType implementation class " + nodeType.getClass().getName()
+ + " is not supported in this method");
+ }
+
+ for (InternalQName sname : nodeType.getDeclaredSupertypeNames())
+ {
+ if (!nodeType.getName().equals(Constants.NT_BASE) && nodeType.getName().equals(sname))
{
- throw new RepositoryException("Invalid super type name"
- + nodeType.getDeclaredSupertypeNames()[i].getAsString());
+ throw new RepositoryException("Invalid super type name" + sname.getAsString());
}
}
- for (int i = 0; i < nodeType.getDeclaredPropertyDefinitions().length; i++)
+
+ for (PropertyDefinitionData pdef : nodeType.getDeclaredPropertyDefinitions())
{
- if (!nodeType.getDeclaredPropertyDefinitions()[i].getDeclaringNodeType().equals(nodeType.getName()))
+ if (!pdef.getDeclaringNodeType().equals(nodeType.getName()))
{
- throw new RepositoryException("Invalid declared node type in property definitions with name "
- + nodeType.getDeclaredPropertyDefinitions()[i].getName().getAsString() + " not registred");
+ throw new RepositoryException("Invalid declared node type in property definitions with name "
+ + pdef.getName().getAsString() + " not registred");
}
+
+ // validate default values
+ try
+ {
+ validateValueDefaults(pdef.getRequiredType(), pdef.getDefaultValues());
+ }
+ catch (ValueFormatException e)
+ {
+ throw new ValueFormatException("Default value is incompatible with Property type "
+ + PropertyType.nameFromValue(pdef.getRequiredType()) + " of " + pdef.getName().getAsString()
+ + " in nodetype " + nodeType.getName().getAsString(), e);
+ }
+
+ // TODO validate constraints, we have issue with TCK nodetype tests:canSetProperty
+ try
+ {
+ validateValueConstraints(pdef.getRequiredType(), pdef.getValueConstraints());
+ }
+ catch (ValueFormatException e)
+ {
+ throw new ValueFormatException("Constraints is incompatible with Property type "
+ + PropertyType.nameFromValue(pdef.getRequiredType()) + " of " + pdef.getName().getAsString()
+ + " in nodetype " + nodeType.getName().getAsString(), e);
+ }
}
- for (int i = 0; i < nodeType.getDeclaredChildNodeDefinitions().length; i++)
+
+ for (NodeDefinitionData cndef : nodeType.getDeclaredChildNodeDefinitions())
{
- if (!nodeType.getDeclaredChildNodeDefinitions()[i].getDeclaringNodeType().equals(nodeType.getName()))
+ if (!cndef.getDeclaringNodeType().equals(nodeType.getName()))
{
- throw new RepositoryException("Invalid declared node type in child node definitions with name "
- + nodeType.getDeclaredChildNodeDefinitions()[i].getName().getAsString() + " not registred");
+ throw new RepositoryException("Invalid declared node type in child node definitions with name "
+ + cndef.getName().getAsString() + " not registred");
}
}
+ }
- if (nodeType.getName() == null)
+ private void validateValueDefaults(int requiredType, String[] defValues) throws ValueFormatException
+ {
+ if (requiredType != PropertyType.STRING && requiredType != PropertyType.UNDEFINED && requiredType != PropertyType.BINARY)
{
- throw new RepositoryException("NodeType implementation class " + nodeType.getClass().getName()
- + " is not supported in this method");
+ for (String dv : defValues)
+ {
+ valueFactory.createValue(dv, requiredType);
+ }
}
}
+
+ private void validateValueConstraints(int requiredType, String[] constraints) throws ValueFormatException
+ {
+ ValueConstraintsValidator validator = new ValueConstraintsValidator(constraints);
+ validator.validateFor(requiredType);
+ }
}
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDataValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -335,8 +335,7 @@
}
}
- private void checkValueConstraints(PropertyDefinitionData def, PropertyData propertyData)
- throws ConstraintViolationException, RepositoryException
+ private void checkValueConstraints(PropertyDefinitionData def, PropertyData propertyData) throws RepositoryException
{
ValueConstraintsMatcher constraints =
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsMatcher.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsMatcher.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsMatcher.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -39,25 +39,18 @@
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.ValueFormatException;
-import javax.jcr.nodetype.ConstraintViolationException;
/**
- * Created by The eXo Platform SAS Author : Peter Nedonosko
- * peter.nedonosko(a)exoplatform.com.ua 13.09.2006
+ * Created by The eXo Platform SAS.
*
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
- * Nedonosko</a>
- * @version $Id: ValueConstraintsMatcher.java 12171 2008-03-20 15:37:28Z ksm $
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com">Peter Nedonosko</a>
+ * @version $Id$
*/
-public class ValueConstraintsMatcher
+public class ValueConstraintsMatcher extends ValueConstraintsValidator
{
- protected static Log log = ExoLogger.getLogger("exo.jcr.component.core.ValueConstraintsMatcher");
+ protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.ValueConstraintsMatcher");
- protected final static String DEFAULT_THRESHOLD = "";
-
- private final String[] constraints;
-
private final LocationFactory locator;
private final ItemDataConsumer itemDataConsumer;
@@ -67,24 +60,32 @@
public ValueConstraintsMatcher(String[] constraints, LocationFactory locator, ItemDataConsumer itemDataConsumer,
NodeTypeDataManager nodeTypeDataManager)
{
- this.constraints = constraints;
+ super(constraints);
this.locator = locator;
this.itemDataConsumer = itemDataConsumer;
this.nodeTypeDataManager = nodeTypeDataManager;
-
}
- public boolean match(ValueData value, int type) throws ConstraintViolationException, IllegalStateException,
- RepositoryException
+ /**
+ * Check given value on compatibility with a given type.
+ *
+ * @param value ValueData
+ * @param type int, property type
+ * @return boolean true if the value matches the type, false otherwise
+ * @throws RepositoryException if gathering of match conditions meets errors (IOException or ItemNotFoundException)
+ */
+ public boolean match(ValueData value, int type) throws RepositoryException
{
if (constraints == null || constraints.length <= 0)
+ {
return true;
+ }
boolean invalid = true;
// do not use getString because of string consuming
- ValueData valueData = (ValueData)value;
+ ValueData valueData = value;
if (type == PropertyType.STRING)
{
try
@@ -112,7 +113,6 @@
}
else if (type == PropertyType.NAME)
{
-
NameValue nameVal;
try
{
@@ -131,11 +131,9 @@
invalid = false;
}
}
-
}
else if (type == PropertyType.PATH)
{
-
PathValue pathVal;
try
{
@@ -147,24 +145,18 @@
}
for (int i = 0; invalid && i < constraints.length; i++)
{
- String constrString = constraints[i];
-
- JCRPathMatcher constrPath = parsePathMatcher(locator, constrString);
+ JCRPathMatcher constrPath = parsePathMatcher(locator, constraints[i]);
if (constrPath.match(pathVal.getQPath()))
{
invalid = false;
}
}
-
}
else if (type == PropertyType.REFERENCE)
{
-
try
{
ReferenceValue refVal = new ReferenceValue(valueData);
- // NodeImpl refNode = (NodeImpl)
- // session.getNodeByUUID(refVal.getIdentifier().getString());
NodeData refNode = (NodeData)itemDataConsumer.getItemData(refVal.getIdentifier().getString());
for (int i = 0; invalid && i < constraints.length; i++)
{
@@ -179,8 +171,10 @@
}
catch (ItemNotFoundException e)
{
- if (log.isDebugEnabled())
- log.debug("Reference constraint node is not found: " + e.getMessage());
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Reference constraint node is not found: " + e.getMessage());
+ }
// But if it's a versionHisroy ref property for add mix:versionable...
// we haven't a versionHisroy created until save method will be called
// on this
@@ -190,21 +184,19 @@
}
catch (RepositoryException e)
{
- log.error("Reference constraint error: " + e.getMessage(), e);
+ LOG.error("Reference constraint error: " + e.getMessage(), e);
// [PN] Posible trouble is session.getNodeByUUID() call result,
// till bug can be found in version restore operation.
invalid = true;
}
catch (IOException e)
{
- log.error("Reference constraint error: " + e.getMessage(), e);
+ LOG.error("Reference constraint error: " + e.getMessage(), e);
invalid = true;
}
-
}
else if (type == PropertyType.BINARY)
{
-
long valueLength = valueData.getLength();
for (int i = 0; invalid && i < constraints.length; i++)
{
@@ -221,12 +213,16 @@
if (constraint.getMin().isExclusive())
{
if (valueLength > min)
+ {
minInvalid = false;
+ }
}
else
{
if (valueLength >= min)
+ {
minInvalid = false;
+ }
}
long max =
@@ -244,11 +240,9 @@
}
invalid = maxInvalid | minInvalid;
}
-
}
else if (type == PropertyType.DATE)
{
-
Calendar valueCalendar;
try
{
@@ -260,13 +254,10 @@
}
for (int i = 0; invalid && i < constraints.length; i++)
{
- String constrString = constraints[i];
-
boolean minInvalid = true;
boolean maxInvalid = true;
- MinMaxConstraint constraint = parseAsMinMax(constrString);
-
+ MinMaxConstraint constraint = parseAsMinMax(constraints[i]);
try
{
if (constraint.getMin().getThreshold().length() > 0)
@@ -275,16 +266,22 @@
if (constraint.getMin().isExclusive())
{
if (valueCalendar.compareTo(min) > 0)
+ {
minInvalid = false;
+ }
}
else
{
if (valueCalendar.compareTo(min) >= 0)
+ {
minInvalid = false;
+ }
}
}
else
+ {
minInvalid = false;
+ }
}
catch (ValueFormatException e)
{
@@ -308,7 +305,9 @@
}
}
else
+ {
maxInvalid = false;
+ }
}
catch (ValueFormatException e)
{
@@ -317,11 +316,9 @@
invalid = maxInvalid | minInvalid;
}
-
}
else if (type == PropertyType.LONG || type == PropertyType.DOUBLE)
{
-
// will be compared as double in any case
Number valueNumber;
try
@@ -334,12 +331,10 @@
}
for (int i = 0; invalid && i < constraints.length; i++)
{
- String constrString = constraints[i];
-
boolean minInvalid = true;
boolean maxInvalid = true;
- MinMaxConstraint constraint = parseAsMinMax(constrString);
+ MinMaxConstraint constraint = parseAsMinMax(constraints[i]);
Number min =
constraint.getMin().getThreshold().length() > 0 ? new Double(constraint.getMin().getThreshold())
@@ -347,12 +342,16 @@
if (constraint.getMin().isExclusive())
{
if (valueNumber.doubleValue() > min.doubleValue())
+ {
minInvalid = false;
+ }
}
else
{
if (valueNumber.doubleValue() >= min.doubleValue())
+ {
minInvalid = false;
+ }
}
Number max =
@@ -361,26 +360,43 @@
if (constraint.getMax().isExclusive())
{
if (valueNumber.doubleValue() < max.doubleValue())
+ {
maxInvalid = false;
+ }
}
else
{
if (valueNumber.doubleValue() <= max.doubleValue())
+ {
maxInvalid = false;
+ }
}
invalid = maxInvalid | minInvalid;
}
}
else if (type == PropertyType.BOOLEAN)
{
- // JSR-283, 4.7.17.6 BOOLEAN has no Constraint
- invalid = false;
+ try
+ {
+ boolean bvalue = Boolean.parseBoolean(new String(valueData.getAsByteArray()));
+ for (int i = 0; invalid && i < constraints.length; i++)
+ {
+ if (Boolean.parseBoolean(constraints[i]) == bvalue)
+ {
+ invalid = false;
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException("FATAL ERROR Value data stream reading error " + e.getMessage(), e);
+ }
}
return !invalid;
}
- JCRPath parsePath(String path, LocationFactory locFactory) throws RepositoryException
+ protected JCRPath parsePath(String path, LocationFactory locFactory) throws RepositoryException
{
try
{
@@ -399,58 +415,14 @@
}
}
- protected MinMaxConstraint parseAsMinMax(String constraint) throws ConstraintViolationException
- {
-
- // constraint as min,max range:
- // value constraints in the form of inclusive or exclusive ranges:
- // i.e., "[min, max]", "(min, max)", "(min, max]" or "[min, max)".
- // Where "[" and "]" indicate "inclusive", while "(" and ")" indicate
- // "exclusive".
- // A missing min or max value indicates no bound in that direction
-
- String[] parts = constraint.split(",");
-
- if (parts.length != 2)
- throw new ConstraintViolationException("Value constraint '" + constraint
- + "' is invalid accrding the JSR-170 spec.");
-
- boolean exclusive = false;
-
- if (parts[0].startsWith("("))
- exclusive = true;
- else if (parts[0].startsWith("["))
- exclusive = false;
- else
- throw new ConstraintViolationException("Value constraint '" + constraint
- + "' min exclusion rule is unefined accrding the JSR-170 spec.");
-
- ConstraintRange minValue =
- new ConstraintRange(parts[0].length() > 1 ? parts[0].substring(1) : DEFAULT_THRESHOLD, exclusive);
-
- if (parts[1].endsWith(")"))
- exclusive = true;
- else if (parts[1].endsWith("]"))
- exclusive = false;
- else
- throw new ConstraintViolationException("Value constraint '" + constraint
- + "' max exclusion rule is unefined accrding the JSR-170 spec.");
-
- ConstraintRange maxValue =
- new ConstraintRange(parts[1].length() > 1 ? parts[1].substring(0, parts[1].length() - 1) : DEFAULT_THRESHOLD,
- exclusive);
-
- return new MinMaxConstraint(minValue, maxValue);
- }
-
/**
- * Parses JCR path matcher from string
+ * Parses JCR path matcher from string.
*
* @param path
* @return
* @throws RepositoryException
*/
- private JCRPathMatcher parsePathMatcher(LocationFactory locFactory, String path) throws RepositoryException
+ protected JCRPathMatcher parsePathMatcher(LocationFactory locFactory, String path) throws RepositoryException
{
JCRPath knownPath = null;
@@ -485,69 +457,5 @@
}
return new JCRPathMatcher(knownPath.getInternalPath(), forDescendants, forAncestors);
-
}
-
- public class ConstraintRange
- {
-
- private final String value;
-
- private final boolean exclusive;
-
- public ConstraintRange(String value)
- {
- this.value = value;
- this.exclusive = false;
- }
-
- public ConstraintRange(String value, boolean exclusive)
- {
- this.value = value;
- this.exclusive = exclusive;
- }
-
- protected String getThreshold()
- {
- return value;
- }
-
- protected boolean isExclusive()
- {
- return exclusive;
- }
- }
-
- public class MinMaxConstraint
- {
-
- private final ConstraintRange minValue;
-
- private final ConstraintRange maxValue;
-
- private final ConstraintRange singleValue;
-
- public MinMaxConstraint(ConstraintRange minValue, ConstraintRange maxValue)
- {
- this.minValue = minValue;
- this.maxValue = maxValue;
- this.singleValue = null;
- }
-
- public ConstraintRange getSingleValue()
- {
- return singleValue;
- }
-
- protected ConstraintRange getMax()
- {
- return maxValue;
- }
-
- protected ConstraintRange getMin()
- {
- return minValue;
- }
- }
-
}
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsMatcher.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsValidator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsValidator.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsValidator.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.core.value;
+
+import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import javax.jcr.PropertyType;
+import javax.jcr.ValueFormatException;
+import javax.jcr.nodetype.ConstraintViolationException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com">Peter Nedonosko</a>
+ * @version $Id: ValueConstraintsValidator.java 12171 2008-03-20 15:37:28Z ksm $
+ */
+public class ValueConstraintsValidator
+{
+
+ protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.ValueConstraintsValidator");
+
+ protected final static String DEFAULT_THRESHOLD = "";
+
+ protected final String[] constraints;
+
+ public ValueConstraintsValidator(String[] constraints)
+ {
+ this.constraints = constraints;
+ }
+
+ protected MinMaxConstraint parseAsMinMax(String constraint) throws ConstraintViolationException
+ {
+
+ // constraint as min,max range:
+ // value constraints in the form of inclusive or exclusive ranges:
+ // i.e., "[min, max]", "(min, max)", "(min, max]" or "[min, max)".
+ // Where "[" and "]" indicate "inclusive", while "(" and ")" indicate
+ // "exclusive".
+ // A missing min or max value indicates no bound in that direction
+
+ String[] parts = constraint.split(",");
+
+ if (parts.length != 2)
+ {
+ throw new ConstraintViolationException("Value constraint '" + constraint
+ + "' is invalid accrding the JSR-170 spec.");
+ }
+
+ boolean exclusive = false;
+
+ if (parts[0].startsWith("("))
+ {
+ exclusive = true;
+ }
+ else if (parts[0].startsWith("["))
+ {
+ exclusive = false;
+ }
+ else
+ {
+ throw new ConstraintViolationException("Value constraint '" + constraint
+ + "' min exclusion rule is unefined accrding the JSR-170 spec.");
+ }
+
+ ConstraintRange minValue =
+ new ConstraintRange(parts[0].length() > 1 ? parts[0].substring(1) : DEFAULT_THRESHOLD, exclusive);
+
+ if (parts[1].endsWith(")"))
+ {
+ exclusive = true;
+ }
+ else if (parts[1].endsWith("]"))
+ {
+ exclusive = false;
+ }
+ else
+ {
+ throw new ConstraintViolationException("Value constraint '" + constraint
+ + "' max exclusion rule is unefined accrding the JSR-170 spec.");
+ }
+
+ ConstraintRange maxValue =
+ new ConstraintRange(parts[1].length() > 1 ? parts[1].substring(0, parts[1].length() - 1) : DEFAULT_THRESHOLD,
+ exclusive);
+
+ return new MinMaxConstraint(minValue, maxValue);
+ }
+
+ /**
+ * Validate this matcher constraints for a validity to a given type.
+ *
+ * @param type int, property type
+ * @throws ValueFormatException if the constraint (at least one) incompatible with the given type
+ */
+ public void validateFor(final int type) throws ValueFormatException
+ {
+ if (constraints == null || constraints.length <= 0)
+ {
+ return;
+ }
+
+ if (type == PropertyType.DATE)
+ {
+ for (String constrString : constraints)
+ {
+ try
+ {
+ MinMaxConstraint constraint = parseAsMinMax(constrString);
+ if (constraint.getMin().getThreshold().length() > 0)
+ {
+ JCRDateFormat.parse(constraint.getMin().getThreshold());
+ }
+
+ if (constraint.getMax().getThreshold().length() > 0)
+ {
+ JCRDateFormat.parse(constraint.getMax().getThreshold());
+ }
+ }
+ catch (ValueFormatException e)
+ {
+ throw new ValueFormatException("Wrong DATE constraint format " + constrString, e);
+ }
+ catch (ConstraintViolationException e)
+ {
+ throw new ValueFormatException("Wrong DATE constraint format " + constrString, e);
+ }
+ }
+ }
+ else if (type == PropertyType.DOUBLE)
+ {
+ for (String constrString : constraints)
+ {
+ try
+ {
+ MinMaxConstraint constraint = parseAsMinMax(constrString);
+ if (constraint.getMin().getThreshold().length() > 0)
+ {
+ Double.parseDouble(constraint.getMin().getThreshold());
+ }
+ if (constraint.getMax().getThreshold().length() > 0)
+ {
+ Double.parseDouble(constraint.getMax().getThreshold());
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ throw new ValueFormatException("Wrong DOUBLE constraint format " + constrString, e);
+ }
+ catch (ConstraintViolationException e)
+ {
+ throw new ValueFormatException("Wrong DOUBLE constraint format " + constrString, e);
+ }
+ }
+ }
+ else if (type == PropertyType.LONG || type == PropertyType.BINARY)
+ {
+ for (String constrString : constraints)
+ {
+ try
+ {
+ MinMaxConstraint constraint = parseAsMinMax(constrString);
+ if (constraint.getMin().getThreshold().length() > 0)
+ {
+ Long.parseLong(constraint.getMin().getThreshold());
+ }
+ if (constraint.getMax().getThreshold().length() > 0)
+ {
+ Long.parseLong(constraint.getMax().getThreshold());
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ throw new ValueFormatException("Wrong LONG (or BINARY size) constraint format " + constrString, e);
+ }
+ catch (ConstraintViolationException e)
+ {
+ throw new ValueFormatException("Wrong LONG (or BINARY size) constraint format " + constrString, e);
+ }
+ }
+ }
+ else if (type == PropertyType.BOOLEAN)
+ {
+ for (String constrString : constraints)
+ {
+ if (!constrString.equalsIgnoreCase("true") && !constrString.equalsIgnoreCase("false"))
+ {
+ throw new ValueFormatException("Wrong BOOLEAN constraint format: " + constrString);
+ }
+ }
+ }
+ }
+
+ protected class ConstraintRange
+ {
+
+ private final String value;
+
+ private final boolean exclusive;
+
+ public ConstraintRange(String value)
+ {
+ this.value = value;
+ this.exclusive = false;
+ }
+
+ public ConstraintRange(String value, boolean exclusive)
+ {
+ this.value = value;
+ this.exclusive = exclusive;
+ }
+
+ protected String getThreshold()
+ {
+ return value;
+ }
+
+ protected boolean isExclusive()
+ {
+ return exclusive;
+ }
+ }
+
+ protected class MinMaxConstraint
+ {
+ private final ConstraintRange minValue;
+
+ private final ConstraintRange maxValue;
+
+ public MinMaxConstraint(ConstraintRange minValue, ConstraintRange maxValue)
+ {
+ this.minValue = minValue;
+ this.maxValue = maxValue;
+ }
+
+ protected ConstraintRange getMax()
+ {
+ return maxValue;
+ }
+
+ protected ConstraintRange getMin()
+ {
+ return minValue;
+ }
+ }
+}
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -54,7 +54,7 @@
* ValueFactory implementation
*
* @author Gennady Azarenkov
- * @version $Id: ValueFactoryImpl.java 11907 2008-03-13 15:36:21Z ksm $
+ * @version $Id$
*/
public class ValueFactoryImpl implements ValueFactory
@@ -87,7 +87,6 @@
public ValueFactoryImpl(LocationFactory locationFactory)
{
-
this.locationFactory = locationFactory;
this.tempDirectory = new File(System.getProperty("java.io.tmpdir"));
this.maxBufferSize = WorkspaceDataContainer.DEF_MAXBUFFERSIZE;
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/nodetypes/TestValueConstraints.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/nodetypes/TestValueConstraints.java 2010-05-21 10:28:31 UTC (rev 2429)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/nodetypes/TestValueConstraints.java 2010-05-21 12:21:59 UTC (rev 2430)
@@ -31,6 +31,7 @@
import javax.jcr.Property;
import javax.jcr.PropertyType;
import javax.jcr.Value;
+import javax.jcr.nodetype.ConstraintViolationException;
/**
* Created by The eXo Platform SAS.
@@ -312,17 +313,17 @@
public void testBOOLEANProperty() throws Exception
{
-
Property testProperty = testValueConstraintsNode.setProperty("jcr:testBOOLEAN", true);
session.save();
try
{
testProperty.setValue(false);
root.save();
+ fail("setValue(BOOLEAN value) should throws ConstraintViolationException on 'false'");
}
- catch (Exception e)
+ catch (ConstraintViolationException e)
{
- fail("setValue(BOOLEAN value) here should be no Exception ");
+ // ok
}
}
15 years, 11 months
exo-jcr SVN: r2429 - kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-05-21 06:28:31 -0400 (Fri, 21 May 2010)
New Revision: 2429
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextInitializer.java
Log:
EXOJCR-573 logger output updated
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextInitializer.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextInitializer.java 2010-05-21 10:26:25 UTC (rev 2428)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextInitializer.java 2010-05-21 10:28:31 UTC (rev 2429)
@@ -32,6 +32,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -239,16 +240,25 @@
if (LOG.isDebugEnabled())
{
StringBuilder refAddrString = new StringBuilder();
- for (Map.Entry<String, String> ent: refAddr.entrySet()) {
+ refAddrString.append('{');
+ Set<Map.Entry<String, String>> refs = refAddr.entrySet();
+ int i = 1;
+ for (Map.Entry<String, String> ent : refs)
+ {
refAddrString.append(ent.getKey());
refAddrString.append('=');
refAddrString.append(ent.getValue());
- refAddrString.append(';');
+ if (i < refs.size())
+ {
+ refAddrString.append(' ');
+ }
+ i++;
}
- LOG.debug("Bind: " + bindName + " class-name:" + className + " factory:" + factory + " factoryLocation:" + factoryLocation +
- " refAddr:" + refAddrString);
+ refAddrString.append('}');
+ LOG.debug("Bind: " + bindName + " class-name:" + className + " factory:" + factory + " factoryLocation:"
+ + factoryLocation + " refAddr:" + refAddrString);
}
-
+
binder.bind(bindName, className, factory, factoryLocation, refAddr);
}
}
15 years, 11 months
exo-jcr SVN: r2428 - in core/trunk: exo.core.component.database and 3 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-05-21 06:26:25 -0400 (Fri, 21 May 2010)
New Revision: 2428
Added:
core/trunk/exo.core.component.database/src/test/resources/dbcreator/
core/trunk/exo.core.component.database/src/test/resources/dbcreator/test.sql
Modified:
core/trunk/exo.core.component.database/pom.xml
core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml
core/trunk/pom.xml
Log:
EXOJCR-573 TestDBCreator works by default using HSQLDB
Modified: core/trunk/exo.core.component.database/pom.xml
===================================================================
--- core/trunk/exo.core.component.database/pom.xml 2010-05-21 10:00:27 UTC (rev 2427)
+++ core/trunk/exo.core.component.database/pom.xml 2010-05-21 10:26:25 UTC (rev 2428)
@@ -102,6 +102,20 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ </dependency>
</dependencies>
<build>
@@ -113,7 +127,6 @@
<configuration>
<excludes>
<exclude>**/DBCreatorTest.java</exclude>
- <exclude>**/TestDBCreator.java</exclude>
</excludes>
</configuration>
</plugin>
Modified: core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml 2010-05-21 10:00:27 UTC (rev 2427)
+++ core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml 2010-05-21 10:26:25 UTC (rev 2428)
@@ -19,10 +19,45 @@
02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
<component>
+ <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
+ <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <init-params>
+ <value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>Log4J properties</description>
+ <property name="log4j.rootLogger" value="INFO, stdout, file" />
+
+ <property name="log4j.appender.stdout" value="org.apache.log4j.ConsoleAppender" />
+ <property name="log4j.appender.stdout.threshold" value="DEBUG" />
+
+ <property name="log4j.appender.stdout.layout" value="org.apache.log4j.PatternLayout" />
+ <property name="log4j.appender.stdout.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
+
+ <property name="log4j.appender.file" value="org.apache.log4j.FileAppender" />
+ <property name="log4j.appender.file.File" value="target/jcr.log" />
+
+ <property name="log4j.appender.file.layout" value="org.apache.log4j.PatternLayout" />
+ <property name="log4j.appender.file.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
+
+ <property name="log4j.category.exo.kernel.component.common.InitialContextInitializer" value="DEBUG" />
+ </properties-param>
+ </init-params>
+ </component>
+
+ <component>
<key>org.exoplatform.services.database.jdbc.DBSchemaCreator</key>
<type>org.exoplatform.services.database.jdbc.DBSchemaCreator</type>
<component-plugins>
@@ -50,27 +85,27 @@
</component-plugins>
</component>
- <component>
+ <component>
<key>org.exoplatform.services.database.creator.DBCreator</key>
<type>org.exoplatform.services.database.creator.DBCreator</type>
<init-params>
<properties-param>
<name>db-connection</name>
<description>database connection properties</description>
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost/" />
- <property name="username" value="root" />
- <property name="password" value="admin" />
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/dbcreator1" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
</properties-param>
<properties-param>
<name>db-creation</name>
<description>database creation properties</description>
- <property name="scriptPath" value="test.sql" />
- <property name="username" value="testuser" />
- <property name="password" value="testpwd" />
- </properties-param>
- </init-params>
- </component>
+ <property name="scriptPath" value="src/test/resources/dbcreator/test.sql" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component>
<component>
<key>org.exoplatform.services.naming.InitialContextInitializer</key>
Added: core/trunk/exo.core.component.database/src/test/resources/dbcreator/test.sql
===================================================================
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2010-05-21 10:00:27 UTC (rev 2427)
+++ core/trunk/pom.xml 2010-05-21 10:26:25 UTC (rev 2428)
@@ -334,6 +334,24 @@
<version>1.7</version>
</dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.2.2</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ <version>1.5.4</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
15 years, 11 months
exo-jcr SVN: r2427 - jcr/trunk/applications.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-05-21 06:00:27 -0400 (Fri, 21 May 2010)
New Revision: 2427
Modified:
jcr/trunk/applications/Readme.txt
Log:
EXOJCR-739 Readme updated
Modified: jcr/trunk/applications/Readme.txt
===================================================================
--- jcr/trunk/applications/Readme.txt 2010-05-21 09:31:50 UTC (rev 2426)
+++ jcr/trunk/applications/Readme.txt 2010-05-21 10:00:27 UTC (rev 2427)
@@ -4,8 +4,9 @@
1.1. settings.xml. There should be the correct application server version (e.g <exo.projects.app.tomcat.version>) etc.
1.2. exo directory structure.
1.3. Maven version 2.2.1 (or higher).
-1.4. Make sure you have run mvn insctal within ./config folder.
-2. Go to folder "exo.jcr.applications.your_application_server_name"and run "mvn clean install -P deploy" command.
+1.4. Make sure you have run mvn instal within ./config folder.
+2. Go to folder "exo.jcr.applications.tomcat" and run "mvn clean install -P deploy" command.
+2.1 If you want to deploy JBoss or Jonas use exo.jcr.applications.jboss or exo.jcr.applications.jonas respectively.
3. If the command has executed successfully, go to exo-tomcat and run "eXo run" command.
4. You may use other product-exo-jcr-as* and an application server if you need.
15 years, 11 months
exo-jcr SVN: r2426 - jcr/trunk/applications.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-05-21 05:31:50 -0400 (Fri, 21 May 2010)
New Revision: 2426
Modified:
jcr/trunk/applications/Readme.txt
Log:
Readme updated
Modified: jcr/trunk/applications/Readme.txt
===================================================================
--- jcr/trunk/applications/Readme.txt 2010-05-21 09:19:35 UTC (rev 2425)
+++ jcr/trunk/applications/Readme.txt 2010-05-21 09:31:50 UTC (rev 2426)
@@ -5,7 +5,7 @@
1.2. exo directory structure.
1.3. Maven version 2.2.1 (or higher).
1.4. Make sure you have run mvn insctal within ./config folder.
-2. Run "mvn -f product-exo-jcr-as-tomcat6.xml clean install -P deploy" command.
+2. Go to folder "exo.jcr.applications.your_application_server_name"and run "mvn clean install -P deploy" command.
3. If the command has executed successfully, go to exo-tomcat and run "eXo run" command.
4. You may use other product-exo-jcr-as* and an application server if you need.
15 years, 11 months