Commit 852209221492f4fb0fd85bbcde20fdcd9f07b80e

Authored by Ancuta Morarasu
0 parents
Exists in master

REPO-1442 Create opencmis-extension repository in Platform group

Showing 28 changed files with 3465 additions and 0 deletions   Show diff stats
... ... @@ -0,0 +1,176 @@
  1 +
  2 + Apache License
  3 + Version 2.0, January 2004
  4 + http://www.apache.org/licenses/
  5 +
  6 + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
  7 +
  8 + 1. Definitions.
  9 +
  10 + "License" shall mean the terms and conditions for use, reproduction,
  11 + and distribution as defined by Sections 1 through 9 of this document.
  12 +
  13 + "Licensor" shall mean the copyright owner or entity authorized by
  14 + the copyright owner that is granting the License.
  15 +
  16 + "Legal Entity" shall mean the union of the acting entity and all
  17 + other entities that control, are controlled by, or are under common
  18 + control with that entity. For the purposes of this definition,
  19 + "control" means (i) the power, direct or indirect, to cause the
  20 + direction or management of such entity, whether by contract or
  21 + otherwise, or (ii) ownership of fifty percent (50%) or more of the
  22 + outstanding shares, or (iii) beneficial ownership of such entity.
  23 +
  24 + "You" (or "Your") shall mean an individual or Legal Entity
  25 + exercising permissions granted by this License.
  26 +
  27 + "Source" form shall mean the preferred form for making modifications,
  28 + including but not limited to software source code, documentation
  29 + source, and configuration files.
  30 +
  31 + "Object" form shall mean any form resulting from mechanical
  32 + transformation or translation of a Source form, including but
  33 + not limited to compiled object code, generated documentation,
  34 + and conversions to other media types.
  35 +
  36 + "Work" shall mean the work of authorship, whether in Source or
  37 + Object form, made available under the License, as indicated by a
  38 + copyright notice that is included in or attached to the work
  39 + (an example is provided in the Appendix below).
  40 +
  41 + "Derivative Works" shall mean any work, whether in Source or Object
  42 + form, that is based on (or derived from) the Work and for which the
  43 + editorial revisions, annotations, elaborations, or other modifications
  44 + represent, as a whole, an original work of authorship. For the purposes
  45 + of this License, Derivative Works shall not include works that remain
  46 + separable from, or merely link (or bind by name) to the interfaces of,
  47 + the Work and Derivative Works thereof.
  48 +
  49 + "Contribution" shall mean any work of authorship, including
  50 + the original version of the Work and any modifications or additions
  51 + to that Work or Derivative Works thereof, that is intentionally
  52 + submitted to Licensor for inclusion in the Work by the copyright owner
  53 + or by an individual or Legal Entity authorized to submit on behalf of
  54 + the copyright owner. For the purposes of this definition, "submitted"
  55 + means any form of electronic, verbal, or written communication sent
  56 + to the Licensor or its representatives, including but not limited to
  57 + communication on electronic mailing lists, source code control systems,
  58 + and issue tracking systems that are managed by, or on behalf of, the
  59 + Licensor for the purpose of discussing and improving the Work, but
  60 + excluding communication that is conspicuously marked or otherwise
  61 + designated in writing by the copyright owner as "Not a Contribution."
  62 +
  63 + "Contributor" shall mean Licensor and any individual or Legal Entity
  64 + on behalf of whom a Contribution has been received by Licensor and
  65 + subsequently incorporated within the Work.
  66 +
  67 + 2. Grant of Copyright License. Subject to the terms and conditions of
  68 + this License, each Contributor hereby grants to You a perpetual,
  69 + worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  70 + copyright license to reproduce, prepare Derivative Works of,
  71 + publicly display, publicly perform, sublicense, and distribute the
  72 + Work and such Derivative Works in Source or Object form.
  73 +
  74 + 3. Grant of Patent License. Subject to the terms and conditions of
  75 + this License, each Contributor hereby grants to You a perpetual,
  76 + worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  77 + (except as stated in this section) patent license to make, have made,
  78 + use, offer to sell, sell, import, and otherwise transfer the Work,
  79 + where such license applies only to those patent claims licensable
  80 + by such Contributor that are necessarily infringed by their
  81 + Contribution(s) alone or by combination of their Contribution(s)
  82 + with the Work to which such Contribution(s) was submitted. If You
  83 + institute patent litigation against any entity (including a
  84 + cross-claim or counterclaim in a lawsuit) alleging that the Work
  85 + or a Contribution incorporated within the Work constitutes direct
  86 + or contributory patent infringement, then any patent licenses
  87 + granted to You under this License for that Work shall terminate
  88 + as of the date such litigation is filed.
  89 +
  90 + 4. Redistribution. You may reproduce and distribute copies of the
  91 + Work or Derivative Works thereof in any medium, with or without
  92 + modifications, and in Source or Object form, provided that You
  93 + meet the following conditions:
  94 +
  95 + (a) You must give any other recipients of the Work or
  96 + Derivative Works a copy of this License; and
  97 +
  98 + (b) You must cause any modified files to carry prominent notices
  99 + stating that You changed the files; and
  100 +
  101 + (c) You must retain, in the Source form of any Derivative Works
  102 + that You distribute, all copyright, patent, trademark, and
  103 + attribution notices from the Source form of the Work,
  104 + excluding those notices that do not pertain to any part of
  105 + the Derivative Works; and
  106 +
  107 + (d) If the Work includes a "NOTICE" text file as part of its
  108 + distribution, then any Derivative Works that You distribute must
  109 + include a readable copy of the attribution notices contained
  110 + within such NOTICE file, excluding those notices that do not
  111 + pertain to any part of the Derivative Works, in at least one
  112 + of the following places: within a NOTICE text file distributed
  113 + as part of the Derivative Works; within the Source form or
  114 + documentation, if provided along with the Derivative Works; or,
  115 + within a display generated by the Derivative Works, if and
  116 + wherever such third-party notices normally appear. The contents
  117 + of the NOTICE file are for informational purposes only and
  118 + do not modify the License. You may add Your own attribution
  119 + notices within Derivative Works that You distribute, alongside
  120 + or as an addendum to the NOTICE text from the Work, provided
  121 + that such additional attribution notices cannot be construed
  122 + as modifying the License.
  123 +
  124 + You may add Your own copyright statement to Your modifications and
  125 + may provide additional or different license terms and conditions
  126 + for use, reproduction, or distribution of Your modifications, or
  127 + for any such Derivative Works as a whole, provided Your use,
  128 + reproduction, and distribution of the Work otherwise complies with
  129 + the conditions stated in this License.
  130 +
  131 + 5. Submission of Contributions. Unless You explicitly state otherwise,
  132 + any Contribution intentionally submitted for inclusion in the Work
  133 + by You to the Licensor shall be under the terms and conditions of
  134 + this License, without any additional terms or conditions.
  135 + Notwithstanding the above, nothing herein shall supersede or modify
  136 + the terms of any separate license agreement you may have executed
  137 + with Licensor regarding such Contributions.
  138 +
  139 + 6. Trademarks. This License does not grant permission to use the trade
  140 + names, trademarks, service marks, or product names of the Licensor,
  141 + except as required for reasonable and customary use in describing the
  142 + origin of the Work and reproducing the content of the NOTICE file.
  143 +
  144 + 7. Disclaimer of Warranty. Unless required by applicable law or
  145 + agreed to in writing, Licensor provides the Work (and each
  146 + Contributor provides its Contributions) on an "AS IS" BASIS,
  147 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  148 + implied, including, without limitation, any warranties or conditions
  149 + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
  150 + PARTICULAR PURPOSE. You are solely responsible for determining the
  151 + appropriateness of using or redistributing the Work and assume any
  152 + risks associated with Your exercise of permissions under this License.
  153 +
  154 + 8. Limitation of Liability. In no event and under no legal theory,
  155 + whether in tort (including negligence), contract, or otherwise,
  156 + unless required by applicable law (such as deliberate and grossly
  157 + negligent acts) or agreed to in writing, shall any Contributor be
  158 + liable to You for damages, including any direct, indirect, special,
  159 + incidental, or consequential damages of any character arising as a
  160 + result of this License or out of the use or inability to use the
  161 + Work (including but not limited to damages for loss of goodwill,
  162 + work stoppage, computer failure or malfunction, or any and all
  163 + other commercial damages or losses), even if such Contributor
  164 + has been advised of the possibility of such damages.
  165 +
  166 + 9. Accepting Warranty or Additional Liability. While redistributing
  167 + the Work or Derivative Works thereof, You may choose to offer,
  168 + and charge a fee for, acceptance of support, warranty, indemnity,
  169 + or other liability obligations and/or rights consistent with this
  170 + License. However, in accepting such obligations, You may act only
  171 + on Your own behalf and on Your sole responsibility, not on behalf
  172 + of any other Contributor, and only if You agree to indemnify,
  173 + defend, and hold each Contributor harmless for any liability
  174 + incurred by, or claims asserted against, such Contributor by reason
  175 + of your accepting any such warranty or additional liability.
  176 +
... ...
... ... @@ -0,0 +1,140 @@
  1 +Alfresco OpenCMIS Extension
  2 +===========================
  3 +
  4 +The Alfresco OpenCMIS Extension provides easy access to Alfresco aspects and
  5 +aspect properties.
  6 +
  7 +Project page: <http://apache-extras.org/p/alfresco-opencmis-extension>
  8 +
  9 +
  10 +Using the Alfresco OpenCMIS Extension
  11 +-------------------------------------
  12 +
  13 +The Alfresco OpenCMIS Extension requires OpenCMIS 0.2 or higher.
  14 +Download it from here: <http://chemistry.apache.org/java/opencmis.html>
  15 +
  16 +Put the Alfresco OpenCMIS Extension Jar into your classpath. When setting up
  17 +an OpenCMIS session, set the object factory class to
  18 +"org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl".
  19 +
  20 +Code sample:
  21 +
  22 + Map<String, String> parameter = new HashMap<String, String>();
  23 +
  24 + // user credentials
  25 + parameter.put(SessionParameter.USER, "admin");
  26 + parameter.put(SessionParameter.PASSWORD, "admin");
  27 +
  28 + // connection settings
  29 + parameter.put(SessionParameter.ATOMPUB_URL,
  30 + "http://localhost:8080/alfresco/service/cmis");
  31 + parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
  32 +
  33 + // set the object factory
  34 + parameter.put(SessionParameter.OBJECT_FACTORY_CLASS,
  35 + "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
  36 +
  37 + // create session
  38 + SessionFactory factory = SessionFactoryImpl.newInstance();
  39 + Session session = factory.getRepositories(parameter).get(0).createSession();
  40 +
  41 +
  42 +Reading aspect properties
  43 +-------------------------
  44 +
  45 +Aspect properties automatically appear as CMIS properties.
  46 +
  47 +
  48 +Updating aspect properties
  49 +--------------------------
  50 +
  51 +An aspect property can be updated as any other CMIS property.
  52 +
  53 +
  54 +Creating documents and folders with aspects
  55 +-------------------------------------------
  56 +
  57 +Aspects can be specified at creation of a document or a folder.
  58 +
  59 +In order to create an object, the property "cmis:objectTypeId" must be set to
  60 +a valid CMIS object type id. With the Alfresco OpenCMIS Extension installed,
  61 +the OpenCMIS library also accepts a comma-separated list of type ids.
  62 +The first type id in that list MUST be the object type id. All following
  63 +type ids MUST be aspect type ids.
  64 +Aspect properties can be set for all aspects in that list.
  65 +
  66 +Code sample:
  67 +
  68 + Map<String, Object> properties = new HashMap<String, Object>();
  69 + properties.put(PropertyIds.NAME, "doc1");
  70 + properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:cm:titled");
  71 + properties.put("cm:description", "My document");
  72 +
  73 + Document doc = session.getRootFolder().createDocument(properties, null, null);
  74 +
  75 +
  76 +Adding, removing and discovering aspects
  77 +----------------------------------------
  78 +
  79 +In order to add and remove aspects, cast OpenCMIS Document objects and Folder
  80 +objects to AlfrescoDocument respectively AlfrescoFolder.
  81 +They provide the following additional methods:
  82 +
  83 + // check for applied aspects
  84 + boolean hasAspect(String id);
  85 + boolean hasAspect(ObjectType type);
  86 + Collection<ObjectType> getAspects();
  87 +
  88 + // find the aspect type for a property id
  89 + ObjectType findAspect(String propertyId);
  90 +
  91 + // add and remove aspects
  92 + void addAspect(String... id);
  93 + void addAspect(ObjectType... type);
  94 + void removeAspect(String... id);
  95 + void removeAspect(ObjectType... type);
  96 +
  97 +
  98 +Code sample:
  99 +
  100 + Document doc = (Document) session.getObject(...);
  101 +
  102 + AlfrescoDocument alfDoc = (AlfrescoDocument) doc;
  103 + alfDoc.addAspect("P:cm:taggable");
  104 +
  105 + if(alfDoc.hasAspect("P:cm:titled")) {
  106 + Map<String, Object> properties = new HashMap<String, Object>();
  107 + properties.put("cm:description", "My taggable document");
  108 + alfDoc.updateProperties(properties);
  109 + }
  110 +
  111 +
  112 +If the OpenCMIS session is connected to a repository that is not an Alfresco
  113 +repository, hasAspect() always returns false, getAspects() returns an empty
  114 +collection and addAspect() and removeAspect() calls should be ignored by the
  115 +connected repository.
  116 +
  117 +
  118 +How does it work?
  119 +-----------------
  120 +
  121 +The CMIS specification defines several extension points. Alfresco uses these
  122 +CMIS extensions to sends and accepts aspect properties. Those extensions are
  123 +available to all CMIS clients but most of them ignore extensions.
  124 +A vanilla OpenCMIS library can read and set CMIS extensions but that requires
  125 +some code and discipline.
  126 +
  127 +The Alfresco OpenCMIS Extension replaces OpenCMIS' internal object factory with
  128 +one that understands Alfresco CMIS extensions. The factory creates objects that
  129 +are aware of Alfresco aspects and provide appropriate interfaces.
  130 +
  131 +So, the Alfresco OpenCMIS Extension is only a convenience layer on top of CMIS.
  132 +
  133 +
  134 +License
  135 +-------
  136 +
  137 +Apache License, Version 2.0
  138 +Please see <http://www.apache.org/licenses/LICENSE-2.0>.
  139 +
  140 +Copyright (C) 2005-2011 Alfresco Software Limited.
... ...
... ... @@ -0,0 +1,5 @@
  1 +#Generated by Maven
  2 +#Thu Aug 14 18:07:08 BST 2014
  3 +version=1.0
  4 +groupId=org.alfresco.cmis.client
  5 +artifactId=alfresco-opencmis-extension
... ...
... ... @@ -0,0 +1,222 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +
  3 + <!--
  4 + Licensed under the Apache License, Version 2.0 (the "License");
  5 + you may not use this file except in compliance with the License.
  6 + You may obtain a copy of the License at
  7 +
  8 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by
  9 + applicable law or agreed to in writing, software distributed
  10 + under the License is distributed on an "AS IS" BASIS, WITHOUT
  11 + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 + See the License for the specific language governing permissions
  13 + and limitations under the License.
  14 + -->
  15 +
  16 +<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">
  17 +
  18 + <modelVersion>4.0.0</modelVersion>
  19 +
  20 + <groupId>org.alfresco.cmis.client</groupId>
  21 + <artifactId>alfresco-opencmis-extension</artifactId>
  22 + <name>Alfresco OpenCMIS Extension</name>
  23 + <version>1.0</version>
  24 + <packaging>jar</packaging>
  25 +
  26 + <organization>
  27 + <name>Alfresco</name>
  28 + <url>http://www.alfresco.com/</url>
  29 + </organization>
  30 +
  31 + <url>http://apache-extras.org/p/alfresco-opencmis-extension</url>
  32 + <inceptionYear>2011</inceptionYear>
  33 + <description>
  34 + The Alfresco OpenCMIS Extension is an extension of Apache Chemistry OpenCMIS.
  35 + </description>
  36 +
  37 + <repositories>
  38 + <repository>
  39 + <id>apache-snapshots</id>
  40 + <url>https://repository.apache.org/content/groups/snapshots/</url>
  41 + <releases>
  42 + <enabled>false</enabled>
  43 + </releases>
  44 + </repository>
  45 + <repository>
  46 + <id>chemistry-opencmis</id>
  47 + <url>https://repository.apache.org/content/repositories/orgapachechemistry-089</url>
  48 + </repository>
  49 + </repositories>
  50 +
  51 + <licenses>
  52 + <license>
  53 + <name>Apache 2</name>
  54 + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
  55 + <distribution>repo</distribution>
  56 + </license>
  57 + </licenses>
  58 +
  59 + <scm>
  60 + <connection>scm:svn:http://svn.codespot.com/a/apache-extras.org/alfresco-opencmis-extension/trunk</connection>
  61 + <developerConnection>scm:svn:https://svn.codespot.com/a/apache-extras.org/alfresco-opencmis-extension/trunk</developerConnection>
  62 + <url>http://svn.codespot.com/a/apache-extras.org/alfresco-opencmis-extension/trunk</url>
  63 + </scm>
  64 +
  65 + <issueManagement>
  66 + <system>Google Code</system>
  67 + <url>http://code.google.com/a/apache-extras.org/p/alfresco-opencmis-extension/issues/list</url>
  68 + </issueManagement>
  69 +
  70 + <mailingLists>
  71 + <mailingList>
  72 + <name>User Mailing List</name>
  73 + <archive>http://groups.google.com/group/alfresco-opencmis-extension</archive>
  74 + </mailingList>
  75 + <mailingList>
  76 + <name>Commit Mailing List</name>
  77 + <archive>http://groups.google.com/group/alfresco-opencmis-extension-commits</archive>
  78 + </mailingList>
  79 + </mailingLists>
  80 +
  81 + <distributionManagement>
  82 + <repository>
  83 + <id>maven.alfresco.com</id>
  84 + <name>Alfresco Maven Repository</name>
  85 + <url>http://maven.alfresco.com/nexus/content/repositories/releases</url>
  86 + </repository>
  87 + </distributionManagement>
  88 +
  89 + <properties>
  90 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  91 + <maven.compile.source>1.5</maven.compile.source>
  92 + <maven.compile.target>1.5</maven.compile.target>
  93 + </properties>
  94 +
  95 + <build>
  96 + <resources>
  97 + <resource>
  98 + <directory>${basedir}</directory>
  99 + <includes>
  100 + <include>README</include>
  101 + <include>LICENSE</include>
  102 + </includes>
  103 + <targetPath>META-INF</targetPath>
  104 + </resource>
  105 + </resources>
  106 +
  107 + <plugins>
  108 + <plugin>
  109 + <artifactId>maven-compiler-plugin</artifactId>
  110 + <configuration>
  111 + <target>${maven.compile.target}</target>
  112 + <source>${maven.compile.source}</source>
  113 + <encoding>UTF-8</encoding>
  114 + </configuration>
  115 + </plugin>
  116 + <plugin>
  117 + <artifactId>maven-assembly-plugin</artifactId>
  118 + <executions>
  119 + <execution>
  120 + <id>pack</id>
  121 + <goals>
  122 + <goal>single</goal>
  123 + </goals>
  124 + <phase>package</phase>
  125 + <configuration>
  126 + <attach>true</attach>
  127 + <descriptors>
  128 + <descriptor>src/main/assembly/pack.xml</descriptor>
  129 + </descriptors>
  130 + </configuration>
  131 + </execution>
  132 + </executions>
  133 + </plugin>
  134 + <plugin>
  135 + <artifactId>maven-eclipse-plugin</artifactId>
  136 + <version>2.8</version>
  137 + <configuration>
  138 + <downloadSources>true</downloadSources>
  139 + <downloadJavadocs>true</downloadJavadocs>
  140 + <workspace>..</workspace>
  141 + </configuration>
  142 + </plugin>
  143 + <plugin>
  144 + <groupId>org.apache.maven.plugins</groupId>
  145 + <artifactId>maven-source-plugin</artifactId>
  146 + <executions>
  147 + <execution>
  148 + <id>attach-sources</id>
  149 + <goals>
  150 + <goal>jar</goal>
  151 + </goals>
  152 + </execution>
  153 + </executions>
  154 + </plugin>
  155 + <plugin>
  156 + <groupId>org.apache.maven.plugins</groupId>
  157 + <artifactId>maven-javadoc-plugin</artifactId>
  158 + <executions>
  159 + <execution>
  160 + <id>attach-javadocs</id>
  161 + <goals>
  162 + <goal>jar</goal>
  163 + </goals>
  164 + </execution>
  165 + </executions>
  166 + </plugin>
  167 + </plugins>
  168 + </build>
  169 +
  170 + <dependencies>
  171 + <dependency>
  172 + <groupId>org.apache.chemistry.opencmis</groupId>
  173 + <artifactId>chemistry-opencmis-client-impl</artifactId>
  174 + <version>0.11.0</version>
  175 + </dependency>
  176 + <dependency>
  177 + <groupId>org.apache.chemistry.opencmis</groupId>
  178 + <artifactId>chemistry-opencmis-client-api</artifactId>
  179 + <version>0.11.0</version>
  180 + </dependency>
  181 + <dependency>
  182 + <groupId>org.apache.chemistry.opencmis</groupId>
  183 + <artifactId>chemistry-opencmis-client-bindings</artifactId>
  184 + <version>0.11.0</version>
  185 + </dependency>
  186 + <dependency>
  187 + <groupId>org.apache.chemistry.opencmis</groupId>
  188 + <artifactId>chemistry-opencmis-commons-impl</artifactId>
  189 + <version>0.11.0</version>
  190 + </dependency>
  191 + <dependency>
  192 + <groupId>org.apache.chemistry.opencmis</groupId>
  193 + <artifactId>chemistry-opencmis-commons-api</artifactId>
  194 + <version>0.11.0</version>
  195 + </dependency>
  196 + <dependency>
  197 + <groupId>org.apache.chemistry.opencmis</groupId>
  198 + <artifactId>chemistry-opencmis-server-support</artifactId>
  199 + <version>0.11.0</version>
  200 + </dependency>
  201 + <dependency>
  202 + <groupId>org.apache.chemistry.opencmis</groupId>
  203 + <artifactId>chemistry-opencmis-server-bindings</artifactId>
  204 + <version>0.11.0</version>
  205 + </dependency>
  206 + <dependency>
  207 + <groupId>commons-httpclient</groupId>
  208 + <artifactId>commons-httpclient</artifactId>
  209 + <version>3.1</version>
  210 + </dependency>
  211 + <dependency>
  212 + <groupId>com.googlecode.json-simple</groupId>
  213 + <artifactId>json-simple</artifactId>
  214 + <version>1.1</version>
  215 + </dependency>
  216 + <dependency>
  217 + <groupId>junit</groupId>
  218 + <artifactId>junit-dep</artifactId>
  219 + <version>4.11</version>
  220 + </dependency>
  221 + </dependencies>
  222 +</project>
... ...
src/main/assembly/pack.xml
... ... @@ -0,0 +1,40 @@
  1 +<!--
  2 + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
  3 + with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless
  4 + required by applicable law or agreed to in writing, software distributed under the License is distributed on an
  5 + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  6 + specific language governing permissions and limitations under the License.
  7 +-->
  8 +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
  9 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  10 + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
  11 + <id></id>
  12 + <formats>
  13 + <format>zip</format>
  14 + </formats>
  15 +
  16 + <files>
  17 + <file>
  18 + <source>${project.build.directory}/${project.build.finalName}.jar</source>
  19 + <outputDirectory>/</outputDirectory>
  20 + </file>
  21 + <file>
  22 + <source>LICENSE</source>
  23 + <outputDirectory>/</outputDirectory>
  24 + </file>
  25 + <file>
  26 + <source>README</source>
  27 + <outputDirectory>/</outputDirectory>
  28 + </file>
  29 + </files>
  30 +
  31 + <fileSets>
  32 + <fileSet>
  33 + <directory>src/main/java</directory>
  34 + <outputDirectory>source</outputDirectory>
  35 + <includes>
  36 + <include>**</include>
  37 + </includes>
  38 + </fileSet>
  39 + </fileSets>
  40 +</assembly>
0 41 \ No newline at end of file
... ...
src/main/java/org/alfresco/cmis/client/AlfrescoAspects.java
... ... @@ -0,0 +1,157 @@
  1 +/*
  2 + * Copyright 2005-2011 Alfresco Software Limited.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.alfresco.cmis.client;
  17 +
  18 +import java.util.Collection;
  19 +import java.util.Map;
  20 +
  21 +import org.apache.chemistry.opencmis.client.api.CmisObject;
  22 +import org.apache.chemistry.opencmis.client.api.ObjectType;
  23 +
  24 +/**
  25 + * Alfresco aspects interface.
  26 + */
  27 +public interface AlfrescoAspects {
  28 +
  29 + /**
  30 + * Returns a type definition with the applied aspects.
  31 + *
  32 + * @return an object type with all property definitions (object and aspect
  33 + * properties).
  34 + */
  35 + ObjectType getTypeWithAspects();
  36 +
  37 + /**
  38 + * Returns if the given aspect is applied to this object.
  39 + *
  40 + * @param id
  41 + * the aspect id
  42 + *
  43 + * @return <code>true</code> if the aspect is applied, <code>false</code>
  44 + * otherwise
  45 + */
  46 + boolean hasAspect(String id);
  47 +
  48 + /**
  49 + * Returns if the given aspect is applied to this object.
  50 + *
  51 + * @param type
  52 + * the aspect object type
  53 + *
  54 + * @return <code>true</code> if the aspect is applied, <code>false</code>
  55 + * otherwise
  56 + */
  57 + boolean hasAspect(ObjectType type);
  58 +
  59 + /**
  60 + * Returns all applied aspects. If no aspect is applied, an empty collection
  61 + * is returned.
  62 + *
  63 + * @return collection of the applied aspects
  64 + */
  65 + Collection<ObjectType> getAspects();
  66 +
  67 + /**
  68 + * Returns the aspect type that defines the given property.
  69 + *
  70 + * @param propertyId
  71 + * the property id
  72 + *
  73 + * @return the aspect type if the property id is defined in an applied
  74 + * aspect, <code>null</code> otherwise
  75 + */
  76 + ObjectType findAspect(String propertyId);
  77 +
  78 + /**
  79 + * Adds one or more aspects to the object.
  80 + *
  81 + * @param id
  82 + * the aspect id or ids
  83 + * @return the changed object (which may be a new object)
  84 + */
  85 + CmisObject addAspect(String... id);
  86 +
  87 + /**
  88 + * Adds one or more aspects to the object.
  89 + *
  90 + * @param type
  91 + * the aspect type or types
  92 + * @return the changed object (which may be a new object)
  93 + */
  94 + CmisObject addAspect(ObjectType... type);
  95 +
  96 + /**
  97 + * Adds an aspect and sets aspect properties.
  98 + *
  99 + * @param type
  100 + * the aspect type
  101 + * @param properties
  102 + * the aspect properties
  103 + * @return the changed object (which may be a new object)
  104 + */
  105 + CmisObject addAspect(ObjectType type, Map<String, ?> properties);
  106 +
  107 + /**
  108 + * Adds aspects and sets aspect properties.
  109 + *
  110 + * @param type
  111 + * the aspect types
  112 + * @param properties
  113 + * the aspect properties
  114 + * @return the changed object (which may be a new object)
  115 + */
  116 + CmisObject addAspect(ObjectType[] type, Map<String, ?> properties);
  117 +
  118 + /**
  119 + * Adds an aspect and sets aspect properties.
  120 + *
  121 + * @param id
  122 + * the aspect type
  123 + * @param properties
  124 + * the aspect properties
  125 + * @return the changed object (which may be a new object)
  126 + */
  127 + CmisObject addAspect(String id, Map<String, ?> properties);
  128 +
  129 + /**
  130 + * Adds aspects and sets aspect properties.
  131 + *
  132 + * @param id
  133 + * the aspect types
  134 + * @param properties
  135 + * the aspect properties
  136 + * @return the changed object (which may be a new object)
  137 + */
  138 + CmisObject addAspect(String[] id, Map<String, ?> properties);
  139 +
  140 + /**
  141 + * Removes one or more aspects from the object.
  142 + *
  143 + * @param id
  144 + * the aspect id or ids
  145 + * @return the changed object (which may be a new object)
  146 + */
  147 + CmisObject removeAspect(String... id);
  148 +
  149 + /**
  150 + * Removes one or more aspects from the object.
  151 + *
  152 + * @param id
  153 + * the aspect type or types
  154 + * @return the changed object (which may be a new object)
  155 + */
  156 + CmisObject removeAspect(ObjectType... type);
  157 +}
... ...
src/main/java/org/alfresco/cmis/client/AlfrescoDocument.java
... ... @@ -0,0 +1,22 @@
  1 +/*
  2 + * Copyright 2005-2011 Alfresco Software Limited.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.alfresco.cmis.client;
  17 +
  18 +import org.apache.chemistry.opencmis.client.api.Document;
  19 +
  20 +public interface AlfrescoDocument extends Document, AlfrescoAspects
  21 +{
  22 +}
... ...
src/main/java/org/alfresco/cmis/client/AlfrescoDocumentType.java
... ... @@ -0,0 +1,22 @@
  1 +/*
  2 + * Copyright 2005-2011 Alfresco Software Limited.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.alfresco.cmis.client;
  17 +
  18 +import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
  19 +
  20 +public interface AlfrescoDocumentType extends DocumentTypeDefinition, AlfrescoObjectType
  21 +{
  22 +}
... ...
src/main/java/org/alfresco/cmis/client/AlfrescoFolder.java
... ... @@ -0,0 +1,22 @@
  1 +/*
  2 + * Copyright 2005-2011 Alfresco Software Limited.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.alfresco.cmis.client;
  17 +
  18 +import org.apache.chemistry.opencmis.client.api.Folder;
  19 +
  20 +public interface AlfrescoFolder extends Folder, AlfrescoAspects
  21 +{
  22 +}
... ...
src/main/java/org/alfresco/cmis/client/AlfrescoFolderType.java
... ... @@ -0,0 +1,22 @@
  1 +/*
  2 + * Copyright 2005-2011 Alfresco Software Limited.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.alfresco.cmis.client;
  17 +
  18 +import org.apache.chemistry.opencmis.commons.definitions.FolderTypeDefinition;
  19 +
  20 +public interface AlfrescoFolderType extends FolderTypeDefinition, AlfrescoObjectType
  21 +{
  22 +}
... ...
src/main/java/org/alfresco/cmis/client/AlfrescoObjectType.java
... ... @@ -0,0 +1,28 @@
  1 +/*
  2 + * Copyright 2005-2011 Alfresco Software Limited.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.alfresco.cmis.client;
  17 +
  18 +import java.util.Collection;
  19 +
  20 +import org.apache.chemistry.opencmis.client.api.ObjectType;
  21 +
  22 +public interface AlfrescoObjectType extends ObjectType
  23 +{
  24 + /**
  25 + * Returns the aspects that are assigned to the object this type belongs to.
  26 + */
  27 + Collection<ObjectType> getAspects();
  28 +}
... ...
src/main/java/org/alfresco/cmis/client/authentication/OAuthCMISAuthenticationProvider.java
... ... @@ -0,0 +1,465 @@
  1 +package org.alfresco.cmis.client.authentication;
  2 +
  3 +import java.io.IOException;
  4 +import java.io.UnsupportedEncodingException;
  5 +import java.text.SimpleDateFormat;
  6 +import java.util.Collections;
  7 +import java.util.HashMap;
  8 +import java.util.List;
  9 +import java.util.Map;
  10 +import java.util.TimeZone;
  11 +
  12 +import javax.xml.parsers.DocumentBuilderFactory;
  13 +import javax.xml.parsers.ParserConfigurationException;
  14 +
  15 +import org.apache.chemistry.opencmis.client.bindings.spi.AbstractAuthenticationProvider;
  16 +import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
  17 +import org.apache.chemistry.opencmis.client.bindings.spi.cookies.CmisCookieManager;
  18 +import org.apache.chemistry.opencmis.commons.SessionParameter;
  19 +import org.apache.chemistry.opencmis.commons.impl.Base64;
  20 +import org.apache.commons.httpclient.HostConfiguration;
  21 +import org.apache.commons.httpclient.HttpClient;
  22 +import org.apache.commons.httpclient.HttpException;
  23 +import org.apache.commons.httpclient.HttpStatus;
  24 +import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
  25 +import org.apache.commons.httpclient.NameValuePair;
  26 +import org.apache.commons.httpclient.methods.PostMethod;
  27 +import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
  28 +import org.json.simple.JSONObject;
  29 +import org.json.simple.parser.JSONParser;
  30 +import org.json.simple.parser.ParseException;
  31 +import org.w3c.dom.Document;
  32 +import org.w3c.dom.Element;
  33 +
  34 +/**
  35 + * An OpenCMIS OAuth authentication provider.
  36 + *
  37 + * Example connection parameters:
  38 + *
  39 + * org.apache.chemistry.opencmis.binding.spi.type=atompub
  40 + * org.apache.chemistry.opencmis.binding.atompub.url=https://api.alfresco.com/cmis/versions/1.0/atom
  41 + * org.apache.chemistry.opencmis.binding.auth.classname=org.alfresco.cmis.client.authentication.OAuthCMISAuthenticationProvider
  42 + * org.apache.chemistry.opencmis.binding.auth.http.basic=false
  43 + * org.apache.chemistry.opencmis.binding.auth.oauth.accessToken=<access token>
  44 + * org.apache.chemistry.opencmis.binding.compression=true
  45 + *
  46 + * @author steveglover
  47 + *
  48 + */
  49 +public class OAuthCMISAuthenticationProvider extends AbstractAuthenticationProvider
  50 +{
  51 + public static final String ALFRESCO_ACCESS_TOKEN_URL = "https://api.alfresco.com/auth/oauth/versions/2/token";
  52 + public static final String ALFRESCO_REFRESH_TOKEN_URL = "https://api.alfresco.com/auth/oauth/versions/2/token";
  53 + public static final String PARAM_ACCESS_TOKEN = "org.apache.chemistry.opencmis.binding.auth.oauth.accessToken";
  54 +
  55 + private static final long serialVersionUID = 1L;
  56 +
  57 + private static final String WSSE_NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
  58 + private static final String WSU_NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
  59 +
  60 + private boolean sendUsernameToken = false;
  61 + private CmisCookieManager cookieManager;
  62 + private Map<String, List<String>> fixedHeaders = new HashMap<String, List<String>>();
  63 +
  64 + private String clientId;
  65 + private String clientSecret;
  66 + private String redirectUrl;
  67 +
  68 + private String authCode;
  69 + private String accessTokenUrl;
  70 + private String refreshTokenUrl;
  71 + private HttpClient client;
  72 +
  73 + private String accessToken;
  74 + private AccessToken accessTokenData;
  75 +
  76 + public static OAuthCMISAuthenticationProvider alfrescoOAuthProvider(String accessToken)
  77 + {
  78 + return new OAuthCMISAuthenticationProvider(accessToken);
  79 + }
  80 +
  81 + public static OAuthCMISAuthenticationProvider alfrescoOAuthProvider(String clientId, String clientSecret, String redirectUrl, String authCode)
  82 + {
  83 + return new OAuthCMISAuthenticationProvider(clientId, clientSecret, redirectUrl, ALFRESCO_ACCESS_TOKEN_URL, ALFRESCO_REFRESH_TOKEN_URL, authCode);
  84 + }
  85 +
  86 + public OAuthCMISAuthenticationProvider()
  87 + {
  88 + }
  89 +
  90 + /**
  91 + * Authenticates with the Alfresco CMIS Public Api with a previously-generated access token (no refresh token support).
  92 + *
  93 + * @param accessToken
  94 + */
  95 + public OAuthCMISAuthenticationProvider(String accessToken)
  96 + {
  97 + this.accessToken = accessToken;
  98 + }
  99 +
  100 + /**
  101 + * Authenticates with the Alfresco CMIS Public Api by generating an access token to communicate with the public api.
  102 + * Refresh support is provided.
  103 + *
  104 + * @param accessToken
  105 + */
  106 + public OAuthCMISAuthenticationProvider(String clientId, String clientSecret, String redirectUrl, String accessTokenUrl, String refreshTokenUrl, String authCode)
  107 + {
  108 + this.clientId = clientId;
  109 + this.clientSecret = clientSecret;
  110 + this.redirectUrl = redirectUrl;
  111 +
  112 + this.accessTokenUrl = accessTokenUrl;
  113 + this.refreshTokenUrl = refreshTokenUrl;
  114 + this.authCode = authCode;
  115 +
  116 + // Initialize manager
  117 + MultiThreadedHttpConnectionManager manager = new MultiThreadedHttpConnectionManager();
  118 + HttpConnectionManagerParams params = new HttpConnectionManagerParams();
  119 + params.setMaxTotalConnections(2);
  120 + params.setMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION, 2);
  121 +
  122 + // Create the client
  123 + client = new HttpClient(manager);
  124 +
  125 + generateAccessToken();
  126 + }
  127 +
  128 + public AccessToken getAccessTokenData()
  129 + {
  130 + return accessTokenData;
  131 + }
  132 +
  133 + private void generateAccessToken()
  134 + {
  135 + PostMethod method = new PostMethod(accessTokenUrl);
  136 + NameValuePair[] data =
  137 + {
  138 + new NameValuePair("redirect_uri", redirectUrl),
  139 + new NameValuePair("client_id", clientId),
  140 + new NameValuePair("client_secret", clientSecret),
  141 + new NameValuePair("code", authCode),
  142 + new NameValuePair("grant_type", "authorization_code")
  143 + };
  144 + method.setRequestBody(data);
  145 +
  146 + try
  147 + {
  148 + int result = client.executeMethod(null, method, null);
  149 + if(result == HttpStatus.SC_OK)
  150 + {
  151 + JSONParser parser = new JSONParser();
  152 + try
  153 + {
  154 + JSONObject json = (JSONObject)parser.parse(method.getResponseBodyAsString());
  155 + accessTokenData = new AccessToken(json);
  156 + }
  157 + catch (ParseException e)
  158 + {
  159 + throw new RuntimeException(e);
  160 + }
  161 + }
  162 + else
  163 + {
  164 + throw new RuntimeException(method.getStatusText());