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 === + {{{ + + + + + BEA Repository + Default Content Repository Configuration + com.bea.content.spi.internal.ExtendedRepositoryImpl + + Data source to use. + CM_DATA_SOURCE + contentDataSource + + + Enable repository events for full-text search. + cm_fireRepositoryEvents + false + + + Enable Library Services + MANAGEMENT_ENABLED + true + + false + 1024 + + true + + false + true + + + Jackrabbit + Jackrabbit JNDI Content Repository Configuration + com.day.content.spi.jsr170.JNDIRepository + + JSR-170 Repository Workspace + jsr170.workspace + jackrabbit + + + JSR-170 Repository JNDI name + jsr170.jndi.name + repository + + false + 1024 + true + false + true + + + }}} * write custom node type def file (cnd) + === Sample Custom Node Type Definition File === + {{{ + + + + [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 +