Merged CMIS063 to HEAD

15843: Java tests harness: next  portion of v0.62
  15918: CMIS Test Harness update.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17235 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2009-10-29 17:01:43 +00:00
parent 689da0821f
commit 0e526dc4d1
33 changed files with 13212 additions and 3493 deletions

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/cmis-types.jar"/>
<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"/>
@@ -33,6 +34,6 @@
<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="lib" path="lib/opensaml-1.0.1.jar"/>
<classpathentry kind="output" path="build"/>
</classpath>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SimpleAlfrescoCmisServicesUsing</name>
<name>Simple-CMIS-Client</name>
<comment></comment>
<projects>
</projects>

View File

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

View File

@@ -3,4 +3,4 @@
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
java org.alfresco.cmis.ws.example.CmisSampleClient $1 $2 $3

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
* Copyright (C) 2005-2009 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
@@ -29,30 +29,29 @@ 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.CmisPropertyId;
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
*
* <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
public class CmisSampleClient
{
private static final String NAME_PROPERTY = "cmis:Name";
private static final String BASE_TYPE_ID_PROPERTY = "cmis:BaseTypeId";
/**
* Executable entry point - represents main life cycle
*
* @param args - not used
* @see SimpleCmisWsTest description
* Executable entry point - represents main life-cycle
*
* @param args - <b>String[]</b> array that contains command line arguments
*/
public static void main(String[] args)
{
@@ -73,15 +72,15 @@ public class SimpleExecutableCmisServicesUtilizer
password = args[2];
}
ExecutableServicesHelper servicesHelper;
CmisUtils servicesHelper;
try
{
servicesHelper = new ExecutableServicesHelper(username, password, serverUrl);
servicesHelper = new CmisUtils(username, password, serverUrl);
}
catch (Exception e)
{
System.out.println("Can't connect to specified server. Message: " + e.getMessage());
System.out.println("Can't connect to specified server. Cause error message: " + e.getMessage());
return;
}
@@ -89,7 +88,7 @@ public class SimpleExecutableCmisServicesUtilizer
try
{
response = servicesHelper.receiveSpaceContent(servicesHelper.receiveAuthorizedNavigationServicePort());
response = servicesHelper.receiveFolderEntry(servicesHelper.getRootFolderId());
}
catch (Exception e)
{
@@ -101,8 +100,8 @@ public class SimpleExecutableCmisServicesUtilizer
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().get(0);
boolean thisIsFolder = ((CmisPropertyId) getCmisProperty(item.getProperties(), BASE_TYPE_ID_PROPERTY)).getValue().get(0).contains("folder");
String itemName = ((CmisPropertyString) getCmisProperty(item.getProperties(), NAME_PROPERTY)).getValue().get(0);
System.out.println(((thisIsFolder) ? ("[") : ("")) + itemName + ((thisIsFolder) ? ("]") : ("")));
}
@@ -112,7 +111,7 @@ public class SimpleExecutableCmisServicesUtilizer
{
for (CmisProperty cmisProperty : properties.getProperty())
{
if (cmisProperty.getName().equalsIgnoreCase(cmisPropertyName))
if (cmisPropertyName.equals(getPropertyName(cmisProperty)))
{
return cmisProperty;
}
@@ -120,4 +119,15 @@ public class SimpleExecutableCmisServicesUtilizer
return null;
}
private static String getPropertyName(CmisProperty property)
{
String result = null;
if (null != property)
{
result = (null != property.getPdid()) ? (property.getPdid()):(property.getLocalname());
result = (null != result) ? (result) : (property.getDisplayname());
}
return result;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
* Copyright (C) 2005-2009 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
@@ -29,6 +29,7 @@ import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -36,17 +37,13 @@ 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.Holder;
import javax.xml.ws.Service;
import org.alfresco.repo.cmis.ws.CmisObjectType;
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.EnumIncludeRelationships;
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;
@@ -57,10 +54,10 @@ 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
public class CmisUtils
{
private static final QName NAVIGATION_SERVICE_NAME = new QName("http://docs.oasis-open.org/ns/cmis/ws/200901", "NavigationService");
private static final QName REPOSITORY_SERVICE_NAME = new QName("http://docs.oasis-open.org/ns/cmis/ws/200901", "RepositoryService");
@@ -68,21 +65,24 @@ public class ExecutableServicesHelper
private static final String NAVIGATION_SERVER_URL_POSTFIX = "/alfresco/cmis/NavigationService?wsdl";
private static final String REPOSITORY_SERVER_URL_POSTFIX = "/alfresco/cmis/RepositoryService?wsdl";
@SuppressWarnings("unused")
private static final Log LOGGER = LogFactory.getLog(ExecutableServicesHelper.class);
private String username;
private String password;
private Service navigationServicesFactory;
private Service repositoryServicesFactory;
private RepositoryServicePort repositoryService;
private NavigationServicePort navigationService;
private String repositoryId;
private String rootFolderId;
/**
* @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
public CmisUtils(String username, String password, String serverAddress)
{
this.username = username;
this.password = password;
@@ -94,55 +94,56 @@ public class ExecutableServicesHelper
}
catch (MalformedURLException e)
{
throw new Exception("Field to connect to specified URL. Exception Message: " + e.getMessage());
throw new RuntimeException("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>
* This method simplify receiving of Root Folder Id
*
* @return <b>String</b> representation of <b>Object Identificator</b>
* @throws RuntimeException This exception will be thrown when any <b>CMIS Services</b> operation fail
*/
public RepositoryServicePort receiveAuthorizedRepositoryServicePort()
public String getRootFolderId()
{
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))
if (null == rootFolderId)
{
return response.getObject();
try
{
rootFolderId = getRepositoryService().getRepositoryInfo(getRepositoryId()).getRootFolderId();
}
catch (Exception e)
{
throw new RuntimeException("Can't receive Root Folder Id. Cause error message: " + e.toString());
}
}
return rootFolderId;
}
/**
* This method simplify receiving children objects of specified folder
*
* @param folderId - <b>String</b> value that represents parent folder id
* @return <b>List&lt;CmisObjectType&gt;</b> - list of all children elements of specified folder
* @throws RuntimeException This exception will be thrown when any <b>CMIS Services</b> operation fail
*/
public List<CmisObjectType> receiveFolderEntry(String folderId)
{
Holder<List<CmisObjectType>> resultHolder = new Holder<List<CmisObjectType>>();
resultHolder.value = new LinkedList<CmisObjectType>();
Holder<Boolean> hasMoreItems = new Holder<Boolean>(false);
try
{
getNavigationService().getChildren(getRepositoryId(), folderId, "*", false, EnumIncludeRelationships.NONE, false, false, BigInteger.ZERO, BigInteger.ZERO, null,
resultHolder, hasMoreItems);
}
catch (Exception e)
{
throw new RuntimeException("Can't receive Children of specified folder with Id=" + folderId + ". Cause error message: " + e.toString());
}
if ((null != resultHolder) && (resultHolder.value != null))
{
return resultHolder.value;
}
else
{
@@ -150,58 +151,53 @@ public class ExecutableServicesHelper
}
}
/**
* 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
private String getRepositoryId()
{
return servicesPort.getRepositoryInfo(servicesPort.getRepositories().get(0).getRepositoryId()).getRootFolderId();
if (null == repositoryId)
{
try
{
return getRepositoryService().getRepositories().get(0).getId();
}
catch (Exception e)
{
throw new RuntimeException("Can't receive Repository Id. Cause error message: " + e.toString());
}
}
return repositoryId;
}
/**
* This method simplify creation of authorized Client instance with specified user name and appropriate password
*
* @return - an instance of authorized <b>CMIS Client</b>
* This method simplify <b>RepositoryServicePort</b> instance creation
*
* @return an instance of <b>RepositoryServicePort</b>
*/
protected Client createAuthorizationClient(Object servicePortInstance)
private RepositoryServicePort getRepositoryService()
{
Map<String, Object> outInterceptorProperties = configureWss4jProperties();
if (null == repositoryService)
{
repositoryService = configureWss4jClient(repositoryServicesFactory.getPort(RepositoryServicePort.class));
}
WSS4JOutInterceptor outInterceptor = new WSS4JOutInterceptor(outInterceptorProperties);
return createAndConfigureClientInstance(servicePortInstance, outInterceptor);
return repositoryService;
}
private GetChildren configureGetChildrenServiceQuery() throws Exception
/**
* This method simplify <b>NavigationServicePort</b> instance creation
*
* @return an instance of <b>NavigationServicePort</b>
*/
private NavigationServicePort getNavigationService()
{
ObjectFactory objectFactory = new ObjectFactory();
if (null == navigationService)
{
navigationService = configureWss4jClient(navigationServicesFactory.getPort(NavigationServicePort.class));
}
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;
return navigationService;
}
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()
private <ResultType> ResultType configureWss4jClient(ResultType servicePort)
{
Map<String, Object> outInterceptorProperties = new HashMap<String, Object>();
outInterceptorProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.TIMESTAMP);
@@ -216,6 +212,11 @@ public class ExecutableServicesHelper
}
});
return outInterceptorProperties;
WSS4JOutInterceptor outInterceptor = new WSS4JOutInterceptor(outInterceptorProperties);
Client client = ClientProxy.getClient(servicePort);
client.getEndpoint().getOutInterceptors().add(new SAAJOutInterceptor());
client.getEndpoint().getOutInterceptors().add(outInterceptor);
return servicePort;
}
}