03-28-2011 01:58 PM
 
					
				
		
03-29-2011 11:24 AM
RepositoryInfo ri = session.getBinding().getRepositoryService().getRepositoryInfo(session.getRepositoryInfo().getId(), null);
String latestChangeLogToken = ri.getLatestChangeLogToken();05-07-2013 03:48 AM

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import org.apache.chemistry.opencmis.client.api.ChangeEvents;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
import org.apache.chemistry.opencmis.commons.enums.BindingType;
import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
public class TempTest {
   /**
    * @param args
    */
   public static void main(String[] args) {
      final CmisBinding binding;
      final Session session;
      final Session websession;
      String repositoryId;
      String url = "http://10.20.1.110:8080/alfresco/cmisatom";
      // holder for the parameters
      final Map<String, String> parameters = new HashMap<String, String>();
      // User credentials.
      parameters.put(SessionParameter.USER, "admin");
      parameters.put(SessionParameter.PASSWORD, "admin");
      // Connection settings.
      parameters.put(SessionParameter.ATOMPUB_URL, url);
      // type of binding
      parameters.put(SessionParameter.BINDING_TYPE,
            BindingType.ATOMPUB.value());
      try {
            // no repositoryId is set so first make a binding to fetch
            // the
            // first repository in the list
            binding = CmisBindingFactory.newInstance()
                  .createCmisAtomPubBinding(parameters);
            // if there is no binding no use to get on
            if (binding != null) {
               final List<RepositoryInfo> infos = binding
                     .getRepositoryService()
                     .getRepositoryInfos(null);
               if (!infos.isEmpty()) {
                  final RepositoryInfo repInfo = infos.get(0);
                  // now we have the repository and use it as a
                  // parameter
                  // to create the session
                  repositoryId = repInfo.getId();
                  parameters.put(SessionParameter.REPOSITORY_ID,
                        repositoryId);
               } else {
                  System.out.println("No repository found!");
               }
            } else {
               System.out.println("Given credentials are probably not correct!");
            }
         final SessionFactory sessionFactory = SessionFactoryImpl
               .newInstance();
         session = sessionFactory.createSession(parameters);
         
         RepositoryInfo ri = session.getBinding().getRepositoryService().getRepositoryInfo(session.getRepositoryInfo().getId(), null);
         String latestChangeLogToken = ri.getLatestChangeLogToken();
         ChangeEvents changes = session.getContentChanges(null, true, 1000);
         System.out.println("token: " + null + " total numbers: " +changes.getChangeEvents().size());
         System.out.println("New changes token: " + changes.getLatestChangeLogToken());
         changes = session.getContentChanges("27", true, 1000);
         System.out.println("token: " +"27" + " total numbers: " +changes.getChangeEvents().size());
         System.out.println("New changes token: " + changes.getLatestChangeLogToken());
         changes = session.getContentChanges("29", true, 1000);
         System.out.println("token: " +"28" + " total numbers: " +changes.getChangeEvents().size());
         System.out.println("New changes token: " + changes.getLatestChangeLogToken());
         changes = session.getContentChanges("28", true, 1000);
         System.out.println("token: " +"29" + " total numbers: " +changes.getChangeEvents().size());
         System.out.println("New changes token: " + changes.getLatestChangeLogToken());
         changes = session.getContentChanges(latestChangeLogToken, true, 1000);
         System.out.println("token: " +latestChangeLogToken + " total numbers: " +changes.getChangeEvents().size());
         System.out.println("New changes token: " + changes.getLatestChangeLogToken());
      } catch (final Exception e) {
         System.out.println("Given credentials are probably not correct! ");
         e.printStackTrace();
      }
   }
}
03-29-2011 08:16 PM
 
					
				
				
			
		
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.