jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r554866 - in /jackrabbit/trunk/contrib/spi: spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/ spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ spi2dav/src/main...
Date Tue, 10 Jul 2007 08:10:37 GMT
Author: angela
Date: Tue Jul 10 01:10:36 2007
New Revision: 554866

URL: http://svn.apache.org/viewvc?view=rev&rev=554866
Log:
JCR-1004 SPI: Add RepositoryService.getQNodeTypeDefinition >> add method implementation
to the various spi-impls

Modified:
    jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
    jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
    jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java?view=diff&rev=554866&r1=554865&r2=554866
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
Tue Jul 10 01:10:36 2007
@@ -745,7 +745,7 @@
     public Iterator getQNodeTypeDefinitions(
             SessionInfo sessionInfo) throws RepositoryException {
         try {
-            QNodeTypeDefinition[] ntDefs = remoteService.getNodeTypeDefinitions(
+            QNodeTypeDefinition[] ntDefs = remoteService.getQNodeTypeDefinitions(
                     getRemoteSessionInfo(sessionInfo));
             return Arrays.asList(ntDefs).iterator();
         } catch (RemoteException e) {
@@ -757,8 +757,11 @@
      * {@inheritDoc}
      */
     public QNodeTypeDefinition getQNodeTypeDefinition(SessionInfo sessionInfo, QName nodetypeName)
throws RepositoryException {
-        // TODO: implement me
-        throw new RuntimeException("implementation for getQNodeTypeDefinition missing");
+        try {
+            return remoteService.getQNodeTypeDefinition(getRemoteSessionInfo(sessionInfo),
nodetypeName);
+        } catch (RemoteException e) {
+            throw new RemoteRepositoryException(e);
+        }
     }
 
     //------------------------------< internal >--------------------------------

Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java?view=diff&rev=554866&r1=554865&r2=554866
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
Tue Jul 10 01:10:36 2007
@@ -669,8 +669,19 @@
      * @return
      * @throws javax.jcr.RepositoryException
      * @throws RemoteException if an error occurs.
-     * @see org.apache.jackrabbit.spi.RepositoryService#getNodeTypeDefinitions(org.apache.jackrabbit.spi.SessionInfo)
+     * @see org.apache.jackrabbit.spi.RepositoryService#getQNodeTypeDefinitions(org.apache.jackrabbit.spi.SessionInfo)
      */
-    public QNodeTypeDefinition[] getNodeTypeDefinitions(RemoteSessionInfo sessionInfo)
+    public QNodeTypeDefinition[] getQNodeTypeDefinitions(RemoteSessionInfo sessionInfo)
             throws RepositoryException, RemoteException;
+
+    /**
+     * Retrieve the <code>QNodeTypeDefinition</code> for the given node type
name.
+     *
+     * @param sessionInfo
+     * @return
+     * @throws javax.jcr.RepositoryException
+     * @throws RemoteException if an error occurs.
+     * @see org.apache.jackrabbit.spi.RepositoryService#getQNodeTypeDefinition(org.apache.jackrabbit.spi.SessionInfo,
QName)
+     */
+    public QNodeTypeDefinition getQNodeTypeDefinition(RemoteSessionInfo sessionInfo, QName
ntName) throws RepositoryException, RemoteException;
 }

Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java?view=diff&rev=554866&r1=554865&r2=554866
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
Tue Jul 10 01:10:36 2007
@@ -820,7 +820,7 @@
     /**
      * {@inheritDoc}
      */
-    public QNodeTypeDefinition[] getNodeTypeDefinitions(RemoteSessionInfo sessionInfo)
+    public QNodeTypeDefinition[] getQNodeTypeDefinitions(RemoteSessionInfo sessionInfo)
             throws RepositoryException, RemoteException {
         Iterator it = service.getQNodeTypeDefinitions(getSessionInfo(sessionInfo));
         List nts = new ArrayList();
@@ -835,6 +835,18 @@
         return (QNodeTypeDefinition[]) nts.toArray(new QNodeTypeDefinition[nts.size()]);
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public QNodeTypeDefinition getQNodeTypeDefinition(RemoteSessionInfo sessionInfo, QName
ntName)
+            throws RepositoryException, RemoteException {
+        QNodeTypeDefinition ntDef = service.getQNodeTypeDefinition(getSessionInfo(sessionInfo),
ntName);
+        if (ntDef instanceof Serializable) {
+            return ntDef;
+        } else {
+            return new QNodeTypeDefinitionImpl(ntDef);
+        }
+    }
     //---------------------------< internal >-----------------------------------
 
     /**

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?view=diff&rev=554866&r1=554865&r2=554866
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Tue Jul 10 01:10:36 2007
@@ -1852,8 +1852,40 @@
      * {@inheritDoc}
      */
     public QNodeTypeDefinition getQNodeTypeDefinition(SessionInfo sessionInfo, QName nodetypeName)
throws RepositoryException {
-        // TODO: implement me
-        throw new RuntimeException("implementation for getQNodeTypeDefinition missing");
+        ReportMethod method = null;
+        try {
+            NamespaceResolver resolver = new NamespaceResolverImpl(sessionInfo);
+
+            ReportInfo info = new ReportInfo(NodeTypesReport.NODETYPES_REPORT, DEPTH_0);
+            Element el = DomUtil.createElement(domFactory, NodeTypeConstants.XML_NODETYPE,
NodeTypeConstants.NAMESPACE);
+            String jcrName = NameFormat.format(nodetypeName, resolver);
+            DomUtil.addChildElement(el, NodeTypeConstants.XML_NODETYPENAME, NodeTypeConstants.NAMESPACE,
jcrName);
+            info.setContentElement(el);
+
+            String workspaceUri = uriResolver.getWorkspaceUri(sessionInfo.getWorkspaceName());
+            method = new ReportMethod(workspaceUri, info);
+            getClient(sessionInfo).executeMethod(method);
+            method.checkSuccess();
+
+            Document reportDoc = method.getResponseBodyAsDocument();
+            Element ntDefEl = DomUtil.getChildElement(reportDoc.getDocumentElement(), NodeTypeConstants.NODETYPE_ELEMENT,
null);
+            QNodeTypeDefinition def = new QNodeTypeDefinitionImpl(ntDefEl, resolver, getQValueFactory());
+            // refresh node type definitions map
+            synchronized (nodeTypeDefinitions) {
+                nodeTypeDefinitions.put(def.getQName(), def);
+            }
+            return def;
+        } catch (IOException e) {
+            throw new RepositoryException(e);
+        } catch (DavException e) {
+            throw ExceptionConverter.generate(e);
+        } catch (NoPrefixDeclaredException e) {
+            throw new RepositoryException(e);
+        } finally {
+            if (method != null) {
+                method.releaseConnection();
+            }
+        }
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?view=diff&rev=554866&r1=554865&r2=554866
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
Tue Jul 10 01:10:36 2007
@@ -1001,8 +1001,15 @@
      * {@inheritDoc}
      */
     public QNodeTypeDefinition getQNodeTypeDefinition(SessionInfo sessionInfo, QName nodetypeName)
throws RepositoryException {
-        // TODO: implement me
-        throw new RuntimeException("implementation for getQNodeTypeDefinition missing");
+        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
+        NodeTypeManager ntMgr = sInfo.getSession().getWorkspace().getNodeTypeManager();
+        try {
+            String ntName = NameFormat.format(nodetypeName, sInfo.getNamespaceResolver());
+            NodeType nt = ntMgr.getNodeType(ntName);
+            return new QNodeTypeDefinitionImpl(nt, sInfo.getNamespaceResolver(), getQValueFactory());
+        } catch (NameException e) {
+            throw new RepositoryException(e);
+        }
     }
 
     //----------------------------< internal >----------------------------------



Mime
View raw message