Package org.exoplatform.services.jcr

Examples of org.exoplatform.services.jcr.RepositoryService


   public void testAddValuesInDifferentVs() throws Exception
   {
      int WORKSPACE_COUNT = 3;
      int NODES_COUNT = 5;
      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      RepositoryImpl defRep = null;

      defRep = (RepositoryImpl)service.getDefaultRepository();
      Random random = new Random();
      for (int i = 0; i < WORKSPACE_COUNT; i++)
      {
         String currwsName = createWs();
         Session currenSession = defRep.getSystemSession(currwsName);
View Full Code Here


      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

      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()));
        
         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

   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

   protected static Log log = ExoLogger.getLogger("exo.jcr.component.core.JCRTest");

   public void _testRepositoryServiceRegistration() throws Exception
   {
      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      assertNotNull(service);
      RepositoryImpl defRep = (RepositoryImpl)service.getRepository();
      assertNotNull(defRep);
      String sysWs = defRep.getSystemWorkspaceName();
      assertFalse("Sys ws should not be    initialized for this test!!", defRep.isWorkspaceInitialized(sysWs)); // Default Namespaces
      // and NodeTypes
      NamespaceRegistry nsReg = defRep.getNamespaceRegistry();
View Full Code Here

   }

   public void _testInitSystemWorkspace() throws Exception
   {

      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      RepositoryImpl defRep = (RepositoryImpl)service.getRepository();
      String sysWs = defRep.getSystemWorkspaceName();
      assertFalse("Sys ws should not be initialized for this test!!", defRep.isWorkspaceInitialized(sysWs));

      // TODO
      // defRep.initWorkspace(sysWs, "nt:unstructured");
View Full Code Here

   }

   public void testInitRegularWorkspace() throws Exception
   {

      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      RepositoryImpl defRep = (RepositoryImpl)service.getDefaultRepository();
      String sysWs = defRep.getSystemWorkspaceName();

      String[] names = defRep.getWorkspaceNames();
      String wsName = null;
      for (int i = 0; i < names.length; i++)
View Full Code Here

      }
   }

   private void doTestOnWorkspace(String wsName) throws RepositoryException, RepositoryConfigurationException
   {
      RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      Session sess = service.getDefaultRepository().getSystemSession(wsName);

      Node root2 = sess.getRootNode();
      assertNotNull(root2);

      Node node1 = root2.getNode("node1");
View Full Code Here

      }

      SessionProviderService sessionProviderService =
         (SessionProviderService)container.getComponentInstanceOfType(SessionProviderService.class);

      RepositoryService repositoryService =
         (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      CommandService commandService = (CommandService)container.getComponentInstanceOfType(CommandService.class);

      GenericWebAppContext ctx;
      try
      {
         ctx =
            new GenericWebAppContext(getServletContext(), request, response, sessionProviderService
               .getSessionProvider(null), // null for
               // ThreadLocalSessionProvider
               repositoryService.getDefaultRepository());
      }
      catch (final RepositoryException e)
      {
         throw new IOException()
         {
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.