exo-jcr SVN: r2992 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/dataflow and 1 other directories.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-08-26 08:43:55 -0400 (Thu, 26 Aug 2010)
New Revision: 2992
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/WorkspaceItemDataCopyVisitor.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestWorkspaceSamenameNodeCopy.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java
Log:
EXOJCR-921: test and new WorkspaceItemDataCopyVisitor added
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-08-26 11:06:23 UTC (rev 2991)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java 2010-08-26 12:43:55 UTC (rev 2992)
@@ -33,8 +33,8 @@
import org.exoplatform.services.jcr.impl.core.query.QueryManagerImpl;
import org.exoplatform.services.jcr.impl.core.version.VersionImpl;
import org.exoplatform.services.jcr.impl.dataflow.ItemDataCloneVisitor;
-import org.exoplatform.services.jcr.impl.dataflow.ItemDataCopyVisitor;
import org.exoplatform.services.jcr.impl.dataflow.ItemDataMoveVisitor;
+import org.exoplatform.services.jcr.impl.dataflow.WorkspaceItemDataCopyVisitor;
import org.exoplatform.services.jcr.impl.dataflow.session.SessionChangesLog;
import org.exoplatform.services.jcr.impl.dataflow.session.TransactionableDataManager;
import org.exoplatform.services.jcr.impl.dataflow.version.VersionHistoryDataHelper;
@@ -208,9 +208,10 @@
}
}
- ItemDataCopyVisitor initializer =
- new ItemDataCopyVisitor((NodeData)destParentNode.getData(), destNodePath.getName().getInternalName(),
- nodeTypeManager, srcSession.getTransientNodesManager(), false);
+ WorkspaceItemDataCopyVisitor initializer =
+ new WorkspaceItemDataCopyVisitor((NodeData)destParentNode.getData(), destNodePath.getName().getInternalName(),
+ nodeTypeManager, srcSession.getTransientNodesManager(), session.getTransientNodesManager(), false);
+
srcNode.getData().accept(initializer);
PlainChangesLogImpl changesLog = new PlainChangesLogImpl(initializer.getItemAddStates(), session.getId());
@@ -355,7 +356,7 @@
InvalidSerializedDataException, RepositoryException
{
session.checkLive();
-
+
NodeImpl node = (NodeImpl)session.getItem(parentAbsPath);
if (!node.checkedOut())
{
@@ -632,8 +633,7 @@
NodeData vh = (NodeData)dataManager.getItemData(v.getParentIdentifier()); // version
// parent
// it's a VH
- VersionHistoryDataHelper historyHelper =
- new VersionHistoryDataHelper(vh, dataManager, nodeTypeManager);
+ VersionHistoryDataHelper historyHelper = new VersionHistoryDataHelper(vh, dataManager, nodeTypeManager);
changesLog.addAll(v.restoreLog(destParent, node.getQPath().getName(), historyHelper, session,
removeExisting, changesLog).getAllStates());
@@ -670,8 +670,7 @@
NodeData destParent = (NodeData)dataManager.getItemData(node.getParentIdentifier());
// version parent it's a VH
NodeData vh = (NodeData)dataManager.getItemData(v.getParentIdentifier());
- VersionHistoryDataHelper historyHelper =
- new VersionHistoryDataHelper(vh, dataManager, nodeTypeManager);
+ VersionHistoryDataHelper historyHelper = new VersionHistoryDataHelper(vh, dataManager, nodeTypeManager);
changesLog.addAll(v.restoreLog(destParent, node.getQPath().getName(), historyHelper, session,
removeExisting, changesLog).getAllStates());
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/WorkspaceItemDataCopyVisitor.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/WorkspaceItemDataCopyVisitor.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/WorkspaceItemDataCopyVisitor.java 2010-08-26 12:43:55 UTC (rev 2992)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.dataflow;
+
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.impl.core.SessionDataManager;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * This ItemData copy visitor uses two data managers:
+ * <UL>
+ * <LI>srcDataManager - used for service data that comes from source workspace (visit all items on
+ * source workspace);
+ * <LI>destDataManager - used for adding data to destination workspace (used to check like
+ * DefaultItemDataVisitor.calculateNewNodePath(), etc);
+ * </UL>
+ *
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: WorkspaceItemDataCopyVisitor.java 111 2010-26-08 11:11:11Z serg $
+ */
+public class WorkspaceItemDataCopyVisitor extends ItemDataCopyVisitor
+{
+ private SessionDataManager srcDataManager;
+
+ /**
+ * Constructor.
+ *
+ * @param parent - parent node, where copied item tree must be saved;
+ * @param destNodeName - copied nodes destination name;
+ * @param nodeTypeManager - node type manager;
+ * @param srcDataManager - used for service data that comes from source workspace (visit all items
+ * on source workspace)
+ * @param destDataManager - used for adding data to destination workspace (used to check like
+ * DefaultItemDataVisitor.calculateNewNodePath(), etc);
+ * @param keepIdentifiers - should we keep items identifiers or not;
+ */
+ public WorkspaceItemDataCopyVisitor(NodeData parent, InternalQName destNodeName,
+ NodeTypeDataManager nodeTypeManager, SessionDataManager srcDataManager, SessionDataManager destDataManager,
+ boolean keepIdentifiers)
+ {
+ super(parent, destNodeName, nodeTypeManager, destDataManager, keepIdentifiers);
+ this.srcDataManager = srcDataManager;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void visit(NodeData node) throws RepositoryException
+ {
+ try
+ {
+ entering(node, currentLevel);
+ if (maxLevel == -1 || currentLevel < maxLevel)
+ {
+ currentLevel++;
+ for (PropertyData data : srcDataManager.getChildPropertiesData(node))
+ data.accept(this);
+ for (NodeData data : srcDataManager.getChildNodesData(node))
+ data.accept(this);
+ currentLevel--;
+ }
+ leaving(node, currentLevel);
+ }
+ catch (RepositoryException re)
+ {
+ currentLevel = 0;
+ throw re;
+ }
+
+ }
+}
Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestWorkspaceSamenameNodeCopy.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestWorkspaceSamenameNodeCopy.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestWorkspaceSamenameNodeCopy.java 2010-08-26 12:43:55 UTC (rev 2992)
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.usecases;
+
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: TestWorksapceSamenameNodeCopy.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class TestWorkspaceSamenameNodeCopy extends BaseUsecasesTest
+{
+ private String parentNodeName = null;
+
+ public void testWorksapceSamenameNodeCopy() throws Exception
+ {
+ parentNodeName = "myNode";
+
+ // add node to ws workspace
+ Session sessionWS = (SessionImpl)repository.login(credentials, "ws");
+ sessionWS.getRootNode().addNode("myNode", "nt:unstructured");
+ sessionWS.save();
+ assertTrue(sessionWS.itemExists("/myNode"));
+ // copy node to another workspase
+
+ Session sessionWS2 = (SessionImpl)repository.login(credentials, "ws2");
+ sessionWS2.getWorkspace().copy("ws", "/myNode", "/myNode");
+
+ assertTrue(sessionWS2.itemExists("/myNode"));
+ }
+
+ public void tearDown() throws Exception
+ {
+ if (parentNodeName != null)
+ {
+ // clean up workspaces
+ Session sessionWS = (SessionImpl)repository.login(credentials, "ws");
+ Item item = sessionWS.getItem("/" + parentNodeName);
+ item.remove();
+ sessionWS.save();
+
+ Session sessionWS2 = (SessionImpl)repository.login(credentials, "ws2");
+ item = sessionWS2.getItem("/" + parentNodeName);
+ item.remove();
+ sessionWS2.save();
+ }
+ parentNodeName = null;
+ super.tearDown();
+ }
+
+ public void testWorksapceSamenameNodeCopy2() throws Exception
+ {
+ parentNodeName = "parent";
+ // add node to ws workspace
+ Session sessionWS = (SessionImpl)repository.login(credentials, "ws");
+ Node parent1 = sessionWS.getRootNode().addNode("parent");
+ parent1.addNode("myNode", "nt:unstructured");
+ sessionWS.save();
+ assertTrue(sessionWS.itemExists("/parent/myNode"));
+ // copy node to another workspase
+
+ Session sessionWS2 = (SessionImpl)repository.login(credentials, "ws2");
+ Node parent2 = sessionWS2.getRootNode().addNode("parent");
+ sessionWS2.save();
+ sessionWS2.getWorkspace().copy("ws", "/parent/myNode", "/parent/myNode");
+
+ assertTrue(sessionWS2.itemExists("/parent/myNode"));
+ }
+
+ public void testWorksapceSamenameNodeCopyWithSubNodes() throws Exception
+ {
+ parentNodeName = "myNode";
+
+ // add node to ws workspace
+ Session sessionWS = (SessionImpl)repository.login(credentials, "ws");
+ Node n = sessionWS.getRootNode().addNode("myNode", "nt:unstructured");
+ n.addNode("subnode", "nt:unstructured");
+ sessionWS.save();
+ assertTrue(sessionWS.itemExists("/myNode"));
+ assertTrue(sessionWS.itemExists("/myNode/subnode"));
+ // copy node to another workspase
+
+ Session sessionWS2 = (SessionImpl)repository.login(credentials, "ws2");
+ sessionWS2.getWorkspace().copy("ws", "/myNode", "/myNode");
+
+ assertTrue(sessionWS2.itemExists("/myNode"));
+ assertTrue(sessionWS2.itemExists("/myNode/subnode"));
+ }
+}
13 years, 10 months
exo-jcr SVN: r2991 - in jcr/trunk/applications: exo.jcr.applications.tomcat and 1 other directory.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-08-26 07:06:23 -0400 (Thu, 26 Aug 2010)
New Revision: 2991
Modified:
jcr/trunk/applications/exo.jcr.applications.jetty/pom.xml
jcr/trunk/applications/exo.jcr.applications.tomcat/pom.xml
Log:
EXOJCR-891 added regexp for removing timestamp from *.war files
Modified: jcr/trunk/applications/exo.jcr.applications.jetty/pom.xml
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.jetty/pom.xml 2010-08-26 07:24:28 UTC (rev 2990)
+++ jcr/trunk/applications/exo.jcr.applications.jetty/pom.xml 2010-08-26 11:06:23 UTC (rev 2991)
@@ -108,11 +108,17 @@
<fileset dir="${basedir}/target/lib-binary.dir/">
<include name="**/*.war" />
</fileset>
- <mapper>
- <chainedmapper>
- <flattenmapper />
- <globmapper from="exo.jcr.applications.*-${project.version}.war" to="*.war" casesensitive="no" />
- </chainedmapper>
+ <fileset dir="${basedir}/target/lib-binary.dir/">
+ <include name="**/*.war" />
+ </fileset>
+ <mapper>
+ <firstmatchmapper>
+ <!-- If a timestamped SNAPSHOT is used -->
+ <regexpmapper from="exo.jcr.applications.(.*)-([0-9]+(.[0-9]+)*-(.*))-([0-9]{8}.[0-9]{6})-([0-9]+).war" to="\1.war" casesensitive="no" />
+ <!-- Otherwise -->
+ <globmapper from="exo.jcr.applications.*-${project.version}.war" to="*.war" casesensitive="no" />
+ <!-- By default keep the name -->
+ </firstmatchmapper>
</mapper>
</move>
<copy todir="${exo.projects.directory.working}/exo-jetty/webapps/" verbose="true" flatten="true" overwrite="true">
@@ -121,7 +127,24 @@
</fileset>
</copy>
</tasks>
- </configuration>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>1.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ <version>1.8.1</version>
+ </dependency>
+ </dependencies>
</plugin>
</plugins>
</build>
Modified: jcr/trunk/applications/exo.jcr.applications.tomcat/pom.xml
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.tomcat/pom.xml 2010-08-26 07:24:28 UTC (rev 2990)
+++ jcr/trunk/applications/exo.jcr.applications.tomcat/pom.xml 2010-08-26 11:06:23 UTC (rev 2991)
@@ -111,10 +111,13 @@
<include name="**/*.war" />
</fileset>
<mapper>
- <chainedmapper>
- <flattenmapper />
+ <firstmatchmapper>
+ <!-- If a timestamped SNAPSHOT is used -->
+ <regexpmapper from="exo.jcr.applications.(.*)-([0-9]+(.[0-9]+)*-(.*))-([0-9]{8}.[0-9]{6})-([0-9]+).war" to="\1.war" casesensitive="no" />
+ <!-- Otherwise -->
<globmapper from="exo.jcr.applications.*-${project.version}.war" to="*.war" casesensitive="no" />
- </chainedmapper>
+ <!-- By default keep the name -->
+ </firstmatchmapper>
</mapper>
</move>
<copy todir="${exo.projects.directory.working}/exo-tomcat/webapps/" verbose="true" flatten="true" overwrite="true">
@@ -124,6 +127,23 @@
</copy>
</tasks>
</configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>1.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ <version>1.8.1</version>
+ </dependency>
+ </dependencies>
</plugin>
</plugins>
</build>
13 years, 10 months
exo-jcr SVN: r2990 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/xml/importing/dataflow and 1 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-08-26 03:24:28 -0400 (Thu, 26 Aug 2010)
New Revision: 2990
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/NodePropertiesInfo.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/dataflow/ImportPropertyData.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java
Log:
EXOJCR-880 : Determine property is multi or single value from nodetype definition in import of version history was implemented.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java 2010-08-25 14:44:46 UTC (rev 2989)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java 2010-08-26 07:24:28 UTC (rev 2990)
@@ -36,6 +36,7 @@
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.JCRName;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
import org.exoplatform.services.jcr.impl.core.value.BaseValue;
@@ -202,7 +203,8 @@
ImportNodeData nodeData = createNode(nodeTypes, propertiesMap, mixinNodeTypes, jcrName);
- NodeData parentNodeData = getParent();
+ NodeData parentNodeData = getParent();
+
changesLog.add(new ItemState(nodeData, ItemState.ADDED, true, getAncestorToSave()));
tree.push(nodeData);
@@ -344,19 +346,39 @@
// determinating is property multivalue;
if (values.size() == 1)
{
- // there is single-value defeniton
- if (defs.getDefinition(false) != null)
+
+ PropertyDefinitionDatas vhdefs = null;
+
+ if (nodeData.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH))
{
- if (defs.getDefinition(false).isResidualSet() && nodeData.getPrimaryTypeName().equals(Constants.NT_FROZENNODE)
- && propName.equals(Constants.JCR_PREDECESSORS))
+ if (nodeData.getPrimaryTypeName().equals(Constants.NT_FROZENNODE))
{
- /// TODO EXOJCR-865
- isMultivalue = true;
+ // get primaryType
+ InternalQName fptName = locationFactory.parseJCRName(atts.get("jcr:frozenPrimaryType")).getInternalName();
+
+ // get mixin types
+ List<JCRName> mtNames = getJCRNames(atts.get("jcr:frozenMixinTypes"));
+
+ InternalQName fmtName[] = new InternalQName[mtNames.size()];
+
+ for (int i = 0; i < mtNames.size(); i++)
+ {
+ fmtName[i] = new InternalQName(mtNames.get(i).getNamespace(), mtNames.get(i).getName());
+ }
+
+ vhdefs = nodeTypeDataManager.getPropertyDefinitions(propName, fptName, fmtName);
+
+ if (vhdefs != null)
+ {
+ isMultivalue = (vhdefs.getDefinition(true) != null ? true : false);
+ }
}
- else
- {
+ }
+
+ // there is single-value defeniton
+ if (vhdefs == null && defs.getDefinition(false) != null)
+ {
isMultivalue = false;
- }
}
}
else
@@ -397,6 +419,28 @@
}
}
+ private List<JCRName> getJCRNames(String string) throws RepositoryException
+ {
+ List<JCRName> mtNames = new ArrayList<JCRName>();
+
+ StringTokenizer spaceToken = new StringTokenizer(string);
+
+ List<String> denormalizedStrings = new ArrayList<String>();
+ while (spaceToken.hasMoreTokens())
+ {
+ String elem = spaceToken.nextToken();
+ String denormalizeString = StringConverter.denormalizeString(elem);
+ denormalizedStrings.add(denormalizeString);
+ }
+
+ for (String mixinName : denormalizedStrings)
+ {
+ mtNames.add(locationFactory.parseJCRName(mixinName));
+ }
+
+ return mtNames;
+ }
+
private ImportNodeData createNode(List<NodeTypeData> nodeTypes, HashMap<InternalQName, String> propertiesMap,
List<InternalQName> mixinNodeTypes, InternalQName jcrName) throws PathNotFoundException, IllegalPathException,
RepositoryException
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/NodePropertiesInfo.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/NodePropertiesInfo.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/NodePropertiesInfo.java 2010-08-26 07:24:28 UTC (rev 2990)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.xml.importing;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.exoplatform.services.jcr.impl.xml.importing.dataflow.ImportNodeData;
+import org.exoplatform.services.jcr.impl.xml.importing.dataflow.ImportPropertyData;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2010
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public class NodePropertiesInfo
+{
+
+ private final ImportNodeData node;
+
+ private final List<ImportPropertyData> properties = new ArrayList<ImportPropertyData>();
+
+ public NodePropertiesInfo(ImportNodeData newNodeData)
+ {
+ this.node = newNodeData;
+ }
+
+ public void addProperty(ImportPropertyData propertyData)
+ {
+ properties.add(propertyData);
+ }
+
+ public ImportNodeData getNode()
+ {
+ return node;
+ }
+
+ public List<ImportPropertyData> getProperties()
+ {
+ return properties;
+ }
+
+}
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/NodePropertiesInfo.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java 2010-08-25 14:44:46 UTC (rev 2989)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java 2010-08-26 07:24:28 UTC (rev 2990)
@@ -24,6 +24,7 @@
import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionDatas;
import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.NodeData;
@@ -49,6 +50,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -74,7 +76,9 @@
private static Log log = ExoLogger.getLogger("exo.jcr.component.core.SystemViewImporter");
protected PropertyInfo propertyInfo = new PropertyInfo();
-
+
+ protected Map<String, NodePropertiesInfo> mapNodePropertiesInfo = new HashMap<String, NodePropertiesInfo>();
+
/**
* Root node name.
*/
@@ -150,7 +154,15 @@
ImportPropertyData propertyData = endProperty();
if (propertyData != null)
+ {
changesLog.add(new ItemState(propertyData, ItemState.ADDED, true, getAncestorToSave()));
+
+ ImportNodeData currentNodeInfo = (ImportNodeData)getParent();
+
+ NodePropertiesInfo currentNodePropertiesInfo = mapNodePropertiesInfo.get(currentNodeInfo.getQPath().getAsString());
+
+ currentNodePropertiesInfo.addProperty(propertyData);
+ }
}
else if (Constants.SV_VALUE_NAME.equals(elementName))
{
@@ -204,8 +216,10 @@
newNodeData.setACL(parentData.getACL());
newNodeData.setOrderNumber(getNextChildOrderNum(parentData));
newNodeData.setIdentifier(IdGenerator.generate());
-
+
changesLog.add(new ItemState(newNodeData, ItemState.ADDED, true, getAncestorToSave()));
+
+ mapNodePropertiesInfo.put(newNodeData.getQPath().getAsString(), new NodePropertiesInfo(newNodeData));
tree.push(newNodeData);
@@ -292,6 +306,15 @@
private void endNode() throws RepositoryException
{
ImportNodeData currentNodeInfo = (ImportNodeData)tree.pop();
+
+ NodePropertiesInfo currentNodePropertiesInfo = mapNodePropertiesInfo.get(currentNodeInfo.getQPath().getAsString());
+
+ if (currentNodePropertiesInfo != null)
+ {
+ checkPropertis(currentNodePropertiesInfo);
+ }
+
+ mapNodePropertiesInfo.remove(currentNodeInfo.getQPath().getAsString());
currentNodeInfo.setMixinTypeNames(currentNodeInfo.getMixinTypeNames());
@@ -304,7 +327,93 @@
.isExoPrivilegeable(), currentNodeInfo.getExoOwner(), currentNodeInfo.getExoPrivileges()));
}
+
/**
+ * Checking priopertis if nodetype is nt:frozennode
+ *
+ * @param currentNodePropertiesInfo
+ * @throws RepositoryException
+ * @throws IOException
+ * @throws IllegalNameException
+ * @throws IllegalStateException
+ */
+ private void checkPropertis(NodePropertiesInfo currentNodePropertiesInfo) throws RepositoryException
+ {
+ currentNodePropertiesInfo.getNode();
+ currentNodePropertiesInfo.getNode().getQPath();
+ currentNodePropertiesInfo.getNode().getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH);
+
+ currentNodePropertiesInfo.getNode();
+ currentNodePropertiesInfo.getNode().getPrimaryTypeName();
+ currentNodePropertiesInfo.getNode().getPrimaryTypeName().equals(Constants.NT_FROZENNODE);
+
+
+
+ if (currentNodePropertiesInfo.getNode().getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH)
+ && currentNodePropertiesInfo.getNode().getPrimaryTypeName().equals(Constants.NT_FROZENNODE))
+ {
+ // name of frozenPrimaryType property
+ InternalQName fptPropertyName = locationFactory.parseJCRName("jcr:frozenPrimaryType").getInternalName();
+
+ // node of frozenMixinTypes property
+ InternalQName fmtPropertyName = locationFactory.parseJCRName("jcr:frozenMixinTypes").getInternalName();
+
+ InternalQName fptName = null;
+ List<InternalQName> fmtNames = new ArrayList<InternalQName>();
+
+ // get frozenPrimaryType and frozenMixinTypes
+ try
+ {
+ for (ImportPropertyData propertyData : currentNodePropertiesInfo.getProperties())
+ {
+ if (propertyData.getQName().equals(fptPropertyName))
+ {
+ fptName = InternalQName.parse(new String(propertyData.getValues().get(0).getAsByteArray()));
+ }
+ else if (propertyData.getQName().equals(fmtPropertyName))
+ {
+ for (ValueData valueData : propertyData.getValues())
+ {
+ fmtNames.add(InternalQName.parse(new String(valueData.getAsByteArray())));
+ }
+ }
+ }
+ }
+ catch (IllegalStateException e)
+ {
+ log.error(e,e);
+ System.exit(0);
+ throw new RepositoryException(e.getMessage(), e);
+ }
+ catch (IllegalNameException e)
+ {
+ log.error(e,e);
+ System.exit(0);
+ throw new RepositoryException(e.getMessage(), e);
+ }
+ catch (IOException e)
+ {
+ log.error(e,e);
+ System.exit(0);
+ throw new RepositoryException(e.getMessage(), e);
+ }
+
+ for (ImportPropertyData propertyData : currentNodePropertiesInfo.getProperties())
+ {
+ PropertyDefinitionDatas vhdefs =
+ nodeTypeDataManager.getPropertyDefinitions(propertyData.getQName(), fptName, fmtNames
+ .toArray(new InternalQName[fmtNames.size()]));
+
+ if (vhdefs != null)
+ {
+ boolean isMultivalue = (vhdefs.getDefinition(true) != null ? true : false);
+ propertyData.setMultivalue(isMultivalue);
+ }
+ }
+ }
+ }
+
+ /**
* endPrimaryType.
*
* @return
@@ -341,7 +450,9 @@
new ImportPropertyData(QPath.makeChildPath(nodeData.getQPath(), propertyInfo.getName()), propertyInfo
.getIndentifer(), 0, propertyInfo.getType(), nodeData.getIdentifier(), false);
propertyData.setValues(parseValues());
+
tree.push(nodeData);
+
return propertyData;
}
@@ -414,16 +525,7 @@
// there is single-value defeniton
if (defs.getDefinition(false) != null)
{
- if (defs.getDefinition(false).isResidualSet() && currentNodeInfo.getPrimaryTypeName().equals(Constants.NT_FROZENNODE)
- && propertyInfo.getName().equals(Constants.JCR_PREDECESSORS))
- {
- /// TODO EXOJCR-865
- isMultivalue = true;
- }
- else
- {
- isMultivalue = false;
- }
+ isMultivalue = false;
}
}
else
@@ -443,6 +545,7 @@
propertyData.setValues(values);
}
+
return propertyData;
}
@@ -481,6 +584,9 @@
}
tree.push(currentNodeInfo);
+
+ mapNodePropertiesInfo.put(currentNodeInfo.getQPath().getAsString(), new NodePropertiesInfo(currentNodeInfo));
+
return propertyData;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/dataflow/ImportPropertyData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/dataflow/ImportPropertyData.java 2010-08-25 14:44:46 UTC (rev 2989)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/dataflow/ImportPropertyData.java 2010-08-26 07:24:28 UTC (rev 2990)
@@ -80,6 +80,17 @@
{
this.parentIdentifier = identifer;
}
+
+ /**
+ * Set multiValued;
+ *
+ * @param multiValue
+ * - multi value
+ */
+ public void setMultivalue(boolean multiValue)
+ {
+ this.multiValued = multiValue;
+ }
/**
* Set path of item.
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java 2010-08-25 14:44:46 UTC (rev 2989)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java 2010-08-26 07:24:28 UTC (rev 2990)
@@ -558,7 +558,7 @@
byte[] versionableNode = serialize(fileNode, false, true);
// version history
byte[] versionHistory = serialize(fileNode.getVersionHistory(), false, true);
- System.out.println(new String(versionHistory));
+ //System.out.println(new String(versionHistory));
fileNode.remove();
session.save();
assertFalse(testRoot.hasNode("TestJCR1247"));
@@ -1129,7 +1129,7 @@
// node content
byte[] versionableNode = serialize(fileNode, true, true);
// version history
- byte[] versionHistory = serialize(fileNode.getVersionHistory(), false, true);
+ byte[] versionHistory = serialize(fileNode.getVersionHistory(), true, true);
//System.out.println(new String(versionHistory));
// restore node content
@@ -1800,4 +1800,195 @@
fileImport.checkout();
root.save();
}
+
+ /**
+ * https://jira.jboss.org/browse/EXOJCR-865
+ *
+ * @throws Exception
+ */
+ public void testEXOJCR865_Doc_exo_links() throws Exception
+ {
+
+ Node testRoot = root.addNode("testRoot");
+ Node fileNode = testRoot.addNode("TestEXOJCR865_exo_links", "nt:file");
+ Node contentNode = fileNode.addNode("jcr:content", "nt:resource");
+ contentNode.setProperty("jcr:data", new ByteArrayInputStream("".getBytes()));
+ contentNode.setProperty("jcr:mimeType", "image/jpg");
+ contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
+ root.save();
+ Node contentNodeBeforeAddVersion = fileNode.getNode("jcr:content");
+ assertNotNull(contentNodeBeforeAddVersion.getProperty("jcr:lastModified"));
+ if (fileNode.canAddMixin("mix:versionable"))
+ {
+ fileNode.addMixin("mix:versionable");
+ }
+
+ fileNode.addMixin("exo:linkable");
+
+ fileNode.setProperty("exo:links", new String[] {"1"});
+
+ fileNode.save();
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ String nodeDump = dumpVersionable(fileNode);
+ // Export VersionHistory
+
+ assertTrue(fileNode.isNodeType("mix:versionable"));
+
+ VersionableNodeInfo nodeInfo = new VersionableNodeInfo(fileNode);
+
+ // node content
+ byte[] versionableNode = serialize(fileNode, false, true);
+ // version history
+ byte[] versionHistory = serialize(fileNode.getVersionHistory(), false, true);
+ //System.out.println(new String(versionHistory));
+
+ // restore node content
+ Node restoreRoot = testRoot.addNode("restRoot");
+ testRoot.save();
+
+ deserialize(restoreRoot, XmlSaveType.SESSION, true, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING,
+ new ByteArrayInputStream(versionableNode));
+ root.save();
+
+ assertTrue(restoreRoot.hasNode("TestEXOJCR865_exo_links"));
+
+ Node fileImport = restoreRoot.getNode("TestEXOJCR865_exo_links");
+ assertTrue(fileImport.isNodeType("mix:versionable"));
+
+ VersionHistoryImporter versionHistoryImporter =
+ new VersionHistoryImporter((NodeImpl)fileImport, new ByteArrayInputStream(versionHistory), nodeInfo
+ .getBaseVersion(), nodeInfo.getPredecessorsHistory(), nodeInfo.getVersionHistory());
+ versionHistoryImporter.doImport();
+ root.save();
+
+ Property property = fileImport.getProperty("exo:links");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ property = fileImport.getProperty("jcr:predecessors");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ fileImport.restore("2", true);
+ root.save();
+
+ property = fileImport.getProperty("exo:links");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ property = fileImport.getProperty("jcr:predecessors");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ fileImport.checkin();
+ fileImport.checkout();
+ root.save();
+ }
+
+ /**
+ * https://jira.jboss.org/browse/EXOJCR-865
+ *
+ * @throws Exception
+ */
+ public void testEXOJCR865_Sys_exo_links() throws Exception
+ {
+
+ Node testRoot = root.addNode("testRoot");
+ Node fileNode = testRoot.addNode("TestEXOJCR865_exo_links", "nt:file");
+ Node contentNode = fileNode.addNode("jcr:content", "nt:resource");
+ contentNode.setProperty("jcr:data", new ByteArrayInputStream("".getBytes()));
+ contentNode.setProperty("jcr:mimeType", "image/jpg");
+ contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
+ root.save();
+ Node contentNodeBeforeAddVersion = fileNode.getNode("jcr:content");
+ assertNotNull(contentNodeBeforeAddVersion.getProperty("jcr:lastModified"));
+ if (fileNode.canAddMixin("mix:versionable"))
+ {
+ fileNode.addMixin("mix:versionable");
+ }
+
+ fileNode.addMixin("exo:linkable");
+
+ fileNode.setProperty("exo:links", new String[] {"1"});
+
+ fileNode.save();
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ String nodeDump = dumpVersionable(fileNode);
+ // Export VersionHistory
+
+ assertTrue(fileNode.isNodeType("mix:versionable"));
+
+ VersionableNodeInfo nodeInfo = new VersionableNodeInfo(fileNode);
+
+ // node content
+ byte[] versionableNode = serialize(fileNode, true, true);
+ // version history
+ byte[] versionHistory = serialize(fileNode.getVersionHistory(), true, true);
+ //System.out.println(new String(versionHistory));
+
+ // restore node content
+ Node restoreRoot = testRoot.addNode("restRoot");
+ testRoot.save();
+
+ deserialize(restoreRoot, XmlSaveType.SESSION, true, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING,
+ new ByteArrayInputStream(versionableNode));
+ root.save();
+
+ assertTrue(restoreRoot.hasNode("TestEXOJCR865_exo_links"));
+
+ Node fileImport = restoreRoot.getNode("TestEXOJCR865_exo_links");
+ assertTrue(fileImport.isNodeType("mix:versionable"));
+
+ VersionHistoryImporter versionHistoryImporter =
+ new VersionHistoryImporter((NodeImpl)fileImport, new ByteArrayInputStream(versionHistory), nodeInfo
+ .getBaseVersion(), nodeInfo.getPredecessorsHistory(), nodeInfo.getVersionHistory());
+ versionHistoryImporter.doImport();
+ root.save();
+
+ Property property = fileImport.getProperty("exo:links");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ property = fileImport.getProperty("jcr:predecessors");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ fileImport.restore("2", true);
+ root.save();
+
+ property = fileImport.getProperty("jcr:predecessors");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ property = fileImport.getProperty("exo:links");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ fileImport.checkin();
+ fileImport.checkout();
+ root.save();
+ }
+
}
13 years, 10 months
exo-jcr SVN: r2989 - jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-08-25 10:44:46 -0400 (Wed, 25 Aug 2010)
New Revision: 2989
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java
Log:
EXOJCR-879: test fixed
Modified: jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java 2010-08-25 14:39:42 UTC (rev 2988)
+++ jcr/branches/1.12.x/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java 2010-08-25 14:44:46 UTC (rev 2989)
@@ -63,39 +63,39 @@
{
Node contentNode = node.getNode("jcr:content");
Property lastModifiedProperty = contentNode.getProperty("jcr:lastModified");
-
+
SimpleDateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.US);
Calendar lastModifiedDate = lastModifiedProperty.getDate();
- lastModifiedDate.roll(Calendar.SECOND, -10);
+ lastModifiedDate.add(Calendar.SECOND, -10);
// Rollback If-Modified-Since 10 seconds earlier.
String ifModifiedDate = dateFormat.format(lastModifiedDate.getTime());
-
+
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
headers.add(ExtHttpHeaders.IF_MODIFIED_SINCE, ifModifiedDate);
ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", headers, null);
-
+
assertEquals(HTTPStatus.OK, response.getStatus());
}
-
+
public void testIfModifiedSince() throws Exception
{
Node contentNode = node.getNode("jcr:content");
Property lastModifiedProperty = contentNode.getProperty("jcr:lastModified");
-
+
SimpleDateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.US);
Calendar lastModifiedDate = lastModifiedProperty.getDate();
-
+
lastModifiedDate.add(Calendar.WEEK_OF_MONTH, 1);
String ifModifiedDate = dateFormat.format(lastModifiedDate.getTime());
-
+
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
headers.add(ExtHttpHeaders.IF_MODIFIED_SINCE, ifModifiedDate);
ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", headers, null);
-
+
assertEquals(HTTPStatus.NOT_MODIFIED, response.getStatus());
}
-
+
public void testCacheConf() throws Exception
{
ArrayList<CacheControlType> testValues = new ArrayList<CacheControlType>();
13 years, 10 months
exo-jcr SVN: r2988 - jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-08-25 10:39:42 -0400 (Wed, 25 Aug 2010)
New Revision: 2988
Modified:
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java
Log:
EXOJCR-879: test fixed
Modified: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java 2010-08-25 08:34:21 UTC (rev 2987)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java 2010-08-25 14:39:42 UTC (rev 2988)
@@ -63,52 +63,52 @@
{
Node contentNode = node.getNode("jcr:content");
Property lastModifiedProperty = contentNode.getProperty("jcr:lastModified");
-
+
SimpleDateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.US);
Calendar lastModifiedDate = lastModifiedProperty.getDate();
-
- lastModifiedDate.roll(Calendar.SECOND, -10);
+
+ lastModifiedDate.add(Calendar.SECOND, -10);
// Rollback If-Modified-Since 10 seconds earlier.
String ifModifiedDate = dateFormat.format(lastModifiedDate.getTime());
-
+
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
headers.add(ExtHttpHeaders.IF_MODIFIED_SINCE, ifModifiedDate);
ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", headers, null);
-
+
assertEquals(HTTPStatus.OK, response.getStatus());
}
-
+
public void testIfModifiedSince() throws Exception
{
Node contentNode = node.getNode("jcr:content");
Property lastModifiedProperty = contentNode.getProperty("jcr:lastModified");
-
+
SimpleDateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.US);
Calendar lastModifiedDate = lastModifiedProperty.getDate();
-
+
lastModifiedDate.add(Calendar.WEEK_OF_MONTH, 1);
String ifModifiedDate = dateFormat.format(lastModifiedDate.getTime());
-
+
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
headers.add(ExtHttpHeaders.IF_MODIFIED_SINCE, ifModifiedDate);
ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", headers, null);
-
+
assertEquals(HTTPStatus.NOT_MODIFIED, response.getStatus());
}
public void _testModifiedSinceLocaleFR() throws Exception
{
- SimpleDateFormat sdf = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.FRENCH);
+ SimpleDateFormat sdf = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.FRENCH);
String ifModifiedDate = sdf.format(sdf.getCalendar().getTime());
-
+
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
headers.add(ExtHttpHeaders.IF_MODIFIED_SINCE, ifModifiedDate);
ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", headers, null);
-
+
assertEquals(HTTPStatus.OK, response.getStatus());
}
-
+
public void testCacheConf() throws Exception
{
ArrayList<CacheControlType> testValues = new ArrayList<CacheControlType>();
13 years, 10 months
exo-jcr SVN: r2987 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-08-25 04:34:21 -0400 (Wed, 25 Aug 2010)
New Revision: 2987
Removed:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
Log:
EXOJCR-898: Changes reverted since it creates regressions
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2010-08-25 08:21:19 UTC (rev 2986)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2010-08-25 08:34:21 UTC (rev 2987)
@@ -347,13 +347,12 @@
if (addACL)
{
+ AccessControlList acl = new AccessControlList();
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
exoNamespaces =
TransientNodeData.createNodeData(nsSystem, Constants.EXO_NAMESPACES, Constants.NT_UNSTRUCTURED, mixins);
- AccessControlList acl = exoNamespaces.getACL();
-
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(exoNamespaces, Constants.JCR_PRIMARYTYPE, PropertyType.NAME,
false, new TransientValueData(exoNamespaces.getPrimaryTypeName()));
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2010-08-25 08:21:19 UTC (rev 2986)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2010-08-25 08:34:21 UTC (rev 2987)
@@ -139,6 +139,9 @@
: Constants.NT_UNSTRUCTURED;
this.dataManager = dataManager;
+ // this.nsPersister = nsPersister;
+ // this.ntRegistry = ntRegistry;
+
}
public NodeData initWorkspace() throws RepositoryException
@@ -270,14 +273,13 @@
if (addACL)
{
+ AccessControlList acl = new AccessControlList();
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
jcrSystem =
TransientNodeData.createNodeData(root, Constants.JCR_SYSTEM, Constants.NT_UNSTRUCTURED, mixins,
Constants.SYSTEM_UUID);
- AccessControlList acl = jcrSystem.getACL();
-
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(jcrSystem, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
new TransientValueData(jcrSystem.getPrimaryTypeName()));
@@ -338,6 +340,15 @@
dataManager.save(new TransactionChangesLog(changesLog));
+ //nsPersister.initStorage(jcrSystem, addACL, NamespaceRegistryImpl.DEF_NAMESPACES);
+ // nodeTypes save
+ // changesLog = new PlainChangesLogImpl();
+ // changesLog.addAll(ntPersister.initNodetypesRoot(jcrSystem,
+ // addACL).getAllStates());
+ // changesLog.addAll(ntPersister.initStorage(nodeTypeDataManager.getAllNodeTypes()).getAllStates());
+ // ntPersister.saveChanges(changesLog);
+
+ // nodeTypeDataManager.initDefaultNodeTypes(addACL);
return jcrSystem;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2010-08-25 08:21:19 UTC (rev 2986)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2010-08-25 08:34:21 UTC (rev 2987)
@@ -153,14 +153,13 @@
if (addACL)
{
+ AccessControlList acl = new AccessControlList();
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
jcrNodetypes =
TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES, Constants.NT_UNSTRUCTURED, mixins,
Constants.NODETYPESROOT_UUID);
- AccessControlList acl = jcrNodetypes.getACL();
-
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
new TransientValueData(jcrNodetypes.getPrimaryTypeName()));
Deleted: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java 2010-08-25 08:21:19 UTC (rev 2986)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java 2010-08-25 08:34:21 UTC (rev 2987)
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2010 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.access;
-
-import org.exoplatform.services.jcr.BaseStandaloneTest;
-import org.exoplatform.services.jcr.core.CredentialsImpl;
-
-import javax.jcr.AccessDeniedException;
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.Session;
-
-/**
- * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
- * @version $Id: TestRemoveSysteNode.java 111 2010-11-11 11:11:11Z tolusha $
- *
- */
-public class TestRemoveNodeTypeNode extends BaseStandaloneTest {
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getRepositoryName() {
- return null;
- }
-
- public void testRemove() throws Exception {
- Repository repository = repositoryService.getRepository("db1tck");
- Credentials credentials = new CredentialsImpl("demo", "exo".toCharArray());
- Session session = repository.login(credentials, "ws");
-
- Node node = session.getRootNode()
- .getNode("jcr:system")
- .getNode("jcr:nodetypes")
- .getNode("nt:base");
- try {
- node.remove();
- session.save();
-
- fail("Exception should be thrown.");
- } catch (AccessDeniedException e) {
- }
- }
-}
13 years, 10 months
exo-jcr SVN: r2986 - in jcr/branches/1.12.x/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-08-25 04:21:19 -0400 (Wed, 25 Aug 2010)
New Revision: 2986
Removed:
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
Log:
EXOJCR-898: Changes reverted since it creates regressions
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2010-08-25 07:15:10 UTC (rev 2985)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2010-08-25 08:21:19 UTC (rev 2986)
@@ -347,13 +347,12 @@
if (addACL)
{
+ AccessControlList acl = new AccessControlList();
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
exoNamespaces =
TransientNodeData.createNodeData(nsSystem, Constants.EXO_NAMESPACES, Constants.NT_UNSTRUCTURED, mixins);
- AccessControlList acl = exoNamespaces.getACL();
-
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(exoNamespaces, Constants.JCR_PRIMARYTYPE, PropertyType.NAME,
false, new TransientValueData(exoNamespaces.getPrimaryTypeName()));
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2010-08-25 07:15:10 UTC (rev 2985)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2010-08-25 08:21:19 UTC (rev 2986)
@@ -139,6 +139,9 @@
: Constants.NT_UNSTRUCTURED;
this.dataManager = dataManager;
+ // this.nsPersister = nsPersister;
+ // this.ntRegistry = ntRegistry;
+
}
public NodeData initWorkspace() throws RepositoryException
@@ -270,14 +273,13 @@
if (addACL)
{
+ AccessControlList acl = new AccessControlList();
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
jcrSystem =
TransientNodeData.createNodeData(root, Constants.JCR_SYSTEM, Constants.NT_UNSTRUCTURED, mixins,
Constants.SYSTEM_UUID);
- AccessControlList acl = jcrSystem.getACL();
-
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(jcrSystem, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
new TransientValueData(jcrSystem.getPrimaryTypeName()));
@@ -338,6 +340,15 @@
dataManager.save(new TransactionChangesLog(changesLog));
+ //nsPersister.initStorage(jcrSystem, addACL, NamespaceRegistryImpl.DEF_NAMESPACES);
+ // nodeTypes save
+ // changesLog = new PlainChangesLogImpl();
+ // changesLog.addAll(ntPersister.initNodetypesRoot(jcrSystem,
+ // addACL).getAllStates());
+ // changesLog.addAll(ntPersister.initStorage(nodeTypeDataManager.getAllNodeTypes()).getAllStates());
+ // ntPersister.saveChanges(changesLog);
+
+ // nodeTypeDataManager.initDefaultNodeTypes(addACL);
return jcrSystem;
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2010-08-25 07:15:10 UTC (rev 2985)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2010-08-25 08:21:19 UTC (rev 2986)
@@ -153,14 +153,13 @@
if (addACL)
{
+ AccessControlList acl = new AccessControlList();
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
jcrNodetypes =
TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES, Constants.NT_UNSTRUCTURED, mixins,
Constants.NODETYPESROOT_UUID);
- AccessControlList acl = jcrNodetypes.getACL();
-
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
new TransientValueData(jcrNodetypes.getPrimaryTypeName()));
Deleted: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java 2010-08-25 07:15:10 UTC (rev 2985)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java 2010-08-25 08:21:19 UTC (rev 2986)
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2010 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.access;
-
-import org.exoplatform.services.jcr.BaseStandaloneTest;
-import org.exoplatform.services.jcr.core.CredentialsImpl;
-
-import javax.jcr.AccessDeniedException;
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.Session;
-
-/**
- * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
- * @version $Id: TestRemoveSysteNode.java 111 2010-11-11 11:11:11Z tolusha $
- *
- */
-public class TestRemoveNodeTypeNode extends BaseStandaloneTest {
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getRepositoryName() {
- return null;
- }
-
- public void testRemove() throws Exception {
- Repository repository = repositoryService.getRepository("db1tck");
- Credentials credentials = new CredentialsImpl("demo", "exo".toCharArray());
- Session session = repository.login(credentials, "ws");
-
- Node node = session.getRootNode()
- .getNode("jcr:system")
- .getNode("jcr:nodetypes")
- .getNode("nt:base");
- try {
- node.remove();
- session.save();
-
- fail("Exception should be thrown.");
- } catch (AccessDeniedException e) {
- }
- }
-}
13 years, 10 months
exo-jcr SVN: r2985 - in ws/branches/2.1.x/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl: groovy and 1 other directory.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-08-25 03:15:10 -0400 (Wed, 25 Aug 2010)
New Revision: 2985
Added:
ws/branches/2.1.x/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/
ws/branches/2.1.x/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java
Log:
EXOJCR-890 : add TestCase
Added: ws/branches/2.1.x/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java
===================================================================
--- ws/branches/2.1.x/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java (rev 0)
+++ ws/branches/2.1.x/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java 2010-08-25 07:15:10 UTC (rev 2985)
@@ -0,0 +1,101 @@
+/*
+ * 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.ws.frameworks.json.impl.groovy;
+
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyObject;
+import junit.framework.TestCase;
+
+import org.exoplatform.ws.frameworks.json.JsonHandler;
+import org.exoplatform.ws.frameworks.json.impl.BeanBuilder;
+import org.exoplatform.ws.frameworks.json.impl.JsonDefaultHandler;
+import org.exoplatform.ws.frameworks.json.impl.JsonGeneratorImpl;
+import org.exoplatform.ws.frameworks.json.impl.JsonParserImpl;
+import org.exoplatform.ws.frameworks.json.value.JsonValue;
+import org.exoplatform.ws.frameworks.json.value.impl.ObjectValue;
+import org.exoplatform.ws.frameworks.json.value.impl.StringValue;
+
+import java.io.InputStreamReader;
+import java.util.Iterator;
+import java.util.List;
+
+public class GroovyBeanTest extends TestCase
+{
+
+ @SuppressWarnings("unchecked")
+ public void testRestoreGroovyBean() throws Exception
+ {
+ GroovyClassLoader cl = new GroovyClassLoader();
+ Class c = cl.parseClass(Thread.currentThread().getContextClassLoader().getResourceAsStream("SimpleBean.groovy"));
+ JsonValue ov = new ObjectValue();
+ StringValue sv = new StringValue("test restore groovy bean");
+ ov.addElement("value", sv);
+ assertEquals("test restore groovy bean", new BeanBuilder().createObject(c, ov).toString());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testSerializeGroovyBean() throws Exception
+ {
+ GroovyClassLoader cl = new GroovyClassLoader();
+ Class c = cl.parseClass(Thread.currentThread().getContextClassLoader().getResourceAsStream("SimpleBean.groovy"));
+ GroovyObject groovyObject = (GroovyObject)c.newInstance();
+ groovyObject.invokeMethod("setValue", new Object[]{"test serialize groovy bean"});
+ assertEquals("{\"value\":\"test serialize groovy bean\"}", new JsonGeneratorImpl().createJsonObject(groovyObject)
+ .toString());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testSerializeGroovyBean1() throws Exception
+ {
+ GroovyClassLoader cl = new GroovyClassLoader();
+ Class c = cl.parseClass(Thread.currentThread().getContextClassLoader().getResourceAsStream("BookStorage.groovy"));
+ GroovyObject groovyObject = (GroovyObject)c.newInstance();
+ groovyObject.invokeMethod("initStorage", new Object[]{});
+
+ JsonValue jsonValue = new JsonGeneratorImpl().createJsonObject(groovyObject);
+ //System.out.println(jsonValue);
+ assertTrue(jsonValue.isObject());
+ Iterator<JsonValue> iterator = jsonValue.getElement("books").getElements();
+ assertEquals("JUnit in Action", iterator.next().getElement("title").getStringValue());
+ assertEquals("Beginning C# 2008 from novice to professional", iterator.next().getElement("title")
+ .getStringValue());
+ assertEquals("Advanced JavaScript, Third Edition", iterator.next().getElement("title").getStringValue());
+ assertFalse(iterator.hasNext());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testRestoreGroovyBean1() throws Exception
+ {
+ GroovyClassLoader cl = new GroovyClassLoader();
+ Class c = cl.parseClass(Thread.currentThread().getContextClassLoader().getResourceAsStream("BookStorage.groovy"));
+ JsonParserImpl jsonParser = new JsonParserImpl();
+ JsonHandler jsonHandler = new JsonDefaultHandler();
+ jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
+ "BookStorage.txt")), jsonHandler);
+ JsonValue jv = jsonHandler.getJsonObject();
+ GroovyObject o = (GroovyObject)new BeanBuilder().createObject(c, jv);
+ //System.out.println(o);
+ List<GroovyObject> books = (List<GroovyObject>)o.getProperty("books");
+ assertEquals(3, books.size());
+ assertEquals(books.get(0).getProperty("title"), "JUnit in Action");
+ assertEquals(books.get(1).getProperty("title"), "Beginning C# 2008 from novice to professional");
+ assertEquals(books.get(2).getProperty("title"), "Advanced JavaScript. Third Edition");
+ }
+
+}
Property changes on: ws/branches/2.1.x/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
13 years, 10 months
exo-jcr SVN: r2984 - in ws: branches/2.1.x/exo.ws.frameworks.json and 3 other directories.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-08-25 03:05:59 -0400 (Wed, 25 Aug 2010)
New Revision: 2984
Added:
ws/branches/2.1.x/exo.ws.frameworks.json/src/test/resources/BookBean.groovy
ws/branches/2.1.x/exo.ws.frameworks.json/src/test/resources/BookStorage.groovy
ws/branches/2.1.x/exo.ws.frameworks.json/src/test/resources/SimpleBean.groovy
ws/trunk/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/
ws/trunk/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java
Removed:
ws/trunk/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/
Modified:
ws/branches/2.1.x/exo.ws.frameworks.json/pom.xml
ws/branches/2.1.x/pom.xml
Log:
EXOJCR-890 : add TestCase
Modified: ws/branches/2.1.x/exo.ws.frameworks.json/pom.xml
===================================================================
--- ws/branches/2.1.x/exo.ws.frameworks.json/pom.xml 2010-08-25 05:24:18 UTC (rev 2983)
+++ ws/branches/2.1.x/exo.ws.frameworks.json/pom.xml 2010-08-25 07:05:59 UTC (rev 2984)
@@ -39,6 +39,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -48,6 +53,7 @@
<includes>
<include>**/*.json</include>
<include>**/*.txt</include>
+ <include>**/*.groovy</include>
</includes>
</testResource>
</testResources>
Added: ws/branches/2.1.x/exo.ws.frameworks.json/src/test/resources/BookBean.groovy
===================================================================
--- ws/branches/2.1.x/exo.ws.frameworks.json/src/test/resources/BookBean.groovy (rev 0)
+++ ws/branches/2.1.x/exo.ws.frameworks.json/src/test/resources/BookBean.groovy 2010-08-25 07:05:59 UTC (rev 2984)
@@ -0,0 +1,32 @@
+public class BookBean
+{
+
+ String author
+
+ String title
+
+ double price
+
+ long isdn
+
+ int pages
+
+ boolean availability
+
+ boolean delivery
+
+ String toString()
+ {
+ StringBuffer sb = new StringBuffer()
+ sb.append("Book:{").append("Author: ").append(author).append(" ").append("Title: ").append(title).append(" ")
+ .append("Pages: ").append(pages).append(" ").append("Price: ").append(price).append(" ").append("ISDN: ")
+ .append(isdn).append("Availability: ").append(availability).append(" ").append("Delivery: ").append(delivery)
+ .append(" ").append("} ")
+ sb.toString()
+ }
+
+ boolean equals(Object other)
+ {
+ return other != null && other instanceof BookBean && other.author == author && other.title == title && other.isdn == isdn && other.pages == pages && other.price == price && other.availability == availability && other.delivery == delivery
+ }
+}
\ No newline at end of file
Added: ws/branches/2.1.x/exo.ws.frameworks.json/src/test/resources/BookStorage.groovy
===================================================================
--- ws/branches/2.1.x/exo.ws.frameworks.json/src/test/resources/BookStorage.groovy (rev 0)
+++ ws/branches/2.1.x/exo.ws.frameworks.json/src/test/resources/BookStorage.groovy 2010-08-25 07:05:59 UTC (rev 2984)
@@ -0,0 +1,51 @@
+
+public class BookStorage
+{
+
+ List<BookBean> books = new ArrayList<BookBean>()
+
+ public BookStorage()
+ {
+ }
+
+ void initStorage()
+ {
+
+ BookBean b1 = new BookBean(
+ author:'Vincent Masson',
+ title:'JUnit in Action',
+ pages:386,
+ price:19.37,
+ isdn:93011099534534L,
+ availability:true,
+ delivery:true)
+
+ BookBean b2 = new BookBean(
+ author:'Christian Gross',
+ title:'Beginning C# 2008 from novice to professional',
+ pages:511,
+ price:23.56,
+ isdn:9781590598696L,
+ availability:true,
+ delivery:true)
+
+ BookBean b3 = new BookBean(
+ author:'Chuck Easttom',
+ title:'Advanced JavaScript, Third Edition',
+ pages:617,
+ price:25.99,
+ isdn:9781598220339L,
+ availability:false,
+ delivery:false)
+
+ books.add(b1)
+ books.add(b2)
+ books.add(b3)
+ }
+
+ String toString()
+ {
+ books.toString()
+ }
+
+}
\ No newline at end of file
Added: ws/branches/2.1.x/exo.ws.frameworks.json/src/test/resources/SimpleBean.groovy
===================================================================
--- ws/branches/2.1.x/exo.ws.frameworks.json/src/test/resources/SimpleBean.groovy (rev 0)
+++ ws/branches/2.1.x/exo.ws.frameworks.json/src/test/resources/SimpleBean.groovy 2010-08-25 07:05:59 UTC (rev 2984)
@@ -0,0 +1,9 @@
+public class SimpleBean
+{
+ String value
+
+ String toString()
+ {
+ value
+ }
+}
\ No newline at end of file
Modified: ws/branches/2.1.x/pom.xml
===================================================================
--- ws/branches/2.1.x/pom.xml 2010-08-25 05:24:18 UTC (rev 2983)
+++ ws/branches/2.1.x/pom.xml 2010-08-25 07:05:59 UTC (rev 2984)
@@ -167,6 +167,12 @@
<version>1.5.8</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>1.6.5</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</dependencyManagement>
<dependencies>
Added: ws/trunk/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java
===================================================================
--- ws/trunk/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java (rev 0)
+++ ws/trunk/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java 2010-08-25 07:05:59 UTC (rev 2984)
@@ -0,0 +1,101 @@
+/*
+ * 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.ws.frameworks.json.impl.groovy;
+
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyObject;
+import junit.framework.TestCase;
+
+import org.exoplatform.ws.frameworks.json.JsonHandler;
+import org.exoplatform.ws.frameworks.json.impl.BeanBuilder;
+import org.exoplatform.ws.frameworks.json.impl.JsonDefaultHandler;
+import org.exoplatform.ws.frameworks.json.impl.JsonGeneratorImpl;
+import org.exoplatform.ws.frameworks.json.impl.JsonParserImpl;
+import org.exoplatform.ws.frameworks.json.value.JsonValue;
+import org.exoplatform.ws.frameworks.json.value.impl.ObjectValue;
+import org.exoplatform.ws.frameworks.json.value.impl.StringValue;
+
+import java.io.InputStreamReader;
+import java.util.Iterator;
+import java.util.List;
+
+public class GroovyBeanTest extends TestCase
+{
+
+ @SuppressWarnings("unchecked")
+ public void testRestoreGroovyBean() throws Exception
+ {
+ GroovyClassLoader cl = new GroovyClassLoader();
+ Class c = cl.parseClass(Thread.currentThread().getContextClassLoader().getResourceAsStream("SimpleBean.groovy"));
+ JsonValue ov = new ObjectValue();
+ StringValue sv = new StringValue("test restore groovy bean");
+ ov.addElement("value", sv);
+ assertEquals("test restore groovy bean", new BeanBuilder().createObject(c, ov).toString());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testSerializeGroovyBean() throws Exception
+ {
+ GroovyClassLoader cl = new GroovyClassLoader();
+ Class c = cl.parseClass(Thread.currentThread().getContextClassLoader().getResourceAsStream("SimpleBean.groovy"));
+ GroovyObject groovyObject = (GroovyObject)c.newInstance();
+ groovyObject.invokeMethod("setValue", new Object[]{"test serialize groovy bean"});
+ assertEquals("{\"value\":\"test serialize groovy bean\"}", new JsonGeneratorImpl().createJsonObject(groovyObject)
+ .toString());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testSerializeGroovyBean1() throws Exception
+ {
+ GroovyClassLoader cl = new GroovyClassLoader();
+ Class c = cl.parseClass(Thread.currentThread().getContextClassLoader().getResourceAsStream("BookStorage.groovy"));
+ GroovyObject groovyObject = (GroovyObject)c.newInstance();
+ groovyObject.invokeMethod("initStorage", new Object[]{});
+
+ JsonValue jsonValue = new JsonGeneratorImpl().createJsonObject(groovyObject);
+ //System.out.println(jsonValue);
+ assertTrue(jsonValue.isObject());
+ Iterator<JsonValue> iterator = jsonValue.getElement("books").getElements();
+ assertEquals("JUnit in Action", iterator.next().getElement("title").getStringValue());
+ assertEquals("Beginning C# 2008 from novice to professional", iterator.next().getElement("title")
+ .getStringValue());
+ assertEquals("Advanced JavaScript, Third Edition", iterator.next().getElement("title").getStringValue());
+ assertFalse(iterator.hasNext());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testRestoreGroovyBean1() throws Exception
+ {
+ GroovyClassLoader cl = new GroovyClassLoader();
+ Class c = cl.parseClass(Thread.currentThread().getContextClassLoader().getResourceAsStream("BookStorage.groovy"));
+ JsonParserImpl jsonParser = new JsonParserImpl();
+ JsonHandler jsonHandler = new JsonDefaultHandler();
+ jsonParser.parse(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(
+ "BookStorage.txt")), jsonHandler);
+ JsonValue jv = jsonHandler.getJsonObject();
+ GroovyObject o = (GroovyObject)new BeanBuilder().createObject(c, jv);
+ //System.out.println(o);
+ List<GroovyObject> books = (List<GroovyObject>)o.getProperty("books");
+ assertEquals(3, books.size());
+ assertEquals(books.get(0).getProperty("title"), "JUnit in Action");
+ assertEquals(books.get(1).getProperty("title"), "Beginning C# 2008 from novice to professional");
+ assertEquals(books.get(2).getProperty("title"), "Advanced JavaScript. Third Edition");
+ }
+
+}
Property changes on: ws/trunk/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
13 years, 10 months
exo-jcr SVN: r2983 - ws/trunk/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-08-25 01:24:18 -0400 (Wed, 25 Aug 2010)
New Revision: 2983
Modified:
ws/trunk/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java
Log:
EXOJCR-890
Modified: ws/trunk/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java
===================================================================
--- ws/trunk/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java 2010-08-25 05:21:03 UTC (rev 2982)
+++ ws/trunk/exo.ws.frameworks.json/src/test/java/org/exoplatform/ws/frameworks/json/impl/groovy/GroovyBeanTest.java 2010-08-25 05:24:18 UTC (rev 2983)
@@ -1,3 +1,21 @@
+/*
+ * 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.ws.frameworks.json.impl.groovy;
import groovy.lang.GroovyClassLoader;
13 years, 10 months