Package org.exoplatform.services.jcr.core

Examples of org.exoplatform.services.jcr.core.ManageableRepository


      List<DataRestore> dataRestorer = new ArrayList<DataRestore>();

      List<WorkspaceContainerFacade> workspacesWaits4Resume = new ArrayList<WorkspaceContainerFacade>();
      try
      {
         ManageableRepository repository = repositoryService.getRepository(repositoryName);

         if (wEntry.getContainer().getParameterBoolean("multi-db") == false)
         {
            for (String wsName : repository.getWorkspaceNames())
            {
               WorkspaceContainerFacade wsContainer = repository.getWorkspaceContainer(wsName);
               wsContainer.setState(ManageableRepository.SUSPENDED);

               workspacesWaits4Resume.add(wsContainer);
            }
         }
         else
         {
            WorkspaceContainerFacade wsContainer = repository.getWorkspaceContainer(wEntry.getName());

            wsContainer.setState(ManageableRepository.SUSPENDED);
            workspacesWaits4Resume.add(wsContainer);
         }

         // get all restorers
         List<Backupable> backupable =
                  repository.getWorkspaceContainer(wEntry.getName())
               .getComponentInstancesOfType(Backupable.class);

         File storageDir = backupChainLog.getBackupConfig().getBackupDir();
         File fullBackupDir = JCRRestore.getFullBackupFile(storageDir);

         DataRestoreContext context = new DataRestoreContext(
                  new String[] {DataRestoreContext.STORAGE_DIR},
                  new Object[] {fullBackupDir});

         for (Backupable component : backupable)
         {
            dataRestorer.add(component.getDataRestorer(context));
         }

         for (DataRestore restorer : dataRestorer)
         {
            restorer.clean();
         }

         for (DataRestore restorer : dataRestorer)
         {
            restorer.restore();
         }
        
         for (DataRestore restorer : dataRestorer)
         {
            restorer.commit();
         }

         for (WorkspaceContainerFacade wsContainer : workspacesWaits4Resume)
         {
            wsContainer.setState(ManageableRepository.ONLINE);
         }

         // incremental restore
         DataManager dataManager =
                  (WorkspacePersistentDataManager) repository.getWorkspaceContainer(wEntry.getName()).getComponent(
                           WorkspacePersistentDataManager.class);

         FileCleanerHolder fileCleanHolder =
                  (FileCleanerHolder) repository.getWorkspaceContainer(wEntry.getName())
               .getComponent(FileCleanerHolder.class);

         JCRRestore restorer = new JCRRestore(dataManager, fileCleanHolder.getFileCleaner());
         for (File incrBackupFile : JCRRestore.getIncrementalFiles(storageDir))
         {
View Full Code Here


      String errorMessage = new String();
      Status status;

      try
      {
         ManageableRepository repository = repositoryService.getRepository(repositoryName);

         if (forseSessionClose)
         {
            forceCloseSession(repositoryName, workspaceName);
         }

         if (repository.canRemoveWorkspace(workspaceName))
         {
            repository.removeWorkspace(workspaceName);
            repositoryService.getConfig().retain(); // save configuration to persistence (file or persister)
            return Response.ok().build();
         }
         return Response.status(Status.CONFLICT).entity(
            "Can't remove workspace " + workspaceName + " in repository " + repositoryName).cacheControl(NO_CACHE)
View Full Code Here

    *           will be generate RepositoryException
    */
   private int forceCloseSession(String repositoryName, String workspaceName) throws RepositoryException,
      RepositoryConfigurationException
   {
      ManageableRepository mr = repositoryService.getRepository(repositoryName);
      WorkspaceContainerFacade wc = mr.getWorkspaceContainer(workspaceName);

      SessionRegistry sessionRegistry = (SessionRegistry)wc.getComponent(SessionRegistry.class);

      return sessionRegistry.closeSessions(workspaceName);
   }
View Full Code Here

    *           will be generated RepositoryConfigurationException
    */
   private BackupCreator initWorkspaceBackup(String repositoryName, String workspaceName) throws RepositoryException,
      RepositoryConfigurationException
   {
      ManageableRepository manageableRepository = repoService.getRepository(repositoryName);
      BackupCreator backupCreator = new BackupCreator(backupDelayTime, workspaceName, backupDir, manageableRepository);
      return backupCreator;
   }
View Full Code Here

         }

         String repositoryName = nodeReference.getRepository();
         if (repositoryName != null && repositoryName.length() > 0)
         {
            ManageableRepository repository = repositoryService.getRepository(repositoryName);
            sessionProvider.setCurrentRepository(repository);
         }

         String workspaceName = nodeReference.getWorkspace();
         if (workspaceName != null && workspaceName.length() > 0)
View Full Code Here

      }

      registerNodeTypes(rEntry.getName());

      // turn on Repository ONLINE
      ManageableRepository mr =
         (ManageableRepository)repositoryContainer.getComponentInstanceOfType(ManageableRepository.class);
      mr.setState(ManageableRepository.ONLINE);
   }
View Full Code Here

    * @return a session
    * @throws RepositoryException any repository exception
    */
   protected final Session openSession() throws RepositoryException
   {
      ManageableRepository repo = lifeCycle.manager.repositoryService.getCurrentRepository();
      return repo.getSystemSession(lifeCycle.getWorkspaceName());
   }
View Full Code Here

      }

      registerNodeTypes(rEntry.getName());

      // turn on Repository ONLINE
      ManageableRepository mr =
         (ManageableRepository)repositoryContainer.getComponentInstanceOfType(ManageableRepository.class);
      mr.setState(ManageableRepository.ONLINE);
   }
View Full Code Here

   @SuppressWarnings("unchecked")
   private void initBasePath(String repository) throws Exception
   {
      Session session = null;
      ManageableRepository manageableRepository = jcrService_.getRepository(repository);
      String defaultWorkspace = manageableRepository.getConfiguration().getDefaultWorkspaceName();
      String systemWorkspace = manageableRepository.getConfiguration().getSystemWorkspaceName();
      boolean isSameWorksapce = defaultWorkspace.equalsIgnoreCase(systemWorkspace);
      String[] workspaceNames = manageableRepository.getWorkspaceNames();
      for (AddPathPlugin pathPlugin : pathPlugins_)
      {
         HierarchyConfig hierarchyConfig = pathPlugin.getPaths();
         List<JcrPath> jcrPaths = hierarchyConfig.getJcrPaths();
         for (String workspaceName : workspaceNames)
         {
            if (!isSameWorksapce && workspaceName.equalsIgnoreCase(systemWorkspace))
               continue;
            session = manageableRepository.getSystemSession(workspaceName);
            Node rootNode = session.getRootNode();
            for (JcrPath jcrPath : jcrPaths)
            {
               String nodeType = jcrPath.getNodeType();
               if (nodeType == null || nodeType.length() == 0)
View Full Code Here

      return userAppNode;
   }

   public Node getPublicApplicationNode(SessionProvider sessionProvider) throws Exception
   {
      ManageableRepository currentRepo = jcrService_.getCurrentRepository();
      Session session =
         getSession(sessionProvider, currentRepo, currentRepo.getConfiguration().getDefaultWorkspaceName());
      Node rootNode = session.getRootNode();
      String publicApplication = getJcrPath(PUBLIC_APPLICATION);
      session.logout();
      return rootNode.getNode(publicApplication.substring(1, publicApplication.length()));
   }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.core.ManageableRepository

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.