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 "JackRabbitOnWeblogic" by RayPolk
Date Wed, 19 Sep 2007 18:41:06 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 RayPolk:
http://wiki.apache.org/jackrabbit/JackRabbitOnWeblogic

------------------------------------------------------------------------------
  
   * write scripting to map dirs to local system
   * add entry to content-config.xml
+ 
+ === Sample content-config.xml ===
+ {{{
+ <?xml version="1.0" encoding="UTF-8"?>
+ <content-config xmlns="http://www.bea.com/ns/portal/90/content-config">
+     <!-- 
+       Sample content-config.xml
+       -->
+     <content-store>
+         <name>BEA Repository</name>
+         <description>Default Content Repository Configuration</description>
+         <class-name>com.bea.content.spi.internal.ExtendedRepositoryImpl</class-name>
+         <repository-property>
+             <description>Data source to use.</description>
+             <name>CM_DATA_SOURCE</name>
+             <value>contentDataSource</value>
+         </repository-property>
+         <repository-property>
+             <description>Enable repository events for full-text search.</description>
+             <name>cm_fireRepositoryEvents</name>
+             <value>false</value>
+         </repository-property>
+ 		<repository-property>
+             <description>Enable Library Services</description>
+             <name>MANAGEMENT_ENABLED</name>
+             <value>true</value>
+         </repository-property>        
+         <read-only>false</read-only>
+         <binary-cache-max-entry-size>1024</binary-cache-max-entry-size>
+         <!-- metadata search -->
+         <search-is-enabled>true</search-is-enabled>
+         <!-- full text search -->
+         <fulltext-search-is-enabled>false</fulltext-search-is-enabled>
+         <search-indexing-is-enabled>true</search-indexing-is-enabled>
+     </content-store>
+     <content-store>
+         <name>Jackrabbit</name>
+         <description>Jackrabbit JNDI Content Repository Configuration</description>
+         <class-name>com.day.content.spi.jsr170.JNDIRepository</class-name>
+         <repository-property>
+             <description>JSR-170 Repository Workspace</description>
+             <name>jsr170.workspace</name>
+             <value>jackrabbit</value>
+         </repository-property>
+         <repository-property>
+             <description>JSR-170 Repository JNDI name</description>
+             <name>jsr170.jndi.name</name>
+             <value>repository</value>
+         </repository-property>
+         <read-only>false</read-only>
+         <binary-cache-max-entry-size>1024</binary-cache-max-entry-size>
+         <search-is-enabled>true</search-is-enabled>
+         <fulltext-search-is-enabled>false</fulltext-search-is-enabled>
+         <search-indexing-is-enabled>true</search-indexing-is-enabled>
+     </content-store>
+ </content-config>
+ }}}
   * write custom node type def file (cnd)
+ === Sample Custom Node Type Definition File ===
+ {{{
+ <nt = 'http://www.jcp.org/jcr/nt/1.0'>
+ <flix = 'http://wlp.bea.com/jcr/1.0/flix'>
+ 
+ [flix:MEDIA] > nt:unstructured
+  - flix:TITLE (string) primary mandatory
+  - flix:RELEASE_DATE (long) mandatory
+  - flix:THUMBNAIL (binary)
+  - flix:LENGTH (long)
+  - flix:DIRECTOR (name) mandatory
+  - flix:CAST (name) mandatory multiple
+  - flix:GENRE (string) mandatory multiple
+    < 'Action', 'Comedy', 'Drama', 'Horror', 'Romance', 'Sci-Fi & Fantasy', 'Thrillers'

+  - flix:MEDIA_TYPE (string) = 'DVD' mandatory
+    < 'VHS', 'DVD', 'Blue-Ray', 'HD DVD', 'CD', 'PS3', 'XBOX 360', 'Wii', 'PS2'
+  - flix:IMDB_LINK (string)
+  - flix:QUOTES (string) multiple
+  - flix:SYNOPSIS (string) mandatory
+  - flix:TRAILER_CLIP (binary)
+  - flix:STOCK_STATUS (string) = 'in stock' mandatory
+    < 'unreleased', 'in stock', 'out of stock'
+ }}}
   * write code against jackrabbit api to create types & content
+ === Sample Type and Node Creation Code ===
+ {{{
+ package com.bea.wlp.scenarios.flix.jackrabbit;
+ 
+ import javax.jcr.NamespaceException;
+ import javax.jcr.NamespaceRegistry;
+ import javax.jcr.Node;
+ import javax.jcr.Workspace;
+ import javax.jcr.Repository;
+ import javax.jcr.Session;
+ import javax.jcr.SimpleCredentials;
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ 
+ import org.apache.jackrabbit.core.TransientRepository;
+ import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
+ import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
+ import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
+ import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
+ import org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader;
+ import java.io.FileReader;
+ import java.io.InputStreamReader;
+ import java.io.Reader;
+ import java.util.Calendar;
+ import java.util.Date;
+ import java.util.Hashtable;
+ import java.util.List;
+ import java.util.Iterator;
+ 
+ public class CustomNodeTypeLoader 
+ {
+     public static final String REPO_JNDI_NAME = "repository";
+ 	public static final String CND_FILE_NAME = "/schemas/flixTypes.cnd";
+     public static final String FLIX_NS_PREFIX = "flix";
+     public static final String FLIX_NS_URI = "http://wlp.bea.com/jcr/1.0/flix";
+ 
+     public void loadCustomNodeTypes()
+     {
+         try
+         {
+             InitialContext ctx = new InitialContext();
+             Repository repository = (Repository)ctx.lookup(REPO_JNDI_NAME);
+ 
+             Session session = repository.login(new SimpleCredentials("weblogic", "weblogic".toCharArray()));
+             Workspace ws = session.getWorkspace();
+             
+             NamespaceRegistry nsr = ws.getNamespaceRegistry();
+             
+             try {
+             	nsr.registerNamespace(FLIX_NS_PREFIX, FLIX_NS_URI);
+             } catch (NamespaceException e) {
+                 // ignore - implies we've already registered the namespace
+             } catch (Exception e) {
+                 throw new RuntimeException(e);
+             }
+ 
+             Reader cndFileReader = new InputStreamReader(this.getClass().getResourceAsStream(CND_FILE_NAME));
+             
+             // Create a CompactNodeTypeDefReader
+             CompactNodeTypeDefReader cndReader = new CompactNodeTypeDefReader(cndFileReader,
CND_FILE_NAME);
+     
+             // Get the List of NodeTypeDef objects
+             List ntdList = cndReader.getNodeTypeDefs();
+     
+             // Get the NodeTypeManager from the Workspace.
+             // Note that it must be cast from the generic JCR NodeTypeManager to the
+             // Jackrabbit-specific implementation.
+             NodeTypeManagerImpl ntmgr =(NodeTypeManagerImpl)ws.getNodeTypeManager();
+     
+             // Acquire the NodeTypeRegistry
+             NodeTypeRegistry ntreg = ntmgr.getNodeTypeRegistry();
+     
+             // Loop through the prepared NodeTypeDefs
+             for (Iterator i = ntdList.iterator(); i.hasNext();) {
+     
+                 // Get the NodeTypeDef...
+                 NodeTypeDef ntd = (NodeTypeDef)i.next();
+ 
+                 try {
+ 	                // ...and register it
+ 	                ntreg.registerNodeType(ntd);
+ 	            } catch (InvalidNodeTypeDefException e) {
+ 	                // ignore - implies we've already created the type
+ 	            } catch (Exception e) {
+ 	                throw new RuntimeException(e);
+ 	            }
+             }
+             
+             Node rootNode = session.getRootNode();
+             Node baseNode = rootNode.addNode("Flix Media Auto", "nt:unstructured");
+             
+             Calendar releaseDate = Calendar.getInstance();
+             
+             releaseDate.set(2007, 8, 17);
+             createNode(baseNode, "Superbad", releaseDate, 114, "Greg Mottola", "Jonah Hill",
"Comdey", "DVD", 
+             		"http://www.imdb.com/title/tt0829482/", "Same-sies!", "Hilarous!", "unreleased");
+             
+             
+             session.save();
+         } catch (InvalidNodeTypeDefException e) {
+             // ignore - implies we've already created everything
+         } catch (Exception e) {
+             throw new RuntimeException(e);
+         }
+     }
+     
+     public void createNode(Node parentNode, String title, Calendar releaseDate, long length,
String director, 
+     		String castMember, String genre, String mediaType, String imdbLink, String quote,
String synopsis, 
+     		String stockStatus)
+     	throws Exception
+     {
+     	Node newNode = parentNode.addNode(title, "flix:MEDIA");
+         newNode.setProperty("flix:TITLE", title);
+         newNode.setProperty("flix:RELEASE_DATE", releaseDate);
+         newNode.setProperty("flix:LENGTH", length);
+         newNode.setProperty("flix:DIRECTOR", director);
+         newNode.setProperty("flix:CAST", castMember);
+         newNode.setProperty("flix:GENRE", genre);
+         newNode.setProperty("flix:MEDIA_TYPE", mediaType);
+         newNode.setProperty("flix:IMDB_LINK", imdbLink);
+         newNode.setProperty("flix:QUOTES", quote);
+         newNode.setProperty("flix:SYNOPSIS", synopsis);
+         newNode.setProperty("flix:STOCK_STATUS", stockStatus);
+     }
+ }
+ }}}
   * add app lifecycle listener or filter to call type creation code
-  * use federated cm api to create and access content
+  * use federated cm api to create and access content (e.g. http://edocs/wlp/docs100/cm/index.html
)
  
+ Also see:  http://edocs/wlp/docs100/pdf/day170adapter_developers_guide.pdf
+ 

Mime
View raw message