jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Jackrabbit Wiki] Update of "ExamplesPage" by RobertRitchy
Date Fri, 08 Jul 2005 23:00:32 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jackrabbit Wiki" for change notification.

The following page has been changed by RobertRitchy:
http://wiki.apache.org/jackrabbit/ExamplesPage

------------------------------------------------------------------------------
- This page will be used to show solutions to common problems related to JSR 170 and Jackrabbit.
These examples shouldn't necessarily be considered '''Best Practices''' because things like
error checking have been omitted to keep them simple.
+ This page will be used to show solutions to common problems related to JSR 170 and Jackrabbit.
These examples shouldn't necessarily be considered Best Practices because things like error
checking have been omitted to keep them simple.
  
  
+ 
+ 
+ 
- '''Importing a File''' - also [http://svn.apache.org/repos/asf/incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/FSImport.java
FSImport.java] for more complete filesystem examples.
+ '''Importing a File''' - also see: [http://svn.apache.org/repos/asf/incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/FSImport.java
FSImport.java] for more complete filesystem examples.
  
  {{{
      public Node importFile (Node folderNode, File file, String mimeType,
@@ -25, +28 @@

      }
  }}}
  
+ 
+ 
+ 
  '''Renaming a Property or Node'''
  {{{
      void rename (Item item, String newName) throws RepositoryException 
@@ -32, +38 @@

          item.getSession().move(item.getPath(), item.getParent().getPath() + "/" + newName);
      }
  }}}
+ 
+ 
  
  
  '''Register a Node type''' - there are a few solutions in the works [http://svn.osafoundation.org/server/commons/trunk/jackrabbit/
Offline tool],  [http://issues.apache.org/jira/browse/GRFT-23 Graffito Jira Issue]
@@ -50, +58 @@

      }
  }}}
  
+ 
+ 
+ 
+ '''Versioning basics'''
+ {{{
+     public void versioningBasics (Node parentNode, Session session) throws RepositoryException
+     {
+           //create versionable node
+           Node n = parentNode.addNode("childNode", "nt:unstructured");
+           n.addMixin("mix:versionable");
+           n.setProperty("anyProperty", "Blah");
+           session.save();
+           Version firstVersion = n.checkin();
+ 
+           //add new version
+           Node child = parentNode.getNode("childNode");
+           child.checkout();
+           child.setProperty("anyProperty", "Blah2");
+           session.save();
+           child.checkin();
+ 
+           //print version history
+           VersionHistory history = child.getVersionHistory();
+           for (VersionIterator it = history.getAllVersions(); it.hasNext();) {
+             Version version = (Version) it.next();
+             System.out.println(version.getCreated().getTime());
+           }
+           
+           //restoring old version
+           child.checkout();
+           child.restore(firstVersion, true);          
+     }
+ }}}
+ 

Mime
View raw message