Merge from DEV/SEAMIST3

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10832 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2008-09-07 13:06:28 +00:00
parent 64bf87af37
commit a42cc8992f
51 changed files with 4046 additions and 352 deletions

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/cxf-2.1.2.jar"/>
<classpathentry kind="lib" path="lib/FastInfoset-1.2.2.jar"/>
<classpathentry kind="lib" path="lib/geronimo-activation_1.1_spec-1.0.2.jar"/>
<classpathentry kind="lib" path="lib/geronimo-annotation_1.0_spec-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/geronimo-javamail_1.4_spec-1.3.jar"/>
<classpathentry kind="lib" path="lib/geronimo-jaxws_2.1_spec-1.0.jar"/>
<classpathentry kind="lib" path="lib/geronimo-servlet_2.5_spec-1.2.jar"/>
<classpathentry kind="lib" path="lib/geronimo-stax-api_1.0_spec-1.0.1.jar"/>
<classpathentry kind="lib" path="lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar"/>
<classpathentry kind="lib" path="lib/jaxb-api-2.1.jar"/>
<classpathentry kind="lib" path="lib/jaxb-impl-2.1.7.jar"/>
<classpathentry kind="lib" path="lib/jaxb-xjc-2.1.7.jar"/>
<classpathentry kind="lib" path="lib/jetty-6.1.9.jar"/>
<classpathentry kind="lib" path="lib/jetty-util-6.1.9.jar"/>
<classpathentry kind="lib" path="lib/neethi-2.0.4.jar"/>
<classpathentry kind="lib" path="lib/saaj-api-1.3.jar"/>
<classpathentry kind="lib" path="lib/saaj-impl-1.3.jar"/>
<classpathentry kind="lib" path="lib/spring-beans-2.0.8.jar"/>
<classpathentry kind="lib" path="lib/spring-context-2.0.8.jar"/>
<classpathentry kind="lib" path="lib/spring-core-2.0.8.jar"/>
<classpathentry kind="lib" path="lib/spring-web-2.0.8.jar"/>
<classpathentry kind="lib" path="lib/stax-utils-20060502.jar"/>
<classpathentry kind="lib" path="lib/velocity-1.4.jar"/>
<classpathentry kind="lib" path="lib/velocity-dep-1.4.jar"/>
<classpathentry kind="lib" path="lib/wsdl4j-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/wss4j-1.5.4.jar"/>
<classpathentry kind="lib" path="lib/wstx-asl-3.2.4.jar"/>
<classpathentry kind="lib" path="lib/xml-resolver-1.2.jar"/>
<classpathentry kind="lib" path="lib/XmlSchema-1.4.2.jar"/>
<classpathentry kind="lib" path="lib/xmlsec-1.3.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/cmis-types.jar"/>
<classpathentry kind="output" path="build"/>
</classpath>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SimpleAlfrescoCmisServicesUsing</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<project name="SimpleAlfrescoCmisServicesUsing" default="build" basedir=".">
<property name="project.dir" value="." />
<property name="build.dir" value="${project.dir}/build" />
<property name="dist.dir" value="${build.dir}/dist" />
<path id="class.path">
<dirset dir="${build.dir}" />
<fileset dir="${project.dir}/lib" includes="**/*.jar" />
</path>
<target name="build">
<delete dir="${build.dir}" />
<mkdir dir="${build.dir}" />
<mkdir dir="${build.dir}/classes" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${dist.dir}/lib" />
<javac classpathref="class.path" srcdir="${project.dir}/src" destdir="${build.dir}/classes" />
<jar destfile="${dist.dir}/cmis-test-client.jar">
<fileset dir="${build.dir}/classes" />
</jar>
<copy file="${project.dir}/cmis-test.bat" todir="${dist.dir}" />
<copy todir="${dist.dir}/lib">
<fileset dir="${project.dir}/lib" />
</copy>
<delete dir="${build.dir}/classes" />
</target>
</project>

View File

@@ -0,0 +1,6 @@
@echo off
set CLASSPATH=cmis-test.jar
for %%i in (./lib/*.jar) do call set CLASSPATH=./lib/%%~i;%%CLASSPATH%%
java org.alfresco.cmis.ws.example.SimpleExecutableCmisServicesUtilizer %1 %2 %3

View File

@@ -0,0 +1,6 @@
#!/bin/sh
export CLASSPATH=./cmis-test-client.jar
for jar in ./lib/*.jar; do export CLASSPATH=$CLASSPATH:$jar; done
java org.alfresco.cmis.ws.example.SimpleExecutableCmisServicesUtilizer $1 $2 $3

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,22 @@
This simple example connects to the Alfresco CMIS Server and displays the names
of the folders within the Alfresco root folder called "Company Home".
The example utilizes the Alfresco CMIS Web Services interfaces.
The example is stand-alone and includes all of its dependencies.
Steps to execute the example...
Pre-requisites:
a) The Alfresco Server must be running for the test client to succeed.
b) ant is required to build the test client
1) Unpack JavaCmisTest.zip to <destdir>
2) Run <destdir>/ant
3) Run <destdir>cmis-test.bat http://<alfresco_host>:<alfresco_port> <username> <password>
Note: A cmis-test.sh also exists.
Upon successful completion, a list of folder names is presented.
The source code for the example is also included.

View File

@@ -0,0 +1,229 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.ws.example;
import java.io.IOException;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import org.alfresco.repo.cmis.ws.CmisObjectType;
import org.alfresco.repo.cmis.ws.CmisQueryType;
import org.alfresco.repo.cmis.ws.CmisRepositoryEntryType;
import org.alfresco.repo.cmis.ws.EnumTypesOfFileableObjects;
import org.alfresco.repo.cmis.ws.GetChildren;
import org.alfresco.repo.cmis.ws.GetChildrenResponse;
import org.alfresco.repo.cmis.ws.GetFolderParent;
import org.alfresco.repo.cmis.ws.GetRepositories;
import org.alfresco.repo.cmis.ws.GetRepositoryInfo;
import org.alfresco.repo.cmis.ws.GetTypes;
import org.alfresco.repo.cmis.ws.NavigationServicePort;
import org.alfresco.repo.cmis.ws.ObjectFactory;
import org.alfresco.repo.cmis.ws.RepositoryServicePort;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.WSPasswordCallback;
import org.apache.ws.security.handler.WSHandlerConstants;
/**
* This helper-class contain all necessary for <b>SimpleCmisWsTest</b> correct working service-methods
*
* @author Dmitry Velichkevich
*/
public class ExecutableServicesHelper
{
private static final QName NAVIGATION_SERVICE_NAME = new QName("http://www.cmis.org/ns/1.0", "NavigationService");
private static final QName REPOSITORY_SERVICE_NAME = new QName("http://www.cmis.org/ns/1.0", "RepositoryService");
private static final String NAVIGATION_SERVER_URL_POSTFIX = "/alfresco/cmis/NavigationService?wsdl";
private static final String REPOSITORY_SERVER_URL_POSTFIX = "/alfresco/cmis/RepositoryService?wsdl";
private static final Log LOGGER = LogFactory.getLog(ExecutableServicesHelper.class);
private String username;
private String password;
private Service navigationServicesFactory;
private Service repositoryServicesFactory;
/**
* @param username - an existent authentication user name
* @param password - appropriate password for specified user name
* @param serverAddress - IP address (or domain name) and port for the server to connect
* @throws Exception - an caught <b>MalformedURLException</b> in time of server connect <b>URL</b> creation
*/
public ExecutableServicesHelper(String username, String password, String serverAddress) throws Exception
{
this.username = username;
this.password = password;
try
{
navigationServicesFactory = Service.create(new URL(serverAddress + NAVIGATION_SERVER_URL_POSTFIX), NAVIGATION_SERVICE_NAME);
repositoryServicesFactory = Service.create(new URL(serverAddress + REPOSITORY_SERVER_URL_POSTFIX), REPOSITORY_SERVICE_NAME);
}
catch (MalformedURLException e)
{
throw new Exception("Field to connect to specified URL. Exception Message: " + e.getMessage());
}
}
/**
* This method simplify <b>RepositoryServicePort</b> instance creation
*
* @return an instance of <b>RepositoryServicePort</b>
*/
public RepositoryServicePort receiveAuthorizedRepositoryServicePort()
{
RepositoryServicePort result = repositoryServicesFactory.getPort(RepositoryServicePort.class);
createAuthorizationClient(result);
return result;
}
/**
* This method simplify <b>NavigationServicePort</b> instance creation
*
* @return an instance of <b>NavigationServicePort</b>
*/
public NavigationServicePort receiveAuthorizedNavigationServicePort()
{
NavigationServicePort result = navigationServicesFactory.getPort(NavigationServicePort.class);
createAuthorizationClient(result);
return result;
}
/**
* This method simplify configuring of <b>GetChildren CMIS Service</b> query with "ANY" filter, <b>Company Home Object Identificator</b> and <b>FOLDERS_AND_DOCUMENTS</b>
* entity types.
*
* @param servicesPort - <b>NavigationServicePort</b> configured with <b>WSS4J Client</b> instance
* @return <b>List< DocumentOrFolderObjectType></b> - list of all children elements of <b>Company Home</b> folder
* @throws Exception This exception throws when any <b>CMIS Services</b> operations was failed
*/
public List<CmisObjectType> receiveSpaceContent(NavigationServicePort servicesPort) throws Exception
{
GetChildrenResponse response;
response = servicesPort.getChildren(configureGetChildrenServiceQuery());
if ((response != null) && (response.getObject() != null))
{
return response.getObject();
}
else
{
return null;
}
}
/**
* This method simplify receiving of Object Identificator for Company Home Root Folder
*
* @param servicesPort - <b>RepositoryServicePort</b> instance that configured with WSS4J Client
* @return <b>String</b> representation of <b>Object Identificator</b>
* @throws Exception This exception throws when any <b>CMIS Services</b> operations was failed
*/
public String receiveCompanyHomeObjectId(RepositoryServicePort servicesPort) throws Exception
{
GetRepositoryInfo parameteers = new GetRepositoryInfo();
parameteers.setRepositoryId(servicesPort.getRepositories().get(0).getRepositoryID());
return servicesPort.getRepositoryInfo(parameteers).getRootFolderId();
}
/**
* This method simplify creation of authorized Client instance with specified user name and appropriate password
*
* @return - an instance of authorized <b>CMIS Client</b>
*/
protected Client createAuthorizationClient(Object servicePortInstance)
{
Map<String, Object> outInterceptorProperties = configureWss4jProperties();
WSS4JOutInterceptor outInterceptor = new WSS4JOutInterceptor(outInterceptorProperties);
return createAndConfigureClientInstance(servicePortInstance, outInterceptor);
}
private GetChildren configureGetChildrenServiceQuery() throws Exception
{
ObjectFactory objectFactory = new ObjectFactory();
RepositoryServicePort authorizedRepositoryServicePort = receiveAuthorizedRepositoryServicePort();
GetChildren requestParameters = objectFactory.createGetChildren();
requestParameters.setRepositoryId(authorizedRepositoryServicePort.getRepositories().get(0).getRepositoryID());
requestParameters.setFilter(objectFactory.createGetChildrenFilter("*"));
requestParameters.setMaxItems(objectFactory.createGetChildrenMaxItems(BigInteger.valueOf(Long.MAX_VALUE)));
requestParameters.setFolderId(receiveCompanyHomeObjectId(authorizedRepositoryServicePort));
requestParameters.setType(objectFactory.createGetChildrenType(EnumTypesOfFileableObjects.ANY));
return requestParameters;
}
private Client createAndConfigureClientInstance(Object servicePortInstance, WSS4JOutInterceptor outInterceptor)
{
Client client = ClientProxy.getClient(servicePortInstance);
client.getEndpoint().getOutInterceptors().add(new SAAJOutInterceptor());
client.getEndpoint().getOutInterceptors().add(outInterceptor);
return client;
}
private Map<String, Object> configureWss4jProperties()
{
Map<String, Object> outInterceptorProperties = new HashMap<String, Object>();
outInterceptorProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.TIMESTAMP);
outInterceptorProperties.put(WSHandlerConstants.USER, username);
outInterceptorProperties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
outInterceptorProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler()
{
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
((WSPasswordCallback) callbacks[0]).setPassword(password);
}
});
return outInterceptorProperties;
}
}

View File

@@ -0,0 +1,123 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.ws.example;
import java.util.List;
import org.alfresco.repo.cmis.ws.CmisObjectType;
import org.alfresco.repo.cmis.ws.CmisPropertiesType;
import org.alfresco.repo.cmis.ws.CmisProperty;
import org.alfresco.repo.cmis.ws.CmisPropertyString;
/**
* This class executes simple processing for prompting server address and user name and password for authentication this user on specified server. After successful connection this
* class print contents of Company Home.<br />
* <br />
* This class expects next command-line parameters:<nobr />
* <ul>
* <li><b>Server Address</b> - with form: (IP_ADDRESS|DOMAIN_NAME):PORT;</li>
* <li><b>Username</b> - login name of the existent user;</li>
* <li><b>Password</b> - appropriate password for specified user.</li>
* </ul>
* <b>Example: <font color=green>192.168.0.1:8080 admin admin</font></b> - authenticate an user as admin on <font color=gray><b>http://192.168.0.1:8080/alfresco/</b></font>
* server
*
* @author Dmitry Velichkevich
*/
public class SimpleExecutableCmisServicesUtilizer
{
/**
* Executable entry point - represents main life cycle
*
* @param args - not used
* @see SimpleCmisWsTest description
*/
public static void main(String[] args)
{
String username = null;
String password = null;
String serverUrl = null;
if (args.length != 3)
{
System.out.println("Usage: cmis-test.bat server_url username password");
System.out.println("Example : cmis-test.bat http://localhost:8080 admin admin");
return;
}
else
{
serverUrl = args[0];
username = args[1];
password = args[2];
}
ExecutableServicesHelper servicesHelper;
try
{
servicesHelper = new ExecutableServicesHelper(username, password, serverUrl);
}
catch (Exception e)
{
System.out.println("Can't connect to specified server. Message: " + e.getMessage());
return;
}
List<CmisObjectType> response;
try
{
response = servicesHelper.receiveSpaceContent(servicesHelper.receiveAuthorizedNavigationServicePort());
}
catch (Exception e)
{
System.out.println("Can't receive content of Company Home caused: " + e.getMessage());
e.printStackTrace();
return;
}
System.out.println("Outing Company Home contents:");
for (CmisObjectType item : response)
{
boolean thisIsFolder = ((CmisPropertyString) getCmisProperty(item.getProperties(), "BaseType")).getValue().contains("folder");
String itemName = ((CmisPropertyString) getCmisProperty(item.getProperties(), "Name")).getValue();
System.out.println(((thisIsFolder) ? ("[") : ("")) + itemName + ((thisIsFolder) ? ("]") : ("")));
}
}
private static CmisProperty getCmisProperty(CmisPropertiesType properties, String cmisPropertyName)
{
for (CmisProperty cmisProperty : properties.getProperty())
{
if (cmisProperty.getName().equalsIgnoreCase(cmisPropertyName))
{
return cmisProperty;
}
}
return null;
}
}