Package org.exoplatform.services.jcr

Examples of org.exoplatform.services.jcr.RepositoryService


      ManageableRepository repository = null;
      try
      {
         repository = helper.createRepository(container, false, 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


   public void testRemove() throws Exception
   {
      ManageableRepository repository = helper.createRepository(container, false, null);

      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      service.removeRepository(repository.getConfiguration().getName());

      try
      {
         service.getRepository(repository.getConfiguration().getName());
      }
      catch (Exception e)
      {

      }
View Full Code Here

   public void testCreateAterRemoveCheckOldContent() throws Exception
   {
      ManageableRepository newRepository = null;
      try
      {
         RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
         RepositoryEntry repoEntry = helper.createRepositoryEntry(false, null, null, true);

         try
         {
            Class
               .forName("org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache");

            ArrayList cacheParams = new ArrayList();
            cacheParams.add(new SimpleParameterEntry("infinispan-configuration",
               "conf/standalone/cluster/test-infinispan-config.xml"));
            cacheParams.add(new SimpleParameterEntry("jgroups-configuration", "conf/udp-mux-v3.xml"));
            cacheParams.add(new SimpleParameterEntry("infinispan-cluster-name", "JCR-cluster-Test"));
            cacheParams.add(new SimpleParameterEntry("use-distributed-cache", "false"));
            CacheEntry cacheEntry = new CacheEntry(cacheParams);
            cacheEntry
               .setType("org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache");
            cacheEntry.setEnabled(true);

            ArrayList<WorkspaceEntry> wsList = repoEntry.getWorkspaceEntries();

            wsList.get(0).setCache(cacheEntry);
            repoEntry.setWorkspaceEntries(wsList);
         }
         catch (ClassNotFoundException e)
         {
         }

         service.createRepository(repoEntry);
         service.getConfig().retain();

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

         // add content
         Session session =
            repository.login(new CredentialsImpl("admin", "admin".toCharArray()), repository.getConfiguration()
               .getSystemWorkspaceName());
         session.getRootNode().addNode("test");
         session.save();
         session.logout();

         // copy repository configuration
         RepositoryEntry repositoryEntry = helper.copyRepositoryEntry(repository.getConfiguration());

         String newDatasourceName = helper.createDatasource();

         for (WorkspaceEntry ws : repositoryEntry.getWorkspaceEntries())
         {
            List<SimpleParameterEntry> parameters = ws.getContainer().getParameters();
            for (int i = 0; i <= parameters.size(); i++)
            {
               SimpleParameterEntry spe = parameters.get(i);
               if (spe.getName().equals("source-name"))
               {
                  parameters.add(i, new SimpleParameterEntry(spe.getName(), newDatasourceName));
                  break;
               }
            }
         }

         service.removeRepository(repository.getConfiguration().getName());

         try
         {
            service.getRepository(repository.getConfiguration().getName());
            fail();
         }
         catch (Exception e)
         {
         }

         // create new repository
         service.createRepository(repositoryEntry);
         service.getConfig().retain();

         newRepository = service.getRepository(repositoryEntry.getName());

         Session newSession = null;
         try
         {
            newSession =
View Full Code Here

         System.setProperty("java.security.auth.login.config", loginConf);

      StandaloneContainer.addConfigurationURL(containerConf);
      container = StandaloneContainer.getInstance();

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

      cservice = (CommandService)container.getComponentInstanceOfType(CommandService.class);

      // login via Authenticator
      Authenticator authr = (Authenticator)container.getComponentInstanceOfType(Authenticator.class);
      String validUser =
         authr.validateUser(new Credential[]{new UsernameCredential("root"), new PasswordCredential("exo")});
      Identity id = authr.createIdentity(validUser);
      ConversationState s = new ConversationState(id);
      ConversationState.setCurrent(s);

      ctx = new BasicAppContext(repService.getDefaultRepository());

      // System.out.println("CTX "+ctx);
   }
View Full Code Here

         System.setProperty("java.security.auth.login.config", loginConf);

      StandaloneContainer.addConfigurationURL(containerConf);
      container = StandaloneContainer.getInstance();

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

      cservice = (CommandService)container.getComponentInstanceOfType(CommandService.class);

      // we need to login (see BasicAppContext, 38) and set current item before ctx using
      if (ctx == null)
      {
         // login via Authenticator
         Authenticator authr = (Authenticator)container.getComponentInstanceOfType(Authenticator.class);
         String validUser =
            authr.validateUser(new Credential[]{new UsernameCredential("root"), new PasswordCredential("exo")});
         Identity id = authr.createIdentity(validUser);
         ConversationState s = new ConversationState(id);
         ConversationState.setCurrent(s);

         ctx = new CliAppContext(repService.getDefaultRepository(), PARAMETERS_KEY);
         Node root = ctx.getSession().getRootNode();
         ctx.setCurrentItem(root);
         if (root.hasNode("testJCRClientCommands") == false)
         {
            Node node = root.addNode("testJCRClientCommands").addNode("childOftestJCRClientCommands");
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, boolean isMultiDb, String dsName)
      throws Exception
   {
      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      RepositoryEntry repoEntry = createRepositoryEntry(isMultiDb, null, dsName, true);
      service.createRepository(repoEntry);
      service.getConfig().retain();

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

   }

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

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

      return createRepository(container, isMultiDb, 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

   @Deprecated
   public void createWorkspace(WorkspaceEntry workspaceEntry, ExoContainer container)
      throws RepositoryConfigurationException, RepositoryException
   {
      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      RepositoryImpl defRep;

      defRep = (RepositoryImpl)service.getDefaultRepository();
      defRep.configWorkspace(workspaceEntry);
      defRep.createWorkspace(workspaceEntry.getName());

   }
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.