Forgot to include my link: https://forums.alfresco.com/en/viewforum.php?f=45
On May 10, 2012, at 11:10 AM, Jeff Potts wrote: > Roberto, > > That wiki page is marked as "3.3". The old CMIS URL wasn't deprecated until > 4.0. > > I'm glad you found the official docs site. > > Another resource you might want to know about is the CMIS alfresco forum [1]. > If you have further issues that you think might be Alfresco-specific and you > want to bounce some ideas around, feel free to join us there. (This list is a > great resource too, I'm just adding to your list). > > Jeff > > On May 10, 2012, at 11:05 AM, Roberto Gómez wrote: > >> Hi Florian, >> >> As you suggested changing the old CMIS atompub binding url [1] for the new >> one [2] solves the issue. >> >> I was following the instructions from the Alfresco wiki [3]. Apparently it's >> a bit outdated, as this Jira issue [4] confirms. >> >> By the way, the correct place to look for documentation seems to be [5]. >> >> Thank you very much, Florian. >> >> [1] http://host/alfresco/s/cmis >> [2] http://<host>/alfresco/cmisatom >> [3] >> http://wiki.alfresco.com/wiki/CMIS_Web_Scripts_Reference#Alfresco_CMIS_AtomPub_Binding >> [4] https://issues.alfresco.com/jira/browse/ALF-12778 >> [5] >> http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Fopencmis-ext-using.html >> >> On 10/05/12 17:35, Florian Müller wrote: >>> Hi Roberto, >>> >>> That is an Alfresco specific problem and you should ask there. >>> >>> A hint from the top of my head: >>> Use "http://<host>/alfresco/cmisatom". The URL you are using is the old >>> CMIS URL. It retrieves the children of a folder from the fulltext engine, >>> which might not be up-to-date all the time. >>> >>> >>> - Florian >>> >>> >>>> Hi, >>>> >>>> I'am unable to get the newly created folder with the getChildren() >>>> method. It's worth to note, however, that after the creation I can >>>> confirm the existence of the newly created folder, but on calling >>>> getChildren() this new folder is not returned unless you wait a while. >>>> Please see below junit test. The method testCreateFolder fails, but >>>> testCreateFolderWait doesn't fail. Note, I have the cmis client cache >>>> dissabled. >>>> >>>> I'am ussing apache-chemistry-0.7.0 against and Alfresco-community-4.0.b. >>>> >>>> Is that a bug or I'am ussing wrong the client ? >>>> >>>> Thank you. >>>> >>>> >>>> >>>> >>>> >>>> public class DevelopSurefireTest { >>>> >>>> final Logger logger = LoggerFactory.getLogger(DevelopSurefireTest.class); >>>> private static Session session; >>>> >>>> @BeforeClass >>>> public static void BeforeClass(){ >>>> session = login("http://192.168.0.4:8080/alfresco/s/cmis", >>>> "admin","admin"); >>>> } >>>> >>>> @Test >>>> public void failSafeTest() { >>>> assertTrue(true); // Para que no falle en caso de que no haya más tests >>>> } >>>> >>>> @Test >>>> public void testCreateFolder() { >>>> String rootFolderId = session.getRootFolder().getId(); >>>> String folderName = UUID.randomUUID().toString(); >>>> Folder f = createFolder(rootFolderId, folderName); >>>> assertEquals(folderName, ((Folder)getObjectById(f.getId())).getName()); >>>> assertEquals(0, getFolders(f.getId()).size()); >>>> Folder f2 = createFolder(f.getId(), folderName.concat("2")); >>>> assertTrue(exists(f2.getId())); >>>> assertEquals(1, getFolders(f.getId()).size()); >>>> >>>> } >>>> >>>> @Test >>>> public void testCreateFolderWait() throws InterruptedException { >>>> String rootFolderId = session.getRootFolder().getId(); >>>> String folderName = UUID.randomUUID().toString(); >>>> Folder f = createFolder(rootFolderId, folderName); >>>> assertEquals(folderName, ((Folder)getObjectById(f.getId())).getName()); >>>> assertEquals(0, getFolders(f.getId()).size()); >>>> Folder f2 = createFolder(f.getId(), folderName.concat("2")); >>>> assertTrue(exists(f2.getId())); >>>> while( getFolders(f.getId()).size() != 1){ >>>> Thread.sleep(2000); >>>> } >>>> assertEquals(1, getFolders(f.getId()).size()); >>>> >>>> } >>>> >>>> public boolean exists(String objectId) throws CmisClientException { >>>> boolean exists; >>>> try { >>>> CmisObject o = getObjectById(objectId); >>>> exists = (o != null); >>>> } catch (CmisObjectNotFoundException e) { >>>> exists = false; >>>> } >>>> return exists; >>>> } >>>> >>>> public Folder createFolder(String parentId, String folderName) throws >>>> CmisClientException { >>>> Map<String, String> newFolderProps = new HashMap<String, String>(); >>>> newFolderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); >>>> newFolderProps.put(PropertyIds.NAME, folderName); >>>> Folder newFolder = >>>> ((Folder)getObjectById(parentId)).createFolder(newFolderProps); >>>> return newFolder; >>>> } >>>> >>>> public Set<Folder> getFolders(String folderId) throws CmisClientException { >>>> Set<Folder> childFolders = new HashSet<Folder>(); >>>> Iterator<CmisObject> it = >>>> ((Folder)getObjectById(folderId)).getChildren().iterator(); >>>> while (it.hasNext()) { >>>> CmisObject obj = it.next(); >>>> if (obj instanceof Folder) { >>>> childFolders.add((Folder) obj); >>>> } >>>> } >>>> return childFolders; >>>> } >>>> >>>> private CmisObject getObjectById(String id) throws CmisClientException { >>>> OperationContext oc = session.createOperationContext(); >>>> oc.setCacheEnabled(false); >>>> return session.getObject(id, oc); >>>> } >>>> >>>> public static Session login(String url, String username, String pass) >>>> throws CmisClientException { >>>> SessionFactory factory = SessionFactoryImpl.newInstance(); >>>> Map<String, String> parameters = new HashMap<String, String>(); >>>> >>>> // user credentials >>>> parameters.put(SessionParameter.USER, username); >>>> parameters.put(SessionParameter.PASSWORD, pass); >>>> >>>> // connection settings >>>> parameters.put(SessionParameter.ATOMPUB_URL, url); >>>> parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); >>>> parameters.put(SessionParameter.COMPRESSION, "true"); >>>> >>>> >>>> List<Repository> repositories = factory.getRepositories(parameters); >>>> Repository cmisRepo = repositories.get(0); // Generalmente solo se >>>> expone un repositorio >>>> >>>> Session s = cmisRepo.createSession(); >>>> >>>> // >>>> >>>> http://chemistry.apache.org/java/opencmis-cookbook.html#understanding_the_client_side_cache >>>> >>>> s.getDefaultContext().setCacheEnabled(false); >>>> RepositoryInfo repositoryInfo = s.getRepositoryInfo(); >>>> return s; >>>> } >>>> } >>> >> >
