Package org.exoplatform.services.jcr

Examples of org.exoplatform.services.jcr.RepositoryService


        private ThreadLocal<SessionProvider> provider = new ThreadLocal<SessionProvider>();

        public AbstractSessionLifeCycle() {
            try {
                ExoContainer container = ExoContainerContext.getCurrentContainer();
                RepositoryService repoService = (RepositoryService) container.getComponentInstanceOfType(RepositoryService.class);
                repository = repoService.getRepository(REPOSITORY_NAME);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
View Full Code Here


    * @throws RepositoryConfigurationException
    */
   public void removeRepository(ExoContainer container, String repositoryName) throws RepositoryException,
      RepositoryConfigurationException
   {
      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);

      ManageableRepository mr = service.getRepository(repositoryName);
      for (String wsName : mr.getWorkspaceNames())
      {
         WorkspaceContainerFacade wc = mr.getWorkspaceContainer(wsName);
         SessionRegistry sessionRegistry = (SessionRegistry)wc.getComponent(SessionRegistry.class);
         sessionRegistry.closeSessions(wsName);
      }

      service.removeRepository(repositoryName);
   }
View Full Code Here

   }

   public ManageableRepository createRepository(ExoContainer container, DatabaseStructureType dbStructureType,
      String dsName) throws Exception
   {
      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      RepositoryEntry repoEntry = createRepositoryEntry(dbStructureType, null, dsName, true);
      service.createRepository(repoEntry);
      service.getConfig().retain();

      return service.getRepository(repoEntry.getName());
   }
View Full Code Here

   }

   public ManageableRepository createRepository(ExoContainer container, DatabaseStructureType dbStructureType,
      boolean cacheEnabled, boolean cacheShared) throws Exception
   {
      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      RepositoryEntry repoEntry = createRepositoryEntry(dbStructureType, null, null, cacheEnabled, cacheShared);
      service.createRepository(repoEntry);
      service.getConfig().retain();

      return service.getRepository(repoEntry.getName());
   }
View Full Code Here

      return createRepository(container, dbStructureType, cacheEnabled, false);
   }

   public ManageableRepository createRepository(ExoContainer container, RepositoryEntry repoEntry) throws Exception
   {
      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      service.createRepository(repoEntry);

      return service.getRepository(repoEntry.getName());
   }
View Full Code Here

   }
  
   public void testCreateRepositoryAfterFailRestoreOnSystemWS() throws Exception
   {
      // create repository
      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      String dsName = helper.createDatasource();
      RepositoryEntry repoEntry = helper.createRepositoryEntry(DatabaseStructureType.SINGLE, null, dsName);
      service.createRepository(repoEntry);

      ManageableRepository repository = service.getRepository(repoEntry.getName());

      WorkspaceEntry wsEntry = helper.createWorkspaceEntry(DatabaseStructureType.SINGLE, dsName);
      helper.addWorkspace(repository, wsEntry);
      service.getConfig().retain();

      addConent(repository, repository.getConfiguration().getSystemWorkspaceName());

      // backup
      File backDir = new File("target/backup/" + IdGenerator.generate());
View Full Code Here

   }

   public void testCreateRepositoryAfterFailRestoreOnNonSystemWS() throws Exception
   {
      // create repository
      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      String dsName = helper.createDatasource();
      RepositoryEntry repoEntry = helper.createRepositoryEntry(DatabaseStructureType.SINGLE, null, dsName);
      service.createRepository(repoEntry);

      ManageableRepository repository = service.getRepository(repoEntry.getName());

      WorkspaceEntry wsEntry = helper.createWorkspaceEntry(DatabaseStructureType.SINGLE, dsName);
      helper.addWorkspace(repository, wsEntry);
      service.getConfig().retain();

      addConent(repository, wsEntry.getName());

      // backup
      File backDir = new File("target/backup/" + IdGenerator.generate());
View Full Code Here

   }

   public void testCreateRepositoryAfterFailRestoreWithFailConfiguration() throws Exception
   {
      // create repository
      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      String dsName = helper.createDatasource();
      RepositoryEntry repoEntry = helper.createRepositoryEntry(DatabaseStructureType.SINGLE, null, dsName);
      service.createRepository(repoEntry);

      ManageableRepository repository = service.getRepository(repoEntry.getName());

      WorkspaceEntry wsEntry = helper.createWorkspaceEntry(DatabaseStructureType.SINGLE, dsName);
      helper.addWorkspace(repository, wsEntry);
      service.getConfig().retain();

      addConent(repository, wsEntry.getName());

      // backup
      File backDir = new File("target/backup/" + IdGenerator.generate());
View Full Code Here

      ManageableRepository repository = null;
      try
      {
         repository = helper.createRepository(container, DatabaseStructureType.SINGLE, null);

         RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);

         SessionImpl session =
            (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());

         assertFalse(service.canRemoveRepository(repository.getConfiguration().getName()));
         session.logout();
         assertTrue(service.canRemoveRepository(repository.getConfiguration().getName()));
      }
      finally
      {
         if (repository != null)
         {
View Full Code Here

      ManageableRepository repository = null;
      try
      {
         repository = helper.createRepository(container, DatabaseStructureType.SINGLE, null);

         RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);

         SessionImpl session =
            (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());

         assertFalse(service.canRemoveRepository(repository.getConfiguration().getName()));

         try
         {
            service.removeRepository(repository.getConfiguration().getName(), false);
            fail();
         }
         catch (RepositoryException e)
         {
            //ok
         }

         try
         {
            service.removeRepository(repository.getConfiguration().getName(), true);
            repository = null;
         }
         catch (RepositoryException e)
         {
            fail("Repository should be removed with opened sessions.");
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.RepositoryService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.