Package org.exoplatform.services.jcr.config

Examples of org.exoplatform.services.jcr.config.RepositoryConfigurationException


         }
         return false;
      }
      catch (final SQLException e)
      {
         throw new RepositoryConfigurationException("Database exception. " + e, e);
      }
      catch (final NamingException e)
      {
         throw new RepositoryConfigurationException("JDNI exception. " + e, e);
      }
   }
View Full Code Here


            con.close();
         }
      }
      catch (final IOException e)
      {
         throw new RepositoryConfigurationException("Configuration read exception. " + e, e);
      }
      catch (final SQLException e)
      {
         throw new RepositoryConfigurationException("Database exception. " + e, e);
      }
      catch (final NamingException e)
      {
         throw new RepositoryConfigurationException("JDNI exception. " + e, e);
      }
   }
View Full Code Here

            con.close();
         }
      }
      catch (final IOException e)
      {
         throw new RepositoryConfigurationException("Configuration read exception. " + e, e);
      }
      catch (final SQLException e)
      {
         throw new RepositoryConfigurationException("Database exception. " + e + ". SQL: " + sql, e);
      }
      catch (final NamingException e)
      {
         throw new RepositoryConfigurationException("JDNI exception. " + e, e);
      }
   }
View Full Code Here

   public void init(Properties props) throws RepositoryConfigurationException, VCASException
   {
      final String sn = props.getProperty(JDBC_SOURCE_NAME_PARAM);
      if (sn == null)
      {
         throw new RepositoryConfigurationException(JDBC_SOURCE_NAME_PARAM + " parameter expected!");
      }

      try
      {
         dataSource = (DataSource)new InitialContext().lookup(sn);

         Connection conn = null;
         Statement st = null;
         try
         {
            conn = SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
            {
               public Connection run() throws Exception
               {
                  return dataSource.getConnection();
               }
            });

            DatabaseMetaData dbMetaData = conn.getMetaData();

            String dialect = props.getProperty(JDBC_DIALECT_PARAM);
            if (dialect == null || DBConstants.DB_DIALECT_AUTO.equalsIgnoreCase(dialect))
            {
               dialect = DialectDetecter.detect(dbMetaData);
            }
            this.dialect = dialect;

            // init database metadata
            String tn = props.getProperty(TABLE_NAME_PARAM);
            if (tn != null)
            {
               tableName = tn;
            }
            else
            {
               tableName = DEFAULT_TABLE_NAME;
            }

            // make error pattern for DB2
            String pattern = String.format(DB2_PK_CONSTRAINT_DETECT_PATTERN, tableName);

            DB2_PK_CONSTRAINT_DETECT = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);

            sqlConstraintPK = tableName + "_PK";

            sqlVCASIDX = tableName + "_IDX";

            if (DBConstants.DB_DIALECT_PGSQL.equalsIgnoreCase(dialect)
               || DBConstants.DB_DIALECT_PGSQL_SCS.equalsIgnoreCase(dialect)
               || DBConstants.DB_DIALECT_INGRES.equalsIgnoreCase(dialect))
            {
               // use lowercase for postgres/ingres metadata.getTable(), HSQLDB wants UPPERCASE
               // for other seems not matter
               tableName = tableName.toUpperCase().toLowerCase();
               sqlConstraintPK = sqlConstraintPK.toUpperCase().toLowerCase();
               sqlVCASIDX = sqlVCASIDX.toUpperCase().toLowerCase();
            }

            sqlAddRecord = "INSERT INTO " + tableName + " (PROPERTY_ID, ORDER_NUM, CAS_ID) VALUES(?,?,?)";
            sqlDeleteRecord = "DELETE FROM " + tableName + " WHERE PROPERTY_ID=?";
            sqlDeleteValueRecord = "DELETE FROM " + tableName + " WHERE PROPERTY_ID=? AND ORDER_NUM=?";
            sqlSelectRecord = "SELECT CAS_ID FROM " + tableName + " WHERE PROPERTY_ID=? AND ORDER_NUM=?";
            sqlSelectRecords = "SELECT CAS_ID, ORDER_NUM FROM " + tableName + " WHERE PROPERTY_ID=? ORDER BY ORDER_NUM";

            sqlSelectOwnRecords =
               "SELECT P.CAS_ID, P.ORDER_NUM, S.CAS_ID as SHARED_ID " + "FROM " + tableName + " P LEFT JOIN "
                  + tableName + " S ON P.PROPERTY_ID<>S.PROPERTY_ID AND P.CAS_ID=S.CAS_ID "
                  + "WHERE P.PROPERTY_ID=? GROUP BY P.CAS_ID, P.ORDER_NUM, S.CAS_ID ORDER BY P.ORDER_NUM";

            sqlSelectSharingProps =
               "SELECT DISTINCT C.PROPERTY_ID AS PROPERTY_ID FROM " + tableName + " C, " + tableName + " P "
                  + "WHERE C.CAS_ID=P.CAS_ID AND C.PROPERTY_ID<>P.PROPERTY_ID AND P.PROPERTY_ID=?";

            // check if table already exists
            if (!JDBCUtils.tableExists(tableName, conn))
            {
               st = conn.createStatement();

               // create table
               st.executeUpdate("CREATE TABLE " + tableName
                  + " (PROPERTY_ID VARCHAR(96) NOT NULL, ORDER_NUM INTEGER NOT NULL, CAS_ID VARCHAR(512) NOT NULL, "
                  + "CONSTRAINT " + sqlConstraintPK + " PRIMARY KEY(PROPERTY_ID, ORDER_NUM))");

               // create index on hash (CAS_ID)
               st.executeUpdate("CREATE INDEX " + sqlVCASIDX + " ON " + tableName + "(CAS_ID, PROPERTY_ID, ORDER_NUM)");

               if (LOG.isDebugEnabled())
               {
                  LOG.debug("JDBC Value Content Address Storage initialized in database " + sn);
               }
            }
            else if (LOG.isDebugEnabled())
            {
               LOG.debug("JDBC Value Content Address Storage already initialized in database " + sn);
            }
         }
         catch (SQLException e)
         {
            throw new VCASException("VCAS INIT database error: " + e, e);
         }
         finally
         {
            if (st != null)
            {
               try
               {
                  st.close();
               }
               catch (SQLException e)
               {
                  LOG.error("Can't close the Statement: " + e.getMessage());
               }
            }

            if (conn != null)
            {
               try
               {
                  conn.close();
               }
               catch (SQLException e)
               {
                  throw new VCASException("VCAS INIT database error on Connection close: " + e, e);
               }
            }
         }
      }
      catch (NamingException e)
      {
         throw new RepositoryConfigurationException("JDBC data source is not available in JNDI with name '" + sn
            + "'. Error: " + e, e);
      }
   }
View Full Code Here

            PrivilegedJBossCacheHelper.start(cache);
         }
      }
      else
      {
         throw new RepositoryConfigurationException("Cache configuration not found");
      }
     

      this.getNumLocks = new LockActionNonTxAware<Integer, Object>()
      {
View Full Code Here

               }
               catch (Throwable t)
               {
                  unregisterAllComponents();
                  parent.unregisterComponent(name);
                  throw new RepositoryConfigurationException("Can not register repository container " + name
                     + " in parent container.", t);
               }
               return null;
            }
         });
      }
      catch (PrivilegedActionException e)
      {
         Throwable ex = e.getCause();
         if (ex instanceof RepositoryConfigurationException)
         {
            throw (RepositoryConfigurationException)ex;
         }
         else
         {
            throw new RepositoryConfigurationException(ex.getMessage(), ex);
         }
      }
   }
View Full Code Here

                        .getComponentInstanceOfType(WorkspaceDataContainer.class)));
                  }
               }
               catch (ClassNotFoundException e)
               {
                  throw new RepositoryConfigurationException("Class not found for workspace data container "
                     + wsConfig.getUniqueName() + " : " + e, e);
               }

               // cache type
               try
               {
                  String className = wsConfig.getCache().getType();
                  if (className != null && className.length() > 0)
                  {
                     workspaceContainer.registerComponentImplementation(ClassLoading.forName(className,
                        RepositoryContainer.class));
                  }
                  else
                     workspaceContainer.registerComponentImplementation(LinkedWorkspaceStorageCacheImpl.class);
               }
               catch (ClassNotFoundException e)
               {
                  log.warn("Workspace cache class not found " + wsConfig.getCache().getType()
                     + ", will use default. Error : " + e.getMessage());
                  workspaceContainer.registerComponentImplementation(LinkedWorkspaceStorageCacheImpl.class);
               }

               if (workspaceContainer.getComponentInstanceOfType(RPCService.class) != null)
               {
                  workspaceContainer.registerComponentImplementation(WorkspaceResumer.class);
               }
               workspaceContainer.registerComponentImplementation(CacheableWorkspaceDataManager.class);
               workspaceContainer.registerComponentImplementation(LocalWorkspaceDataManagerStub.class);
               workspaceContainer.registerComponentImplementation(ObservationManagerRegistry.class);

               if (wsConfig.getLockManager() != null && wsConfig.getLockManager().getType() != null)
               {
                  try
                  {
                     final Class<?> lockManagerType =
                        ClassLoading.forName(wsConfig.getLockManager().getType(), RepositoryContainer.class);
                     workspaceContainer.registerComponentImplementation(lockManagerType);
                  }
                  catch (ClassNotFoundException e)
                  {
                     throw new RepositoryConfigurationException("Class not found for workspace lock manager "
                        + wsConfig.getLockManager().getType() + ", container " + wsConfig.getUniqueName() + " : " + e,
                        e);
                  }
               }
               else
               {
                  throw new RepositoryConfigurationException(
                     "The configuration of lock manager is expected in container " + wsConfig.getUniqueName());
               }

               // Query handler
               if (wsConfig.getQueryHandler() != null)
               {
                  workspaceContainer.registerComponentImplementation(SearchManager.class);
                  workspaceContainer.registerComponentImplementation(QueryManager.class);
                  workspaceContainer.registerComponentImplementation(QueryManagerFactory.class);
                  workspaceContainer.registerComponentInstance(wsConfig.getQueryHandler());
                  if (isSystem)
                  {
                     workspaceContainer.registerComponentImplementation(SystemSearchManager.class);
                  }
               }

               // access manager
               if (wsConfig.getAccessManager() != null && wsConfig.getAccessManager().getType() != null)
               {
                  try
                  {
                     final Class<?> am = ClassLoading.forName(wsConfig.getAccessManager().getType(), RepositoryContainer.class);
                     workspaceContainer.registerComponentImplementation(am);
                  }
                  catch (ClassNotFoundException e)
                  {
                     throw new RepositoryConfigurationException(
                        "Class not found for workspace access manager " + wsConfig.getAccessManager().getType()
                           + ", container " + wsConfig.getUniqueName() + " : " + e, e);
                  }
               }

               // initializer
               final Class<?> initilizerType;
               if (wsConfig.getInitializer() != null && wsConfig.getInitializer().getType() != null)
               {
                  // use user defined
                  try
                  {
                     initilizerType = ClassLoading.forName(wsConfig.getInitializer().getType(), RepositoryContainer.class);
                  }
                  catch (ClassNotFoundException e)
                  {
                     throw new RepositoryConfigurationException("Class not found for workspace initializer "
                        + wsConfig.getInitializer().getType() + ", container " + wsConfig.getUniqueName() + " : " + e,
                        e);
                  }
               }
               else
               {
                  // use default
                  initilizerType = ScratchWorkspaceInitializer.class;
               }
               workspaceContainer.registerComponentImplementation(initilizerType);
               workspaceContainer.registerComponentImplementation(TransactionableResourceManager.class);
               workspaceContainer.registerComponentImplementation(SessionFactory.class);
               final LocalWorkspaceDataManagerStub wsDataManager =
                  (LocalWorkspaceDataManagerStub)workspaceContainer
                     .getComponentInstanceOfType(LocalWorkspaceDataManagerStub.class);

               if (isSystem)
               {
                  // system workspace
                  systemDataManager = wsDataManager;
                  registerComponentInstance(systemDataManager);
               }

               wsDataManager.setSystemDataManager(systemDataManager);

               if (!config.getWorkspaceEntries().contains(wsConfig))
                  config.getWorkspaceEntries().add(wsConfig);
               return null;
            }
         });

      }
      catch (PrivilegedActionException pae)
      {
         Throwable cause = pae.getCause();
         if (cause instanceof RepositoryConfigurationException)
         {
            throw (RepositoryConfigurationException)cause;
         }
         else if (cause instanceof RepositoryException)
         {
            throw (RepositoryException)cause;
         }
         else if (cause instanceof RuntimeException)
         {
            RuntimeException e = (RuntimeException)cause;
            int depth = 0;
            Throwable retval = e;
            while (retval.getCause() != null && depth < 100)
            {
               retval = retval.getCause();
               if (retval instanceof RepositoryException)
               {
                  throw new RepositoryException(retval.getMessage(), e);
               }
               else if (retval instanceof RepositoryConfigurationException)
               {
                  throw new RepositoryConfigurationException(retval.getMessage(), e);
               }
               else if (retval instanceof NameNotFoundException)
               {
                  throw new RepositoryException(retval.getMessage(), e);
               }
View Full Code Here

                     ClassLoading.forName(config.getAuthenticationPolicy(), RepositoryContainer.class);
                  registerComponentImplementation(authenticationPolicyClass);
               }
               catch (ClassNotFoundException e)
               {
                  throw new RepositoryConfigurationException("Class not found for repository authentication policy: "
                     + e, e);
               }

               // Repository
               final RepositoryImpl repository = new RepositoryImpl(RepositoryContainer.this);
View Full Code Here

         security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
      }

      if (repositoryContainers.containsKey(rEntry.getName()))
      {
         throw new RepositoryConfigurationException("Repository container " + rEntry.getName() + " already started");
      }

      final RepositoryContainer repositoryContainer =
         new RepositoryContainer(parentContainer, rEntry, addNamespacesPlugins);

      // Storing and starting the repository container under
      // key=repository_name
      try
      {
         if (repositoryContainers.putIfAbsent(rEntry.getName(), repositoryContainer) == null)
         {
            SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
            {
               public Void run()
               {
                  repositoryContainer.start();
                  return null;
               }
            });
         }
         else
         {
            throw new RepositoryConfigurationException("Repository container " + rEntry.getName() + " already started");
         }
      }
      catch (Throwable t) //NOSONAR
      {
         repositoryContainers.remove(rEntry.getName());

         throw new RepositoryConfigurationException("Repository container " + rEntry.getName() + " was not started.", t);
      }

      if (!config.getRepositoryConfigurations().contains(rEntry))
      {
         config.getRepositoryConfigurations().add(rEntry);
View Full Code Here

         security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
      }

      if (!repositoryContainers.containsKey(repositoryName))
      {
         throw new RepositoryConfigurationException("Repository is not configured. Name " + repositoryName);
      }
      currentRepositoryName.set(repositoryName);
   }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.config.RepositoryConfigurationException

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.