You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by re...@locus.apache.org on 2000/12/04 02:41:49 UTC
cvs commit: jakarta-slide/src/examples/xml Domain.xml Test.java
remm 00/12/03 17:41:49
Modified: src/examples/xml Domain.xml Test.java
Added: src/examples/version Domain.xml Test.java
Log:
- Small cosmetic update to the XML example.
- Add the versioning example, which creates an object, then adds some
revisions to the object, creates a new branch and adds some revisions to it,
and finally merges the two branches.
Revision Changes Path
1.1 jakarta-slide/src/examples/version/Domain.xml
Index: Domain.xml
===================================================================
<?xml version="1.0"?>
<slide>
<namespace name="version">
<definition>
<store name="memory">
<contentstore name="file"
classname="slidestore.file.FileContentStoreNoVersioning">
<parameter name="rootpath">files</parameter>
</contentstore>
</store>
<scope match="/" store="memory" />
</definition>
<configuration>
<default-action>/actions</default-action>
<userspath>/users</userspath>
<filespath></filespath>
<parameter name="dav">true</parameter>
<parameter name="standalone">true</parameter>
</configuration>
<data>
<objectnode classname="org.apache.slide.structure.SubjectNode" uri="/">
<permission action="/actions" subject="/users/root"/>
<!-- /users represents the unauthenticated user -->
<objectnode classname="org.apache.slide.structure.SubjectNode"
uri="/users">
<!-- /users/root represents the administrator -->
<objectnode classname="org.apache.slide.structure.SubjectNode"
uri="/users/root">
</objectnode>
<!-- /users/guest represents an authenticated guest user -->
<objectnode classname="org.apache.slide.structure.SubjectNode"
uri="/users/guest">
</objectnode>
</objectnode>
<objectnode classname="org.apache.slide.structure.ActionNode"
uri="/actions">
</objectnode>
</objectnode>
</data>
</namespace>
</slide>
1.1 jakarta-slide/src/examples/version/Test.java
Index: Test.java
===================================================================
/**
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "Exolab" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of Exoffice Technologies. For written permission,
* please contact info@exolab.org.
*
* 4. Products derived from this Software may not be called "Exolab"
* nor may "Exolab" appear in their names without prior written
* permission of Exoffice Technologies. Exolab is a registered
* trademark of Exoffice Technologies.
*
* 5. Due credit should be given to the Exolab Project
* (http://www.exolab.org/).
*
* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
*
* $Id: Test.java,v 1.1 2000/12/04 01:41:49 remm Exp $
*/
package version;
import java.util.Enumeration;
import java.util.Vector;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.Date;
import org.apache.slide.structure.*;
import org.apache.slide.content.*;
import org.apache.slide.common.*;
import org.apache.slide.lock.*;
import org.apache.slide.security.*;
import org.apache.slide.authenticate.CredentialsToken;
import org.apache.slide.authenticate.SecurityToken;
/**
* This is a test class for versioning support.
*/
public class Test {
public static void main(String[] args) {
NamespaceAccessToken token = null;
try {
token = Domain.accessNamespace(new SecurityToken(new String()),
"version");
Structure structure = token.getStructureHelper();
Security security = token.getSecurityHelper();
Lock lock = token.getLockHelper();
Content content = token.getContentHelper();
CredentialsToken credToken =
new CredentialsToken(new String("root"));
SlideToken slideToken = new SlideToken(credToken);
System.out.println("Creating a test subject");
SubjectNode subject = new SubjectNode();
structure.create(slideToken, subject, "/test");
// Creating a versioned revision descriptors
content.create(slideToken, "/test", true);
NodeRevisionDescriptors revisionDescriptors =
content.retrieve(slideToken, "/test");
// Now creating some revisions
NodeRevisionDescriptor revisionDescriptor =
new NodeRevisionDescriptor(0);
revisionDescriptor.setProperty("revision", "1");
content.create(slideToken, "/test", revisionDescriptor, null);
revisionDescriptor = content.retrieve
(slideToken, revisionDescriptors);
revisionDescriptor.setProperty("revision", "2");
content.create(slideToken, "/test", revisionDescriptor, null);
revisionDescriptor = content.retrieve
(slideToken, revisionDescriptors);
content.fork(slideToken, "/test", "branch2", revisionDescriptor);
revisionDescriptor = content.retrieve
(slideToken, revisionDescriptors, "branch2");
revisionDescriptor.setProperty("revision", "3");
content.create(slideToken, "/test", "branch2",
revisionDescriptor, null);
revisionDescriptor = content.retrieve
(slideToken, revisionDescriptors, "branch2");
revisionDescriptor.setProperty("revision", "4");
content.create(slideToken, "/test", "branch2", revisionDescriptor,
null);
revisionDescriptor = content.retrieve
(slideToken, revisionDescriptors);
revisionDescriptor.setProperty("revision", "5");
content.create(slideToken, "/test", revisionDescriptor, null);
content.merge(slideToken, "/test",
NodeRevisionDescriptors.MAIN_BRANCH, "branch2",
revisionDescriptor, null);
revisionDescriptor = content.retrieve
(slideToken, revisionDescriptors);
revisionDescriptor.setProperty("revision", "7");
content.create(slideToken, "/test", revisionDescriptor, null);
// Retrieving some revisions
revisionDescriptor =
content.retrieve(slideToken, revisionDescriptors);
System.out.println("Latest revision in the main branch : Number:"
+ revisionDescriptor.getRevisionNumber()
+ " Revision:"
+ revisionDescriptor.getProperty("revision")
.getValue());
revisionDescriptor =
content.retrieve(slideToken, revisionDescriptors, "branch2");
System.out.println("Latest revision in branch2 : Number:"
+ revisionDescriptor.getRevisionNumber()
+ " Revision:"
+ revisionDescriptor.getProperty("revision")
.getValue());
} catch (Throwable e) {
e.printStackTrace();
} finally {
System.out.println("Closing data sources");
Domain.closeNamespace(token);
}
}
}
1.3 +1 -1 jakarta-slide/src/examples/xml/Domain.xml
Index: Domain.xml
===================================================================
RCS file: /home/cvs/jakarta-slide/src/examples/xml/Domain.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Domain.xml 2000/12/02 07:33:30 1.2
+++ Domain.xml 2000/12/04 01:41:49 1.3
@@ -2,7 +2,7 @@
<slide>
- <namespace name="xmltest">
+ <namespace name="xml">
<definition>
1.5 +6 -6 jakarta-slide/src/examples/xml/Test.java
Index: Test.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/examples/xml/Test.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Test.java 2000/12/02 07:33:31 1.4
+++ Test.java 2000/12/04 01:41:49 1.5
@@ -40,7 +40,7 @@
*
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
*
- * $Id: Test.java,v 1.4 2000/12/02 07:33:31 remm Exp $
+ * $Id: Test.java,v 1.5 2000/12/04 01:41:49 remm Exp $
*/
package xml;
@@ -70,7 +70,7 @@
try {
token = Domain.accessNamespace(new SecurityToken(new String()),
- "xmltest");
+ "xml");
Structure structure = token.getStructureHelper();
Security security = token.getSecurityHelper();
@@ -203,7 +203,7 @@
long date1 = (new Date()).getTime();
- int nbcheck = 100000;
+ int nbcheck = 10000;
for (int i=0; i<nbcheck; i++) {
structure.retrieve(slideToken, "/toto/2/3/4/5");
@@ -348,10 +348,10 @@
+ latestRevision.getId() + " with date " + latestRevision.getCreationDate()
+ " and content : " + new String(latestRevision.getContent()));
- // Saving data
-
- token.exportData(slideToken, new FileWriter("Export.xml"), "/");
*/
+
+ // Saving data
+ token.exportData(slideToken, new FileWriter("Export.xml"));
} catch (Throwable e) {
e.printStackTrace();