You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2010/06/30 10:35:17 UTC

svn commit: r959231 - in /incubator/chemistry/opencmis-browser-binding/trunk: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/chemistry/ src/main/java/org/apache/chemistry/opencmis/ src/main/java/o...

Author: fmui
Date: Wed Jun 30 08:35:16 2010
New Revision: 959231

URL: http://svn.apache.org/viewvc?rev=959231&view=rev
Log:
initial OpenCMIS Browser Binding sandbox code

Added:
    incubator/chemistry/opencmis-browser-binding/trunk/
    incubator/chemistry/opencmis-browser-binding/trunk/pom.xml   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisApplication.java   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisJaxbContextResolver.java   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisResource.java   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryInfoList.java   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/WEB-INF/
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/WEB-INF/web.xml   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.jsp   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.jsp   (with props)

Added: incubator/chemistry/opencmis-browser-binding/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/pom.xml?rev=959231&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/pom.xml (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/pom.xml Wed Jun 30 08:35:16 2010
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+    <!--
+        Licensed 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.
+    -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache</groupId>
+        <artifactId>apache</artifactId>
+        <version>7</version>
+    </parent>
+
+    <groupId>org.apache.chemistry.opencmis</groupId>
+    <version>0.1.0-incubating-SNAPSHOT</version>
+    <artifactId>chemistry-opencmis-binding-browser</artifactId>
+    <name>OpenCMIS Browser Binding</name>
+    <packaging>war</packaging>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compile.source>1.5</maven.compile.source>
+        <maven.compile.target>1.5</maven.compile.target>
+        <docs.start.url>http://incubator.apache.org/chemistry/index.html</docs.start.url>
+        <docs.download.directory>${project.build.directory}/site</docs.download.directory>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <configuration>
+                    <overlays>
+                        <overlay>
+                        </overlay>
+                        <overlay>
+                            <groupId>org.apache.chemistry.opencmis</groupId>
+                            <artifactId>chemistry-opencmis-server-inmemory</artifactId>
+                        </overlay>
+                    </overlays>
+                </configuration>
+            </plugin>
+            <plugin>
+                <inherited>true</inherited>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <target>${maven.compile.target}</target>
+                    <source>${maven.compile.source}</source>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-eclipse-plugin</artifactId>
+                <configuration>
+                    <downloadSources>true</downloadSources>
+                    <downloadJavadocs>true</downloadJavadocs>
+                    <workspace>..</workspace>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.chemistry.opencmis</groupId>
+            <artifactId>chemistry-opencmis-server-inmemory</artifactId>
+            <version>0.2.0-incubating-SNAPSHOT</version>
+            <type>war</type>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.chemistry.opencmis</groupId>
+            <artifactId>chemistry-opencmis-server-bindings</artifactId>
+            <version>0.2.0-incubating-SNAPSHOT</version>
+            <classifier>classes</classifier> 
+        </dependency>
+        <dependency>
+            <groupId>org.apache.chemistry.opencmis</groupId>
+            <artifactId>chemistry-opencmis-commons-api</artifactId>
+            <version>0.2.0-incubating-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.chemistry.opencmis</groupId>
+            <artifactId>chemistry-opencmis-commons-impl</artifactId>
+            <version>0.2.0-incubating-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+             <groupId>com.sun.jersey</groupId>
+             <artifactId>jersey-server</artifactId>
+             <version>1.3</version>
+        </dependency>
+        <dependency>
+             <groupId>com.sun.jersey</groupId>
+             <artifactId>jersey-json</artifactId>
+             <version>1.3</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.grizzly</groupId>
+            <artifactId>grizzly-servlet-webserver</artifactId>
+            <version>1.9.18-i</version>
+        </dependency>
+    </dependencies>
+
+    <repositories>
+        <repository>
+            <id>maven-repository.dev.java.net</id>
+            <name>Java.net Repository for Maven 1</name>
+            <url>http://download.java.net/maven/1/</url>
+            <layout>legacy</layout>
+        </repository>
+        <repository>
+            <id>maven2-repository.dev.java.net</id>
+            <name>Java.net Repository for Maven 2</name>
+            <url>http://download.java.net/maven/2/</url>
+        </repository>
+    </repositories>
+
+</project>

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisApplication.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisApplication.java?rev=959231&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisApplication.java (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisApplication.java Wed Jun 30 08:35:16 2010
@@ -0,0 +1,33 @@
+/*
+ * 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.apache.chemistry.opencmis.server.impl.browser;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public class CmisApplication extends Application {
+
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> s = new HashSet<Class<?>>();
+        s.add(CmisResource.class);
+        return s;
+    }
+}

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisJaxbContextResolver.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisJaxbContextResolver.java?rev=959231&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisJaxbContextResolver.java (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisJaxbContextResolver.java Wed Jun 30 08:35:16 2010
@@ -0,0 +1,76 @@
+/*
+ * 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.apache.chemistry.opencmis.server.impl.browser;
+
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+import org.apache.chemistry.opencmis.commons.impl.JaxBHelper.CMISExtraObjectFactory;
+import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectInFolderListType;
+import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionListType;
+import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionType;
+import org.apache.chemistry.opencmis.commons.impl.jaxb.ObjectFactory;
+
+import com.sun.jersey.api.json.JSONConfiguration;
+import com.sun.jersey.api.json.JSONJAXBContext;
+
+@Provider
+public class CmisJaxbContextResolver implements ContextResolver<JAXBContext> {
+
+    public static final CMISJSONObjectFactory CMIS_JSON_OBJECT_FACTORY = new CMISJSONObjectFactory();
+
+    private JAXBContext context;
+    private Class<?>[] objectFactories = { ObjectFactory.class, CMISExtraObjectFactory.class,
+            CMISJSONObjectFactory.class };
+
+    public CmisJaxbContextResolver() throws Exception {
+        this.context = new JSONJAXBContext(JSONConfiguration.natural().rootUnwrapping(true).humanReadableFormatting(
+                true).build(), objectFactories);
+    }
+
+    public JAXBContext getContext(Class<?> objectType) {
+        return context;
+    }
+
+    @XmlRegistry
+    public static class CMISJSONObjectFactory {
+        @XmlElementDecl(name = "typeDefintion")
+        public JAXBElement<CmisTypeDefinitionType> createTypeDefintion(CmisTypeDefinitionType value) {
+            return new JAXBElement<CmisTypeDefinitionType>(new QName("typeDefintion"), CmisTypeDefinitionType.class,
+                    value);
+        }
+
+        @XmlElementDecl(name = "typeDefintionList")
+        public JAXBElement<CmisTypeDefinitionListType> createTypeDefintionList(CmisTypeDefinitionListType value) {
+            return new JAXBElement<CmisTypeDefinitionListType>(new QName("typeDefintionList"),
+                    CmisTypeDefinitionListType.class, value);
+        }
+
+        @XmlElementDecl(name = "objectInFolderList")
+        public JAXBElement<CmisObjectInFolderListType> createObjectInFolderList(CmisObjectInFolderListType value) {
+            return new JAXBElement<CmisObjectInFolderListType>(new QName("objectInFolderList"),
+                    CmisObjectInFolderListType.class, value);
+        }
+    }
+}

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisJaxbContextResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisResource.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisResource.java?rev=959231&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisResource.java (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisResource.java Wed Jun 30 08:35:16 2010
@@ -0,0 +1,257 @@
+/*
+ * 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.apache.chemistry.opencmis.server.impl.browser;
+
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.impl.Converter;
+import org.apache.chemistry.opencmis.commons.impl.JaxBHelper;
+import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectInFolderListType;
+import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectType;
+import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisRepositoryInfoType;
+import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionListType;
+import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionType;
+import org.apache.chemistry.opencmis.commons.impl.server.AbstractServiceFactory;
+import org.apache.chemistry.opencmis.commons.server.CallContext;
+import org.apache.chemistry.opencmis.commons.server.CmisService;
+import org.apache.chemistry.opencmis.server.impl.CallContextImpl;
+import org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener;
+import org.apache.chemistry.opencmis.server.impl.atompub.BasicAuthCallContextHandler;
+import org.apache.chemistry.opencmis.server.impl.atompub.CallContextHandler;
+
+@Path("/")
+public class CmisResource {
+
+    public static final String BINDING_BROWSER = "browser";
+
+    @Context
+    private ServletContext servletContext;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
+    private CallContextHandler callContextHandler;
+
+    public CmisResource() throws Exception {
+        callContextHandler = new BasicAuthCallContextHandler();
+    }
+
+    @GET
+    @Path("/repositories")
+    @Produces(MediaType.APPLICATION_JSON)
+    public JAXBElement<RepositoryInfoList> getRepositories() {
+        CmisService service = null;
+
+        try {
+            service = getService(null);
+
+            RepositoryInfoList result = new RepositoryInfoList();
+
+            for (RepositoryInfo ri : service.getRepositoryInfos(null)) {
+                result.getRepositoryInfos().add(Converter.convert(ri));
+            }
+
+            return new JAXBElement<RepositoryInfoList>(new QName("repositoryInfoList"), RepositoryInfoList.class,
+                    result);
+        } finally {
+            if (service != null) {
+                service.close();
+            }
+        }
+    }
+
+    @GET
+    @Path("/repository/{repositoryId}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public JAXBElement<CmisRepositoryInfoType> getRepository(@PathParam("repositoryId") String repositoryId) {
+        CmisService service = null;
+
+        try {
+            service = getService(repositoryId);
+
+            RepositoryInfo ri = service.getRepositoryInfo(repositoryId, null);
+
+            return JaxBHelper.CMIS_EXTRA_OBJECT_FACTORY.createRepositoryInfo(Converter.convert(ri));
+        } finally {
+            if (service != null) {
+                service.close();
+            }
+        }
+    }
+
+    @GET
+    @Path("/type/{repositoryId}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public JAXBElement<CmisTypeDefinitionType> getTypeDefintion(@PathParam("repositoryId") String repositoryId,
+            @QueryParam("id") String typeId) {
+        CmisService service = null;
+
+        try {
+            service = getService(repositoryId);
+
+            TypeDefinition typeDef = service.getTypeDefinition(repositoryId, typeId, null);
+
+            return CmisJaxbContextResolver.CMIS_JSON_OBJECT_FACTORY.createTypeDefintion(Converter.convert(typeDef));
+        } finally {
+            if (service != null) {
+                service.close();
+            }
+        }
+    }
+
+    @GET
+    @Path("/types/{repositoryId}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public JAXBElement<CmisTypeDefinitionListType> getTypeDefintionChildren(
+            @PathParam("repositoryId") String repositoryId, @QueryParam("id") String typeId) {
+        CmisService service = null;
+
+        try {
+            service = getService(repositoryId);
+
+            TypeDefinitionList typeDefs = service.getTypeChildren(repositoryId, typeId, true, null, null, null);
+
+            return CmisJaxbContextResolver.CMIS_JSON_OBJECT_FACTORY
+                    .createTypeDefintionList(Converter.convert(typeDefs));
+        } finally {
+            if (service != null) {
+                service.close();
+            }
+        }
+    }
+
+    @GET
+    @Path("/object/{repositoryId}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public JAXBElement<CmisObjectType> getObject(@PathParam("repositoryId") String repositoryId,
+            @QueryParam("id") String objectId) {
+        CmisService service = null;
+
+        try {
+            service = getService(repositoryId);
+
+            ObjectData object = service.getObject(repositoryId, objectId, null, true, IncludeRelationships.NONE, null,
+                    false, false, null);
+
+            return JaxBHelper.CMIS_EXTRA_OBJECT_FACTORY.createObject(Converter.convert(object));
+        } finally {
+            if (service != null) {
+                service.close();
+            }
+        }
+    }
+
+    @GET
+    @Path("/content/{repositoryId}")
+    @Produces("*/*")
+    public Response getContent(@PathParam("repositoryId") String repositoryId, @QueryParam("id") String objectId) {
+        CmisService service = null;
+
+        try {
+            service = getService(repositoryId);
+
+            ContentStream stream = service.getContentStream(repositoryId, objectId, null, null, null, null);
+
+            return Response.ok(stream.getStream()).type(stream.getMimeType()).build();
+        } finally {
+            if (service != null) {
+                service.close();
+            }
+        }
+    }
+
+    @GET
+    @Path("/folder/{repositoryId}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public JAXBElement<CmisObjectInFolderListType> getChildren(@PathParam("repositoryId") String repositoryId,
+            @QueryParam("id") String folderId) {
+        CmisService service = null;
+
+        try {
+            service = getService(repositoryId);
+
+            ObjectInFolderList children = service.getChildren(repositoryId, folderId, null, null, true,
+                    IncludeRelationships.NONE, null, true, null, null, null);
+
+            return CmisJaxbContextResolver.CMIS_JSON_OBJECT_FACTORY.createObjectInFolderList(Converter
+                    .convert(children));
+        } finally {
+            if (service != null) {
+                service.close();
+            }
+        }
+    }
+
+    // --------------------------------------------------------
+
+    protected CmisService getService(String repositoryId) {
+        CmisService service = null;
+        try {
+            // get services factory
+            AbstractServiceFactory factory = (AbstractServiceFactory) servletContext
+                    .getAttribute(CmisRepositoryContextListener.SERVICES_FACTORY);
+
+            // get the service
+            service = factory.getService(createContext(repositoryId));
+        } catch (Exception e) {
+            if (service != null) {
+                service.close();
+                service = null;
+            }
+        }
+
+        return service;
+    }
+
+    protected CallContext createContext(String repositoryId) {
+        CallContextImpl context = new CallContextImpl(BINDING_BROWSER, repositoryId, false);
+
+        // call call context handler
+        if (callContextHandler != null) {
+            Map<String, String> callContextMap = callContextHandler.getCallContextMap(servletRequest);
+            if (callContextMap != null) {
+                for (Map.Entry<String, String> e : callContextMap.entrySet()) {
+                    context.put(e.getKey(), e.getValue());
+                }
+            }
+        }
+
+        return context;
+    }
+}
\ No newline at end of file

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryInfoList.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryInfoList.java?rev=959231&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryInfoList.java (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryInfoList.java Wed Jun 30 08:35:16 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.apache.chemistry.opencmis.server.impl.browser;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisRepositoryInfoType;
+
+@XmlRootElement(name = "repositoryInfoList")
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "repositoryInfoList", propOrder = { "repositoryInfos" })
+public class RepositoryInfoList {
+
+    protected List<CmisRepositoryInfoType> repositoryInfos;
+
+    public RepositoryInfoList() {
+    }
+
+    public List<CmisRepositoryInfoType> getRepositoryInfos() {
+        if (repositoryInfos == null) {
+            repositoryInfos = new ArrayList<CmisRepositoryInfoType>();
+        }
+        return this.repositoryInfos;
+    }
+}

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryInfoList.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/WEB-INF/web.xml?rev=959231&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/WEB-INF/web.xml (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/WEB-INF/web.xml Wed Jun 30 08:35:16 2010
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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. 
+-->
+<web-app version="2.4"
+	xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+	<display-name>OpenCMIS Server</display-name>
+
+	<welcome-file-list>
+		<welcome-file>index.jsp</welcome-file>
+	</welcome-file-list>
+
+	<listener>
+		<listener-class>org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener</listener-class>
+	</listener>
+	
+	<listener>
+		<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
+	</listener>
+
+	<servlet>
+		<servlet-name>cmisws</servlet-name>
+		<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
+
+	<servlet>
+		<servlet-name>cmisatom</servlet-name>
+		<servlet-class>org.apache.chemistry.opencmis.server.impl.atompub.CmisAtomPubServlet</servlet-class>
+		<init-param>
+			<param-name>callContextHandler</param-name>
+			<param-value>org.apache.chemistry.opencmis.server.impl.atompub.BasicAuthCallContextHandler</param-value>
+		</init-param>
+		<load-on-startup>2</load-on-startup>
+	</servlet>
+
+	<servlet>
+		<servlet-name>cmisbrowser</servlet-name>
+		<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+		<init-param>
+			<param-name>javax.ws.rs.Application</param-name>
+			<param-value>org.apache.chemistry.opencmis.server.impl.browser.CmisApplication</param-value>
+		</init-param>
+	</servlet>
+
+	<servlet-mapping>
+		<servlet-name>cmisws</servlet-name>
+		<url-pattern>/services/*</url-pattern>
+	</servlet-mapping>
+
+	<servlet-mapping>
+		<servlet-name>cmisatom</servlet-name>
+		<url-pattern>/atom/*</url-pattern>
+	</servlet-mapping>
+
+	<servlet-mapping>
+		<servlet-name>cmisbrowser</servlet-name>
+		<url-pattern>/browser/*</url-pattern>
+	</servlet-mapping>
+
+	<session-config>
+		<session-timeout>60</session-timeout>
+	</session-config>
+</web-app>

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.jsp
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.jsp?rev=959231&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.jsp (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.jsp Wed Jun 30 08:35:16 2010
@@ -0,0 +1,43 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+    pageEncoding="ISO-8859-1"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<title>OpenCMIS Browser Binding Demo</title>
+<style type="text/css">
+  body {
+    font-family:Arial,sans-serif;
+  }
+  .box { 
+    border-width:1px;
+    border-style:solid; 
+    width:100%;
+  }
+</style>
+<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
+<script type="text/javascript">
+$(document).ready(function(){
+  $.getJSON('<%=request.getContextPath()%>/browser/repositories', 
+    function(data) {
+      var ri = data.repositoryInfos;
+      $('#repositoryInfo').html(
+        '<h2>Repsository ' + ri.repositoryName + ' (' + ri.repositoryId + ')</h2>' +
+        '<table>' +
+        '<tr><td>Id:</td><td>' + ri.repositoryId + '</td></tr>' +
+        '<tr><td>Name:</td><td>' + ri.repositoryName + '</td></tr>' +
+        '<tr><td>Description:</td><td>' + ri.repositoryDescription + '</td></tr>' +
+        '<tr><td>Product:</td><td>' + ri.vendorName + ' ' + ri.productName + ' ' + ri.productVersion + '</td></tr>' +
+        '<tr><td>Root folder id:</td><td>' + ri.rootFolderId + '</td></tr>' +
+        '</table>');
+   });
+});     
+</script>
+</head>
+<body>
+<h1>OpenCMIS Browser Binding - Demo</h1>
+<br/>
+<div id="repositoryInfo" class="box">
+RepositoryInfo
+</div>
+</body>
+</html>
\ No newline at end of file

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.jsp?rev=959231&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.jsp (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.jsp Wed Jun 30 08:35:16 2010
@@ -0,0 +1,38 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+    pageEncoding="ISO-8859-1"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<title>OpenCMIS Browser Binding</title>
+<style type="text/css">
+  body {
+    font-family:Arial,sans-serif;
+  }
+</style>
+</head>
+<body>
+
+<h1>OpenCMIS Browser Binding</h1>
+
+<h2>Browser Binding</h2>
+<ul>
+<li>Repository Infos: <a href="<%=request.getContextPath()%>/browser/repositories"><%=request.getContextPath()%>/browser/repositories</a></li>
+<li>Repository Info (repository id A1): <a href="<%=request.getContextPath()%>/browser/repository/A1"><%=request.getContextPath()%>/browser/repository/A1</a></li>
+<li>Object Data (object id 100 [root folder]): <a href="<%=request.getContextPath()%>/browser/object/A1?id=100"><%=request.getContextPath()%>/browser/object/A1?id=100</a></li>
+<li>Object Data (object id 133 [document in root folder]): <a href="<%=request.getContextPath()%>/browser/object/A1?id=133"><%=request.getContextPath()%>/browser/object/A1?id=133</a></li>
+<li>Content (object id 133 [document in root folder]): <a href="<%=request.getContextPath()%>/browser/content/A1?id=133"><%=request.getContextPath()%>/browser/content/A1?id=133</a></li>
+<li>Folder children (object id 100 [root folder]): <a href="<%=request.getContextPath()%>/browser/folder/A1?id=100"><%=request.getContextPath()%>/browser/folder/A1?id=100</a></li>
+<li>Type definition (cmis:document): <a href="<%=request.getContextPath()%>/browser/type/A1?id=cmis:document"><%=request.getContextPath()%>/browser/type/A1?id=cmis:document</a></li>
+<li>Type definition children (cmis:document): <a href="<%=request.getContextPath()%>/browser/types/A1?id=cmis:document"><%=request.getContextPath()%>/browser/types/A1?id=cmis:document</a></li>
+</ul>
+
+<a href="demo.jsp">Demo page</a>
+
+<h2>AtomPub binding</h2>
+<a href="<%=request.getContextPath()%>/atom">AtomPub Service Document</a>
+
+<h2>WebServices binding</h2>
+<a href="<%=request.getContextPath()%>/services/RepositoryService">Web Services Overview</a>
+
+</body>
+</html>
\ No newline at end of file

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.jsp
------------------------------------------------------------------------------
    svn:eol-style = native