Added:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/RepositoryAccessJackrabbit.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/RepositoryAccessJackrabbit.java?rev=1156196&view=auto
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/RepositoryAccessJackrabbit.java
(added)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/RepositoryAccessJackrabbit.java
Wed Aug 10 14:29:40 2011
@@ -0,0 +1,176 @@
+package org.ofbiz.jcr.access.jackrabbit;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import net.sf.json.JSONArray;
+
+import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
+import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl;
+import org.apache.jackrabbit.ocm.mapper.Mapper;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.AnnotationMapperImpl;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.jcr.access.ContentReader;
+import org.ofbiz.jcr.access.ContentWriter;
+import org.ofbiz.jcr.access.RepositoryAccess;
+import org.ofbiz.jcr.loader.JCRFactoryUtil;
+import org.ofbiz.jcr.orm.OfbizRepositoryMapping;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitFile;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitFolder;
+import
org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitHierarchyNode;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitNews;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitResource;
+import
org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitUnstructured;
+
+public class RepositoryAccessJackrabbit implements RepositoryAccess {
+
+ private static String module = RepositoryAccessJackrabbit.class.getName();
+
+ Session session = null;
+ ObjectContentManagerImpl ocm = null;
+
+ /**
+ * Create a repository Access object based on the userLogin.
+ *
+ * @param userLogin
+ */
+ public RepositoryAccessJackrabbit(GenericValue userLogin) {
+ // TODO pass the userLogin to the getSession() method and perform some
+ this(JCRFactoryUtil.getSession());
+ }
+
+ /**
+ * Create a repository Access object based on a JCR Session.
+ *
+ * @param userLogin
+ */
+ public RepositoryAccessJackrabbit(Session session) {
+ if (session == null) {
+ Debug.logWarning("A repository session is needed to create an
OfbizContentMapping Object.", module);
+ return;
+ }
+
+ this.session = session;
+
+ List<Class> classes = new ArrayList<Class>();
+ // put this in an xml configuration file
+ // should the ocm classes be loaded in during the container startup?
+ classes.add(OfbizRepositoryMappingJackrabbitUnstructured.class);
+ classes.add(OfbizRepositoryMappingJackrabbitHierarchyNode.class);
+ classes.add(OfbizRepositoryMappingJackrabbitNews.class);
+ classes.add(OfbizRepositoryMappingJackrabbitFile.class);
+ classes.add(OfbizRepositoryMappingJackrabbitFolder.class);
+ classes.add(OfbizRepositoryMappingJackrabbitResource.class);
+
+ Mapper mapper = new AnnotationMapperImpl(classes);
+ this.ocm = new ObjectContentManagerImpl(session, mapper);
+
+ return;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.RepositoryAccess#closeAccess()
+ */
+ @Override
+ public void closeAccess() {
+ if (this.ocm != null) {
+ this.ocm.logout();
+ }
+ this.ocm = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ofbiz.jcr.orm.RepositoryAccess#getContentObject(java.lang.String)
+ */
+ @Override
+ public OfbizRepositoryMapping getContentObject(String nodePath) {
+ ContentReader contentReader = new ContentReaderJackrabbit(this.ocm);
+ return contentReader.getContentObject(nodePath);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ofbiz.jcr.orm.RepositoryAccess#storeContentObject(org.ofbiz.jcr.orm
+ * .OfbizRepositoryMapping)
+ */
+ @Override
+ public void storeContentObject(OfbizRepositoryMapping orm) throws
ObjectContentManagerException {
+ ContentWriter contentWriter = new ContentWriterJackrabbit(this.ocm);
+ contentWriter.storeContentObject(orm);
+
+ return;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ofbiz.jcr.orm.RepositoryAccess#updateContentObject(org.ofbiz.jcr.
+ * orm.OfbizRepositoryMapping)
+ */
+ @Override
+ public void updateContentObject(OfbizRepositoryMapping orm) throws
ObjectContentManagerException {
+ ContentWriter contentWriter = new ContentWriterJackrabbit(this.ocm);
+ contentWriter.updateContentObject(orm);
+
+ return;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ofbiz.jcr.orm.RepositoryAccess#removeContentObject(java.lang.String)
+ */
+ @Override
+ public void removeContentObject(String nodePath) throws
ObjectContentManagerException {
+ ContentWriter contentWriter = new ContentWriterJackrabbit(this.ocm);
+ contentWriter.removeContentObject(nodePath);
+
+ return;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ofbiz.jcr.orm.RepositoryAccess#removeContentObject(org.ofbiz.jcr.
+ * orm.OfbizRepositoryMapping)
+ */
+ @Override
+ public void removeContentObject(OfbizRepositoryMapping orm) throws
ObjectContentManagerException {
+ removeContentObject(orm.getPath());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.RepositoryAccess#getJsonFileTree()
+ */
+ @Override
+ public JSONArray getJsonDataTree() throws RepositoryException {
+ ContentReader contentReader = new ContentReaderJackrabbit(this.ocm);
+ return contentReader.getJsonDataTree();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.ofbiz.jcr.access.RepositoryAccess#getJsonFileTree()
+ */
+ @Override
+ public JSONArray getJsonFileTree() throws RepositoryException {
+ ContentReader contentReader = new ContentReaderJackrabbit(this.ocm);
+ return contentReader.getJsonFileTree();
+ }
+}
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/RepositoryAccessJackrabbit.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java?rev=1156196&view=auto
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java
(added)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java
Wed Aug 10 14:29:40 2011
@@ -0,0 +1,118 @@
+package org.ofbiz.jcr.access.jackrabbit;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.version.VersionManager;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.jcr.access.VersioningManager;
+
+public class VersioningManagerJackrabbit implements VersioningManager {
+
+ private static String module = VersioningManagerJackrabbit.class.getName();
+
+ private volatile VersionManager versionManager = null;
+ private List<Node> checkedOutNodeStore = Collections.synchronizedList(new
ArrayList<Node>());
+ private Session session = null;
+
+ VersioningManagerJackrabbit(Session session) throws
UnsupportedRepositoryOperationException, RepositoryException {
+ versionManager = session.getWorkspace().getVersionManager();
+ this.session = session;
+ }
+
+ public VersionManager getVersionManager() {
+ return this.versionManager;
+ }
+
+ public void addNodeToCheckedOutStore(Node node) {
+ try {
+ if (!versionManager.isCheckedOut(node.getPath())) {
+ checkedOutNodeStore.add(node);
+ }
+ } catch (RepositoryException e) {
+ Debug.logError(e, module);
+ }
+ }
+
+ protected void saveSessionAndCheckinNode() {
+ try {
+ this.session.save();
+
+ for (Node node : checkedOutNodeStore) {
+ // add the new resource content to the version history
+ if (session.nodeExists(node.getPath()) &&
versionManager.isCheckedOut(node.getPath())) {
+ versionManager.checkin(node.getPath());
+ }
+ }
+
+ // reset the node store after everything is checked in
+ checkedOutNodeStore = new ArrayList<Node>();
+ } catch (RepositoryException e) {
+ Debug.logError(e, module);
+ }
+ }
+
+ protected void checkOutNode(Node node) {
+ try {
+ // make sure we don't checkout the root node, because it's not
+ // versionable
+ if (!ConstantsJackrabbit.ROOTPATH.equals(node.getPath())) {
+ versionManager.checkout(node.getPath());
+ checkedOutNodeStore.add(node);
+ }
+ } catch (RepositoryException e) {
+ Debug.logError(e, module);
+ }
+ }
+
+ /**
+ * Checks out recursively all related nodes (parent, all child's (if
exists)
+ * and the node itself)
+ *
+ * @param startNode
+ * @throws RepositoryException
+ */
+ protected void checkOutRelatedNodes(Node startNode) throws
RepositoryException {
+ List<Node> nodesToCheckOut = new ArrayList<Node>();
+ nodesToCheckOut.add(startNode);
+ nodesToCheckOut.add(startNode.getParent());
+ if (startNode.hasNodes()) {
+ nodesToCheckOut.addAll(getAllChildNodes(startNode));
+ }
+
+ for (Node node : nodesToCheckOut) {
+ checkOutNode(node);
+ }
+
+ }
+
+ /**
+ * Return recursively all child nodes
+ *
+ * @param startNode
+ * @return
+ * @throws RepositoryException
+ */
+ private List<Node> getAllChildNodes(Node startNode) throws
RepositoryException {
+ List<Node> nodes = new ArrayList<Node>();
+ NodeIterator ni = startNode.getNodes();
+ while (ni.hasNext()) {
+ Node nextNode = ni.nextNode();
+ if (nextNode.hasNodes()) {
+ nodes.addAll(getAllChildNodes(nextNode));
+ }
+
+ nodes.add(nextNode);
+ }
+
+ return nodes;
+ }
+
+}
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/handler/JcrEventHandler.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/handler/JcrEventHandler.java?rev=1156196&view=auto
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/handler/JcrEventHandler.java
(added)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/handler/JcrEventHandler.java
Wed Aug 10 14:29:40 2011
@@ -0,0 +1,5 @@
+package org.ofbiz.jcr.handler;
+
+public interface JcrEventHandler {
+
+}
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/handler/JcrEventHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRContainer.java
(from r1140127,
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/JCRContainer.java)
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRContainer.java?p2=ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRContainer.java&p1=ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/JCRContainer.java&r1=1140127&r2=1156196&rev=1156196&view=diff
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/JCRContainer.java
(original)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRContainer.java
Wed Aug 10 14:29:40 2011
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*******************************************************************************/
-package org.ofbiz.jcr;
+package org.ofbiz.jcr.loader;
+import javax.jcr.Repository;
import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.Reference;
@@ -35,8 +35,6 @@ import org.ofbiz.base.util.JNDIContextFa
import org.ofbiz.base.util.UtilXml;
import org.w3c.dom.Element;
-import com.sun.corba.se.spi.activation.Repository;
-
/**
* A container for a local JCR-compliant content repository. The default
* implementation uses Apache Jackrabbit.
@@ -88,6 +86,7 @@ public class JCRContainer implements Con
throw new ContainerException("No jcr configuration found in file "
+ configFilePath);
}
+ homeDir = UtilXml.childElementAttribute(configRootElement, "home-dir",
"path", "runtime/data/jcr/");
Element childElement = UtilXml.firstChildElement(configRootElement,
"jcr-context");
jcrContextName = UtilXml.elementAttribute(childElement, "name",
"default");
@@ -95,7 +94,6 @@ public class JCRContainer implements Con
for (Element curElement : UtilXml.childElementList(configRootElement,
"jcr")) {
if (jcrContextName.equals(curElement.getAttribute("name"))) {
factoryClassName = curElement.getAttribute("class");
- homeDir = curElement.getAttribute("home-dir");
jndiName = curElement.getAttribute("jndi-name");
break;
}
@@ -182,7 +180,7 @@ public class JCRContainer implements Con
protected void bindRepository() {
if (this.jndiContext != null) {
try {
- Reference ref = new Reference(Repository.class.getName(),
RepositoryFactory.class.getName(), null);
+ Reference ref = new Reference(Repository.class.getName(),
org.ofbiz.jcr.loader.RepositoryFactory.class.getName(), null);
ref.add(new StringRefAddr(REP_HOME_DIR, homeDir));
ref.add(new StringRefAddr(CONFIG_FILE_PATH, configFilePath));
this.jndiContext.bind(jndiName, ref);
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRContainer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRFactory.java
(from r1140127,
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/JCRFactory.java)
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRFactory.java?p2=ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRFactory.java&p1=ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/JCRFactory.java&r1=1140127&r2=1156196&rev=1156196&view=diff
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/JCRFactory.java
(original)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRFactory.java
Wed Aug 10 14:29:40 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*******************************************************************************/
-package org.ofbiz.jcr;
+package org.ofbiz.jcr.loader;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRFactoryUtil.java
(from r1140127,
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/JCRFactoryUtil.java)
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRFactoryUtil.java?p2=ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRFactoryUtil.java&p1=ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/JCRFactoryUtil.java&r1=1140127&r2=1156196&rev=1156196&view=diff
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/JCRFactoryUtil.java
(original)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRFactoryUtil.java
Wed Aug 10 14:29:40 2011
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*******************************************************************************/
-package org.ofbiz.jcr;
+package org.ofbiz.jcr.loader;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/JCRFactoryUtil.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/OFBizLoginModule.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/OFBizLoginModule.java?rev=1156196&view=auto
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/OFBizLoginModule.java
(added)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/OFBizLoginModule.java
Wed Aug 10 14:29:40 2011
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
*******************************************************************************/
+package org.ofbiz.jcr.loader;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+
+import javolution.util.FastMap;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.DelegatorFactory;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.service.GenericDispatcher;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ServiceUtil;
+
+public class OFBizLoginModule implements LoginModule {
+
+ public static final String module = OFBizLoginModule.class.getName();
+
+ protected Subject subject;
+ protected CallbackHandler callbackHandler;
+ protected Map<String, ?> sharedState;
+ protected Map<String, ?> options;
+
+ private Delegator delegator;
+ private LocalDispatcher dispatcher;
+
+ private GenericValue userLogin;
+
+ @Override
+ public boolean abort() throws LoginException {
+ return logout();
+ }
+
+ @Override
+ public boolean commit() throws LoginException {
+ if (userLogin != null) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void initialize(Subject subject, CallbackHandler callbackHandler,
Map<String, ?> sharedState, Map<String, ?> options) {
+ // get the delegator
+ delegator = DelegatorFactory.getDelegator("default");
+
+ // get the dispatcher
+ dispatcher = GenericDispatcher.getLocalDispatcher("auth-dispatcher",
delegator);
+
+ this.subject = subject;
+ this.callbackHandler = callbackHandler;
+ this.sharedState = sharedState;
+ this.options = options;
+
+ if (options != null) {
+ for (Map.Entry<String, ?> option : options.entrySet()) {
+ Debug.logWarning("OFBizLoginModule does not support provided
option [" + option.getKey() + "] with value [" + option.getValue() + "],
ignoring", module);
+ }
+ }
+ }
+
+ @Override
+ public boolean login() throws LoginException {
+ NameCallback nameCallback = new NameCallback("userLoginId");
+ PasswordCallback passwordCallback = new
PasswordCallback("currentPassword", false);
+ Callback[] callbacks = new Callback[]{nameCallback, passwordCallback};
+ try {
+ callbackHandler.handle(callbacks);
+ } catch (IOException e) {
+ Debug.logError(e, module);
+ throw new LoginException(e.getMessage());
+ } catch (UnsupportedCallbackException e) {
+ Debug.logError(e, module);
+ throw new LoginException(e.getMessage());
+ }
+
+ String userLoginId = nameCallback.getName();
+ String password = String.valueOf(passwordCallback.getPassword());
+ passwordCallback.clearPassword();
+ // try matching against the encrypted password
+ try {
+ GenericValue newUserLogin = delegator.findOne("UserLogin", false,
"userLoginId", userLoginId);
+ if (newUserLogin.getString("currentPassword") == null ||
newUserLogin.getString("currentPassword").equals(password)) {
+ userLogin = newUserLogin;
+ return true;
+ }
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ }
+ // plain text password
+ if (UtilValidate.isNotEmpty(password)) {
+ Map<String, Object> loginCtx = FastMap.newInstance();
+ loginCtx.put("login.username", userLoginId);
+ loginCtx.put("login.password", password);
+ try {
+ Map<String, ? extends Object> result =
dispatcher.runSync("userLogin", loginCtx);
+ if (ServiceUtil.isSuccess(result)) {
+ userLogin = (GenericValue) result.get("userLogin");
+ return true;
+ }
+ } catch (GenericServiceException e) {
+ Debug.logError(e, module);
+ throw new LoginException(e.getMessage());
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean logout() throws LoginException {
+ userLogin = null;
+ return true;
+ }
+
+}
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/OFBizLoginModule.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/RepositoryFactory.java
(from r1140127,
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/RepositoryFactory.java)
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/RepositoryFactory.java?p2=ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/RepositoryFactory.java&p1=ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/RepositoryFactory.java&r1=1140127&r2=1156196&rev=1156196&view=diff
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/RepositoryFactory.java
(original)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/RepositoryFactory.java
Wed Aug 10 14:29:40 2011
@@ -1,4 +1,4 @@
-package org.ofbiz.jcr;
+package org.ofbiz.jcr.loader;
import java.io.File;
import java.util.Hashtable;
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/RepositoryFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/RepositoryLoader.java
(from r1140127,
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/RepositoryLoader.java)
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/RepositoryLoader.java?p2=ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/RepositoryLoader.java&p1=ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/RepositoryLoader.java&r1=1140127&r2=1156196&rev=1156196&view=diff
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/RepositoryLoader.java
(original)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/RepositoryLoader.java
Wed Aug 10 14:29:40 2011
@@ -1,4 +1,4 @@
-package org.ofbiz.jcr;
+package org.ofbiz.jcr.loader;
import java.util.Map;
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/RepositoryLoader.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/jackrabbit/JCRFactoryImpl.java
(from r1140127,
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/jackrabbit/JCRFactoryImpl.java)
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/jackrabbit/JCRFactoryImpl.java?p2=ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/jackrabbit/JCRFactoryImpl.java&p1=ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/jackrabbit/JCRFactoryImpl.java&r1=1140127&r2=1156196&rev=1156196&view=diff
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/jackrabbit/JCRFactoryImpl.java
(original)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/jackrabbit/JCRFactoryImpl.java
Wed Aug 10 14:29:40 2011
@@ -16,27 +16,41 @@
* specific language governing permissions and limitations
* under the License.
*******************************************************************************/
-package org.ofbiz.jcr.jackrabbit;
+package org.ofbiz.jcr.loader.jackrabbit;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
import javax.jcr.Credentials;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
+import javax.jcr.Workspace;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeTypeManager;
import org.apache.jackrabbit.core.TransientRepository;
+import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
+import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
+import org.apache.jackrabbit.core.nodetype.xml.NodeTypeReader;
+import org.apache.jackrabbit.ocm.nodemanagement.impl.RepositoryUtil;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
-import org.ofbiz.jcr.JCRFactory;
+import org.ofbiz.jcr.loader.JCRFactory;
import org.w3c.dom.Element;
public class JCRFactoryImpl implements JCRFactory {
public static final String module = JCRFactoryImpl.class.getName();
+ private static String CUSTOM_NODE_TYPES =
"framework/jcr/config/custom-jackrabbit-nodetypes.xml";
+
private static String homeDir = null;
private static String jackrabbitConfigFile = null;
private static String CREDENTIALS_USERNAME = null;
@@ -67,7 +81,8 @@ public class JCRFactoryImpl implements J
*/
@Override
public void start() throws RepositoryException {
- // Transient repositories closes automatically when the last session
is closed
+ // Transient repositories closes automatically when the last session is
+ // closed
repository = new TransientRepository(jackrabbitConfigFile, homeDir);
createSession();
}
@@ -102,6 +117,17 @@ public class JCRFactoryImpl implements J
Credentials credentials = new
SimpleCredentials(CREDENTIALS_USERNAME, CREDENTIALS_PASSWORD);
try {
session = repository.login(credentials);
+ // register NameSpaces
+ RepositoryUtil.setupSession(session);
+ try {
+ // register the cool new noteTypes
+ registerNodeTypes(session);
+ } catch (InvalidNodeTypeDefException e) {
+ Debug.logError(e, module);
+ } catch (IOException e) {
+ Debug.logError(e, module);
+ }
+
} catch (RepositoryException e) {
Debug.logError(e, "Could not login to the workspace");
throw e;
@@ -130,4 +156,31 @@ public class JCRFactoryImpl implements J
public Repository getRepository() {
return repository;
}
+
+ /*
+ * Register some new node types
+ */
+ protected void registerNodeTypes(Session session) throws
InvalidNodeTypeDefException, javax.jcr.RepositoryException, IOException {
+ InputStream xml = new FileInputStream(CUSTOM_NODE_TYPES);
+
+ // HINT: throws InvalidNodeTypeDefException, IOException
+ QNodeTypeDefinition[] types = NodeTypeReader.read(xml);
+
+ Workspace workspace = session.getWorkspace();
+ NodeTypeManager ntMgr = workspace.getNodeTypeManager();
+ NodeTypeRegistry ntReg = ((NodeTypeManagerImpl)
ntMgr).getNodeTypeRegistry();
+
+ for (int j = 0; j < types.length; j++) {
+ QNodeTypeDefinition def = types[j];
+
+ try {
+ ntReg.getNodeTypeDef(def.getName());
+ } catch (NoSuchNodeTypeException nsne) {
+ // HINT: if not already registered than register custom node
+ // type
+ ntReg.registerNodeType(def);
+ }
+
+ }
+ }
}
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/jackrabbit/JCRFactoryImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/OfbizRepositoryMapping.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/OfbizRepositoryMapping.java?rev=1156196&r1=1156195&r2=1156196&view=diff
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/OfbizRepositoryMapping.java
(original)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/OfbizRepositoryMapping.java
Wed Aug 10 14:29:40 2011
@@ -1,244 +1,16 @@
package org.ofbiz.jcr.orm;
-import java.io.InputStream;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.version.Version;
-
-import net.sf.json.JSONArray;
-
-import org.ofbiz.entity.Delegator;
-import org.ofbiz.entity.GenericEntityException;
-import org.ofbiz.entity.GenericValue;
public interface OfbizRepositoryMapping {
-
- /**
- * Object delegator reference
- */
- public Delegator getDelegator();
-
- /**
- * Close the current repository session should be used when the operation
- * with this object are finished.
- */
- public void closeSession();
-
- /**
- * Updates only the node text property data
- *
- * @param message
- * @return
- * @throws RepositoryException
- * @throws GenericEntityException
- */
- public Version updateOrStoreTextData(String message) throws
RepositoryException, GenericEntityException;
-
- /**
- * Updates only the node text property data
- *
- * @param message
- * @param language
- * @return
- * @throws RepositoryException
- * @throws GenericEntityException
- */
- public Version updateOrStoreTextData(String message, String language)
throws RepositoryException, GenericEntityException;
-
- /**
- * Returns the related Content Object
- *
- * @return
- */
- public GenericValue getContentObject();
-
- /**
- * Returns the related Repository Node
- *
- * @return
- */
- public Node getNode();
-
- /**
- * Return the property of the current node. Return null if the property not
- * exists or an exception is raised.
- *
- * @param propertyName
- * @return
- */
- public Property getNodeProperty(String propertyName);
-
- /**
- * Returns the contentId from the related content object. If the content
- * object is null, an empty string will be retunred.
- *
- * @return
- */
- public String getContentId();
-
- /**
- * Returns the absolute path of the node.
- *
- * @return
- */
- public String getNodePath();
-
- /**
- * Returns the name of the node.
- *
- * @return
- */
- public String getNodeName();
-
- /**
- * Remove a repository Node and the related database entry.
- *
- * @throws RepositoryException
- * @throws GenericEntityException
- */
- public void removeRepositoryNode() throws RepositoryException,
GenericEntityException;
-
- /**
- * Returns only the String Content of a node, if none exists an empty
String
- * will be returned.
- *
- * @return
- * @throws PathNotFoundException
- * @throws RepositoryException
- */
- public String getStringContent() throws PathNotFoundException,
RepositoryException;
-
/**
- * Returns only the String Content of a node, if none exists an empty
String
- * will be returned.
- *
- * @param language
+ * Return the Node Path.
* @return
- * @throws PathNotFoundException
- * @throws RepositoryException
*/
- public String getStringContent(String language) throws
PathNotFoundException, RepositoryException;
+ String getPath();
/**
- * Returns the text content in a defined language and a defined version
- *
- * @param language
- * @param version
- * @return
- * @throws PathNotFoundException
- * @throws RepositoryException
+ * Set the Node Path.
+ * @param path
*/
- public String getStringContent(String language, String version) throws
PathNotFoundException, RepositoryException;
-
- /**
- * Upload and store a file in the repository
- *
- * @param description
- * @param file
- * @return
- * @throws PathNotFoundException
- * @throws RepositoryException
- * @throws GenericEntityException
- */
- public void uploadFileData(InputStream file, String fileName) throws
PathNotFoundException, RepositoryException, GenericEntityException;
-
- /**
- * Upload and store a file in the repository und a givven language.
- *
- * @param file
- * @param fileName
- * @param language
- * @param description
- * @throws PathNotFoundException
- * @throws RepositoryException
- * @throws GenericEntityException
- */
- void uploadFileData(InputStream file, String fileName, String language,
String description) throws PathNotFoundException, RepositoryException,
GenericEntityException;
-
- /**
- * Return the file stream from the current node object.
- *
- * @param fileName
- * @return
- * @throws RepositoryException
- */
- public InputStream getFileContent(String fileName) throws
RepositoryException;
-
- /**
- * Returns the content type of the file. An empty String will be returned
if
- * the node is not a file node or no mimeType exists.
- *
- * @return
- * @throws RepositoryException
- */
- public String getFileMimeType() throws RepositoryException;
-
- /**
- * Returns the repository file tree as Json Object.
- *
- * @return
- * @throws RepositoryException
- */
- public JSONArray getJsonFileTree() throws RepositoryException;
-
- /**
- * Returns the repository data (including all text content data) tree as
- * Json Object.
- *
- * @return
- * @throws RepositoryException
- */
- public JSONArray getJsonDataTree() throws RepositoryException;
-
- /**
- * Get the file stream from the current node.
- *
- * @return
- * @throws RepositoryException
- */
- public InputStream getFileContent() throws RepositoryException;
-
- /**
- * Returns a List of available languages of the current node content
- *
- * @return
- * @throws PathNotFoundException
- * @throws RepositoryException
- */
- public List<String> getAvailableLanguages() throws PathNotFoundException,
RepositoryException;
-
- /**
- * Get the current selected content language.
- *
- * @return
- */
- public String getSelctedLanguage();
-
- /**
- * Returns the current version of the node. If '0' is returned the node is
- * not versinoed.
- *
- * @return
- */
- public String getCurrentBaseVersion();
-
- /**
- * Get the current version of the node. Returns the version of the
- * currentliy selected language.
- *
- * @return
- */
- public String getCurrentLanguageVersion();
-
- /**
- * Returns a list of all versions to the current selected version.
- *
- * @return
- */
- public List<String> getAllLanguageVersions();
-
+ void setPath(String path);
}
\ No newline at end of file
Added:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFile.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFile.java?rev=1156196&view=auto
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFile.java
(added)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFile.java
Wed Aug 10 14:29:40 2011
@@ -0,0 +1,34 @@
+package org.ofbiz.jcr.orm.jackrabbit;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Bean;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+import org.ofbiz.jcr.access.jackrabbit.ConstantsJackrabbit;
+
+@Node(jcrType = "nt:file", extend =
OfbizRepositoryMappingJackrabbitHierarchyNode.class)
+public class OfbizRepositoryMappingJackrabbitFile extends
OfbizRepositoryMappingJackrabbitHierarchyNode {
+
+ @Bean(jcrName = "jcr:content")
+ private OfbizRepositoryMappingJackrabbitResource resource;
+
+ public OfbizRepositoryMappingJackrabbitResource getResource() {
+ return resource;
+ }
+
+ public void setResource(OfbizRepositoryMappingJackrabbitResource resource)
{
+ this.resource = resource;
+ }
+
+ public void setPath(String nodePath) {
+ // check that the path don't end with a /
+ if (nodePath.endsWith(ConstantsJackrabbit.ROOTPATH)) {
+ nodePath = nodePath.substring(0, nodePath.indexOf("/"));
+ }
+
+ // check that it is a relative path
+ if (nodePath.indexOf("/") != -1) {
+ nodePath = nodePath.substring(nodePath.indexOf("/") + 1);
+ }
+
+ super.path = nodePath;
+ }
+}
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFile.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFolder.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFolder.java?rev=1156196&view=auto
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFolder.java
(added)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFolder.java
Wed Aug 10 14:29:40 2011
@@ -0,0 +1,30 @@
+package org.ofbiz.jcr.orm.jackrabbit;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import
org.apache.jackrabbit.ocm.manager.collectionconverter.impl.NTCollectionConverterImpl;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Collection;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+@Node(jcrType = "nt:folder", extend =
OfbizRepositoryMappingJackrabbitHierarchyNode.class)
+public class OfbizRepositoryMappingJackrabbitFolder extends
OfbizRepositoryMappingJackrabbitHierarchyNode {
+ @Collection(autoUpdate = false, elementClassName =
OfbizRepositoryMappingJackrabbitHierarchyNode.class, collectionConverter =
NTCollectionConverterImpl.class)
+ private List<OfbizRepositoryMappingJackrabbitHierarchyNode> children;
+
+ public List<OfbizRepositoryMappingJackrabbitHierarchyNode> getChildren() {
+ return children;
+ }
+
+ public void
setChildren(List<OfbizRepositoryMappingJackrabbitHierarchyNode> children) {
+ this.children = children;
+ }
+
+ public void addChild(OfbizRepositoryMappingJackrabbitHierarchyNode node) {
+ if (children == null) {
+ children = new
ArrayList<OfbizRepositoryMappingJackrabbitHierarchyNode>();
+ }
+ children.add(node);
+ }
+
+}
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFolder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitHierarchyNode.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitHierarchyNode.java?rev=1156196&view=auto
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitHierarchyNode.java
(added)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitHierarchyNode.java
Wed Aug 10 14:29:40 2011
@@ -0,0 +1,37 @@
+package org.ofbiz.jcr.orm.jackrabbit;
+
+import java.util.Calendar;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+import org.ofbiz.jcr.access.jackrabbit.ConstantsJackrabbit;
+import org.ofbiz.jcr.orm.OfbizRepositoryMapping;
+
+@Node(jcrType = "nt:hierarchyNode")
+public class OfbizRepositoryMappingJackrabbitHierarchyNode implements
OfbizRepositoryMapping {
+ @Field(path = true, id = true, jcrProtected = true)
+ protected String path;
+ @Field(jcrName = "jcr:created")
+ private Calendar creationDate;
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String nodePath) {
+ // check if the node path is an absolute path
+ if (!nodePath.startsWith(ConstantsJackrabbit.ROOTPATH)) {
+ nodePath = ConstantsJackrabbit.ROOTPATH + nodePath;
+ }
+
+ this.path = nodePath;
+ }
+
+ public Calendar getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Calendar creationDate) {
+ this.creationDate = creationDate;
+ }
+}
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitHierarchyNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitNews.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitNews.java?rev=1156196&view=auto
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitNews.java
(added)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitNews.java
Wed Aug 10 14:29:40 2011
@@ -0,0 +1,51 @@
+package org.ofbiz.jcr.orm.jackrabbit;
+
+import java.util.Calendar;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+@Node(extend = OfbizRepositoryMappingJackrabbitUnstructured.class)
+public class OfbizRepositoryMappingJackrabbitNews extends
OfbizRepositoryMappingJackrabbitUnstructured {
+
+ @Field(id = true) String title = null;
+ @Field(jcrType = "Date") Calendar pubDate = null;
+ @Field String content = null;
+
+ public OfbizRepositoryMappingJackrabbitNews() {
+ super();
+ // create an empty object
+ }
+
+ public OfbizRepositoryMappingJackrabbitNews(String nodePath, String
language, String title, Calendar pubDate, String content) {
+ super(nodePath, language);
+ this.title = title;
+ this.pubDate = pubDate;
+ this.content = content;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public Calendar getPubDate() {
+ return pubDate;
+ }
+
+ public void setPubDate(Calendar pubDate) {
+ this.pubDate = pubDate;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+}
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitNews.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitResource.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitResource.java?rev=1156196&view=auto
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitResource.java
(added)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitResource.java
Wed Aug 10 14:29:40 2011
@@ -0,0 +1,43 @@
+package org.ofbiz.jcr.orm.jackrabbit;
+
+import java.io.InputStream;
+import java.util.Calendar;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+@Node(jcrType = "nt:resource")
+public class OfbizRepositoryMappingJackrabbitResource {
+
+ @Field(jcrName = "jcr:mimeType")
+ private String mimeType;
+ @Field(jcrName = "jcr:data")
+ private InputStream data;
+ @Field(jcrName = "jcr:lastModified")
+ private Calendar lastModified;
+
+ public InputStream getData() {
+ return data;
+ }
+
+ public void setData(InputStream data) {
+ this.data = data;
+ }
+
+ public Calendar getLastModified() {
+ return lastModified;
+ }
+
+ public void setLastModified(Calendar lastModified) {
+ this.lastModified = lastModified;
+ }
+
+ public String getMimeType() {
+ return mimeType;
+ }
+
+ public void setMimeType(String mimeType) {
+ this.mimeType = mimeType;
+ }
+
+}
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitUnstructured.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitUnstructured.java?rev=1156196&view=auto
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitUnstructured.java
(added)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitUnstructured.java
Wed Aug 10 14:29:40 2011
@@ -0,0 +1,76 @@
+package org.ofbiz.jcr.orm.jackrabbit;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.jcr.access.jackrabbit.ConstantsJackrabbit;
+import org.ofbiz.jcr.orm.OfbizRepositoryMapping;
+
+@Node(isAbstract = true)
+public abstract class OfbizRepositoryMappingJackrabbitUnstructured implements
OfbizRepositoryMapping {
+
+ protected static String module =
OfbizRepositoryMappingJackrabbitUnstructured.class.getName();
+
+ @Field(path = true)
+ private String path;
+ @Field
+ private String language;
+ @Field
+ private String version;
+ @Field(jcrName = "jcr:created")
+ private Calendar creationDate;
+
+ protected OfbizRepositoryMappingJackrabbitUnstructured() {
+ // create an empty object
+ }
+
+ protected OfbizRepositoryMappingJackrabbitUnstructured(String nodePath,
String language) {
+ this.setPath(nodePath);
+ this.creationDate = new GregorianCalendar();
+ if (UtilValidate.isEmpty(language)) {
+ language = UtilProperties.getPropertyValue("general",
"locale.properties.fallback");
+ }
+ this.language = language;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public Calendar getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Calendar creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public void setPath(String nodePath) {
+ // check if the node path is an absolute path
+ if (!nodePath.startsWith(ConstantsJackrabbit.ROOTPATH)) {
+ nodePath = ConstantsJackrabbit.ROOTPATH + nodePath;
+ }
+
+ this.path = nodePath;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+}
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitUnstructured.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/JcrUtil.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/JcrUtil.java?rev=1156196&view=auto
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/JcrUtil.java
(added)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/JcrUtil.java
Wed Aug 10 14:29:40 2011
@@ -0,0 +1,5 @@
+package org.ofbiz.jcr.util;
+
+public interface JcrUtil {
+
+}
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/JcrUtil.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/jackrabbit/JcrUtilJackrabbit.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/jackrabbit/JcrUtilJackrabbit.java?rev=1156196&view=auto
==============================================================================
---
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/jackrabbit/JcrUtilJackrabbit.java
(added)
+++
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/jackrabbit/JcrUtilJackrabbit.java
Wed Aug 10 14:29:40 2011
@@ -0,0 +1,89 @@
+package org.ofbiz.jcr.util.jackrabbit;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import javolution.util.FastList;
+import javolution.util.FastMap;
+
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.jcr.loader.JCRFactoryUtil;
+import org.ofbiz.jcr.util.JcrUtil;
+
+public class JcrUtilJackrabbit implements JcrUtil {
+
+ public static final String module = JcrUtilJackrabbit.class.getName();
+
+ /**
+ * Just a dummy method to list all nodes in the repository.
+ *
+ * @param startNodePath
+ * @return
+ * @throws RepositoryException
+ */
+ public static List<Map<String, String>> getRepositoryNodes(GenericValue
userLogin, String startNodePath) throws RepositoryException {
+ List<Map<String, String>> returnList = null;
+ Session session = JCRFactoryUtil.getSession();
+
+ try {
+ returnList = getRepositoryNodes(session, startNodePath);
+ } catch (RepositoryException e) {
+ throw new RepositoryException(e);
+ } finally {
+ session.logout();
+ }
+
+ return returnList;
+ }
+
+ /**
+ * Just a dummy method to list all nodes in the repository.
+ *
+ * @param startNodePath
+ * @return
+ * @throws RepositoryException
+ */
+ private static List<Map<String, String>> getRepositoryNodes(Session
session, String startNodePath) throws RepositoryException {
+ Node node = null;
+
+ List<Map<String, String>> nodeList = FastList.newInstance();
+ if (UtilValidate.isEmpty(startNodePath)) {
+ node = session.getRootNode();
+ } else {
+ node = session.getNode(startNodePath);
+ }
+
+ NodeIterator nodeIterator = node.getNodes();
+ Map<String, String> nodeEntry = null;
+ while (nodeIterator.hasNext()) {
+ Node n = nodeIterator.nextNode();
+
+ // recursion - get all subnodes and add the results to our nodeList
+ if (n.getNodes().hasNext()) {
+ nodeList.addAll(getRepositoryNodes(session, n.getPath()));
+ }
+
+ nodeEntry = FastMap.newInstance();
+
+ // if the node path is a jcr:system node than ignore this
+ // entry
+ if (n.getPath().startsWith("/jcr:system")) {
+ continue;
+ }
+
+ nodeEntry.put("path", n.getPath());
+
+ nodeEntry.put("primaryNodeType", n.getPrimaryNodeType().getName());
+
+ nodeList.add(nodeEntry);
+ }
+
+ return nodeList;
+ }
+}
Propchange:
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/jackrabbit/JcrUtilJackrabbit.java
------------------------------------------------------------------------------
svn:mime-type = text/plain