Return-Path: X-Original-To: apmail-chemistry-dev-archive@www.apache.org Delivered-To: apmail-chemistry-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 08327CA76 for ; Thu, 10 May 2012 16:11:35 +0000 (UTC) Received: (qmail 58833 invoked by uid 500); 10 May 2012 16:11:34 -0000 Delivered-To: apmail-chemistry-dev-archive@chemistry.apache.org Received: (qmail 58779 invoked by uid 500); 10 May 2012 16:11:34 -0000 Mailing-List: contact dev-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list dev@chemistry.apache.org Received: (qmail 58771 invoked by uid 99); 10 May 2012 16:11:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 May 2012 16:11:34 +0000 X-ASF-Spam-Status: No, hits=-0.5 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jeffpotts01@gmail.com designates 209.85.214.170 as permitted sender) Received: from [209.85.214.170] (HELO mail-ob0-f170.google.com) (209.85.214.170) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 May 2012 16:11:26 +0000 Received: by obbuo13 with SMTP id uo13so4265632obb.1 for ; Thu, 10 May 2012 09:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; bh=sGGEolgifwkNwg+wgqswXMhkLfeQJu+sX2fXaDkV/10=; b=wfx9Gstwzuo72j28KaR9DyM0XVErM2A7m9ZFX+NGNtWGu470052xnUUiGRu+qjP9uQ WbR1ZUTIAnCx0cnSlGwRpzYxX5uhWM6o2RBuDT8nGwd1R5MHucWZbREyhooSHgeydGDb ThkcH8LZabDx0luopvZVBwd1BDpPJk0w05SwmdB88QEzR4fUcwpG+vCT6Vsh4GbT3TgT hFeO5ultySBCpWk+OhyomHUsGP36HoGVkGB2h9B49s/qZy1UuYELasmUF8X0jWABVbDx wss2T30kU8B3IRG/GIuts6KlkOr4mOFmcTfJG60hPBCX+FIonxnEEacbklxWzJ9G27YP YmLw== Received: by 10.182.164.69 with SMTP id yo5mr6801489obb.17.1336666265324; Thu, 10 May 2012 09:11:05 -0700 (PDT) Received: from [192.168.0.13] (cpe-173-173-95-161.tx.res.rr.com. [173.173.95.161]) by mx.google.com with ESMTPS id bd10sm6492894obb.15.2012.05.10.09.10.59 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 10 May 2012 09:11:01 -0700 (PDT) Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Apple Message framework v1257) Subject: Re: Unable to get the newly created folder with the getChildren() method, unless wait for a while From: Jeff Potts In-Reply-To: <4FABE736.8000203@queres.com> Date: Thu, 10 May 2012 11:10:58 -0500 Content-Transfer-Encoding: quoted-printable Message-Id: References: <4FABCF7D.9060001@queres.com> <15ff17f3ff33babd06a8a24e7027bdb4-EhVcXl9JQQFXRwQFDQkEXR0wfgZLV15fQUBFBEFYXS9ZUF0WWlloB11LX15YLkQBXFxfRlxUWQw=-webmailer2@server01.webmailer.hosteurope.de> <4FABE736.8000203@queres.com> To: dev@chemistry.apache.org X-Mailer: Apple Mail (2.1257) 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).=20 Jeff On May 10, 2012, at 11:05 AM, Roberto G=F3mez wrote: > Hi Florian, >=20 > As you suggested changing the old CMIS atompub binding url [1] for the = new one [2] solves the issue. >=20 > I was following the instructions from the Alfresco wiki [3]. = Apparently it's a bit outdated, as this Jira issue [4] confirms. >=20 > By the way, the correct place to look for documentation seems to be = [5]. >=20 > Thank you very much, Florian. >=20 > [1] http://host/alfresco/s/cmis > [2] http:///alfresco/cmisatom > [3] = http://wiki.alfresco.com/wiki/CMIS_Web_Scripts_Reference#Alfresco_CMIS_Ato= mPub_Binding > [4] https://issues.alfresco.com/jira/browse/ALF-12778 > [5] = http://docs.alfresco.com/4.0/index.jsp?topic=3D%2Fcom.alfresco.enterprise.= doc%2Fconcepts%2Fopencmis-ext-using.html >=20 > On 10/05/12 17:35, Florian M=FCller wrote: >> Hi Roberto, >>=20 >> That is an Alfresco specific problem and you should ask there. >>=20 >> A hint from the top of my head: >> Use "http:///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. >>=20 >>=20 >> - Florian >>=20 >>=20 >>> Hi, >>>=20 >>> 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. >>>=20 >>> I'am ussing apache-chemistry-0.7.0 against and = Alfresco-community-4.0.b. >>>=20 >>> Is that a bug or I'am ussing wrong the client ? >>>=20 >>> Thank you. >>>=20 >>>=20 >>>=20 >>>=20 >>>=20 >>> public class DevelopSurefireTest { >>>=20 >>> final Logger logger =3D = LoggerFactory.getLogger(DevelopSurefireTest.class); >>> private static Session session; >>>=20 >>> @BeforeClass >>> public static void BeforeClass(){ >>> session =3D login("http://192.168.0.4:8080/alfresco/s/cmis", = "admin","admin"); >>> } >>>=20 >>> @Test >>> public void failSafeTest() { >>> assertTrue(true); // Para que no falle en caso de que no haya m=E1s = tests >>> } >>>=20 >>> @Test >>> public void testCreateFolder() { >>> String rootFolderId =3D session.getRootFolder().getId(); >>> String folderName =3D UUID.randomUUID().toString(); >>> Folder f =3D createFolder(rootFolderId, folderName); >>> assertEquals(folderName, = ((Folder)getObjectById(f.getId())).getName()); >>> assertEquals(0, getFolders(f.getId()).size()); >>> Folder f2 =3D createFolder(f.getId(), folderName.concat("2")); >>> assertTrue(exists(f2.getId())); >>> assertEquals(1, getFolders(f.getId()).size()); >>>=20 >>> } >>>=20 >>> @Test >>> public void testCreateFolderWait() throws InterruptedException { >>> String rootFolderId =3D session.getRootFolder().getId(); >>> String folderName =3D UUID.randomUUID().toString(); >>> Folder f =3D createFolder(rootFolderId, folderName); >>> assertEquals(folderName, = ((Folder)getObjectById(f.getId())).getName()); >>> assertEquals(0, getFolders(f.getId()).size()); >>> Folder f2 =3D createFolder(f.getId(), folderName.concat("2")); >>> assertTrue(exists(f2.getId())); >>> while( getFolders(f.getId()).size() !=3D 1){ >>> Thread.sleep(2000); >>> } >>> assertEquals(1, getFolders(f.getId()).size()); >>>=20 >>> } >>>=20 >>> public boolean exists(String objectId) throws CmisClientException { >>> boolean exists; >>> try { >>> CmisObject o =3D getObjectById(objectId); >>> exists =3D (o !=3D null); >>> } catch (CmisObjectNotFoundException e) { >>> exists =3D false; >>> } >>> return exists; >>> } >>>=20 >>> public Folder createFolder(String parentId, String folderName) = throws >>> CmisClientException { >>> Map newFolderProps =3D new HashMap(); >>> newFolderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); >>> newFolderProps.put(PropertyIds.NAME, folderName); >>> Folder newFolder =3D >>> ((Folder)getObjectById(parentId)).createFolder(newFolderProps); >>> return newFolder; >>> } >>>=20 >>> public Set getFolders(String folderId) throws = CmisClientException { >>> Set childFolders =3D new HashSet(); >>> Iterator it =3D >>> ((Folder)getObjectById(folderId)).getChildren().iterator(); >>> while (it.hasNext()) { >>> CmisObject obj =3D it.next(); >>> if (obj instanceof Folder) { >>> childFolders.add((Folder) obj); >>> } >>> } >>> return childFolders; >>> } >>>=20 >>> private CmisObject getObjectById(String id) throws = CmisClientException { >>> OperationContext oc =3D session.createOperationContext(); >>> oc.setCacheEnabled(false); >>> return session.getObject(id, oc); >>> } >>>=20 >>> public static Session login(String url, String username, String = pass) >>> throws CmisClientException { >>> SessionFactory factory =3D SessionFactoryImpl.newInstance(); >>> Map parameters =3D new HashMap(); >>>=20 >>> // user credentials >>> parameters.put(SessionParameter.USER, username); >>> parameters.put(SessionParameter.PASSWORD, pass); >>>=20 >>> // connection settings >>> parameters.put(SessionParameter.ATOMPUB_URL, url); >>> parameters.put(SessionParameter.BINDING_TYPE, = BindingType.ATOMPUB.value()); >>> parameters.put(SessionParameter.COMPRESSION, "true"); >>>=20 >>>=20 >>> List repositories =3D = factory.getRepositories(parameters); >>> Repository cmisRepo =3D repositories.get(0); // Generalmente solo se >>> expone un repositorio >>>=20 >>> Session s =3D cmisRepo.createSession(); >>>=20 >>> // >>>=20 >>> = http://chemistry.apache.org/java/opencmis-cookbook.html#understanding_the_= client_side_cache=20 >>> s.getDefaultContext().setCacheEnabled(false); >>> RepositoryInfo repositoryInfo =3D s.getRepositoryInfo(); >>> return s; >>> } >>> } >>=20 >=20