chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Van Belle <jonathan.vanbe...@cediti.be>
Subject opencmis and create folder in alfresco
Date Thu, 29 Sep 2011 11:06:13 GMT
Hi everybody,
I try to do stuff with opencmis and Alfresco. I tried to create a 
folder, but it's seeems not working. Reading works perfectly.

Here is the code that I use  (try with 0.0.5 and 0.6.0-snapshot version 
of opencmis) :
>
> import java.util.ArrayList;
> import java.util.HashMap;
> import java.util.List;
> import java.util.Map;
>
> import org.apache.chemistry.opencmis.client.api.Folder;
> import org.apache.chemistry.opencmis.client.api.Repository;
> import org.apache.chemistry.opencmis.client.api.Session;
> import org.apache.chemistry.opencmis.client.api.SessionFactory;
> import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
> import org.apache.chemistry.opencmis.commons.PropertyIds;
> import org.apache.chemistry.opencmis.commons.SessionParameter;
> import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
> import org.apache.chemistry.opencmis.commons.enums.BindingType;
>
> /**
>  */
> public class TestCmisAtomAlfresco
> {
>     private static final String USER = "admin";
>     private static final String PASSWORD = "admin";
>     private static final String ATOM_URL = 
> "http://cmis.alfresco.com/cmisatom";
>
>     public static void main(final String... args)
>     {
>         final Map<String, String> parameter = new HashMap<String, 
> String>();
>
>         // user credentials
>         parameter.put(SessionParameter.USER, TestCmisAtomAlfresco.USER);
>         parameter.put(SessionParameter.PASSWORD, 
> TestCmisAtomAlfresco.PASSWORD);
>
>         // connection settings
>         parameter.put(SessionParameter.ATOMPUB_URL, 
> TestCmisAtomAlfresco.ATOM_URL);
>         parameter.put(SessionParameter.BINDING_TYPE, 
> BindingType.ATOMPUB.value());
>
>         // default factory implementation
>         final SessionFactory factory = SessionFactoryImpl.newInstance();
>         Session session;
>         List<Repository> repositories = new ArrayList<Repository>();
>         repositories = factory.getRepositories(parameter);
>         for (final Repository r : repositories)
>         {
>             System.out.println("Found repository: " + r.getName());
>         }
>
>         // create session with the first repository
>         final Repository repository = repositories.get(0);
>         parameter.put(SessionParameter.REPOSITORY_ID, repository.getId());
>         session = factory.createSession(parameter);
>
>         System.out.println("Got a connection to repository: " + 
> repository.getName() + ", with id: "
>             + repository.getId());
>
>         final RepositoryInfo lcf_repoInfo = session.getRepositoryInfo();
>         System.out.println("Version CMIS : " + 
> lcf_repoInfo.getCmisVersionSupported());
>
>         // get destination folder
>         final Folder folderDestination = session.getRootFolder();
>
>         System.out.println("Create folder");
>
>         final Map<String, String> newFolderProps = new HashMap<String, 
> String>();
>         newFolderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
>         newFolderProps.put(PropertyIds.NAME, "test-cmis-creation");
>
>         // Create folder
>
>         Folder newFolder = null;
>         try
>         {
>             newFolder = (Folder) session.createFolder(newFolderProps, 
> folderDestination);
>             System.out.println(newFolder);
>         }
>         catch (final Exception lcf_e)
>         {
>             lcf_e.printStackTrace();
>         }
>
>         session.clear();
>     }
> }

The exception genereted :
> Found repository: Main Repository
> Got a connection to repository: Main Repository, with id: 
> 371554cd-ac06-40ba-98b8-e6b60275cca7
> Version CMIS : 1.0
> Create folder
> org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: 
> Request Entity Too Large
>     at 
> org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:450)
>     at 
> org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:568)
>     at 
> org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.createFolder(ObjectServiceImpl.java:153)
>     at 
> org.apache.chemistry.opencmis.client.runtime.SessionImpl.createFolder(SessionImpl.java:703)
>     at 
> org.apache.chemistry.opencmis.client.runtime.SessionImpl.createFolder(SessionImpl.java:762)
>     at 
> eu.aznetwork.jazee.proptotype.cmis.client.TestCmisAtomAlfresco.main(TestCmisAtomAlfresco.java:80)

Anyone have a solution ?

-- 
Jonathan Van Belle
Aznetwork - Cediti
+32 (0)71 25 94 19



Mime
View raw message