Package org.exoplatform.services.jcr.config

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


      {
         key = new ConfigurationKey(cfg);
      }
      catch (CloneNotSupportedException e)
      {
         throw new RepositoryConfigurationException("Cannot clone the configuration.", e);
      }

      if (caches.containsKey(key))
      {
         CacheInstance cacheInstance = caches.get(key);
View Full Code Here


         security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
      }

      if (isWorkspaceInitialized(wsConfig.getName()))
      {
         throw new RepositoryConfigurationException("Workspace '" + wsConfig.getName()
            + "' is presumably initialized. config canceled");
      }

      try
      {
         repositoryContainer.registerWorkspace(wsConfig);
      }
      catch (RepositoryConfigurationException e)
      {
         final WorkspaceContainer workspaceContainer = repositoryContainer.getWorkspaceContainer(wsConfig.getName());
         SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
         {
            public Void run()
            {
               repositoryContainer.unregisterComponentByInstance(workspaceContainer);
               repositoryContainer.unregisterComponent(wsConfig.getName());
               return null;
            }
         });
         throw new RepositoryConfigurationException(e);
      }
      catch (RepositoryException e)
      {
         final WorkspaceContainer workspaceContainer = repositoryContainer.getWorkspaceContainer(wsConfig.getName());
         SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
View Full Code Here

      {
         script = DBInitializerHelper.readScriptResource(scriptsPath);
      }
      catch (IOException e)
      {
         throw new RepositoryConfigurationException("Can not read script file " + scriptsPath, e);
      }

      List<String> scripts = new ArrayList<String>();
      for (String query : DBInitializerHelper.scripts(script))
      {
View Full Code Here

               // can be only one storage with given id
               for (ValueStoragePlugin vsp : this)
               {
                  if (vsp.getId().equals(storageEntry.getId()))
                  {
                     throw new RepositoryConfigurationException("Value storage with ID '" + storageEntry.getId()
                        + "' already exists");
                  }
               }

               Object o = null;
View Full Code Here

         // MULTIDB
         if (!wsEntry.getContainer().getParameterValue(MULTIDB)
            .equals(wsConfig.getContainer().getParameterValue(MULTIDB)))
         {
            throw new RepositoryConfigurationException("All workspaces must be " + MULTIDB + " or " + SINGLEDB
               + ". But " + wsEntry.getName() + "- multi-db=" + wsEntry.getContainer().getParameterValue(MULTIDB)
               + " and " + wsConfig.getName() + "- multi-db=" + wsConfig.getContainer().getParameterValue(MULTIDB));
         }

         isMulti = Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));

         // source name
         String wsSourceName = null;
         String newWsSourceName = null;
         try
         {
            wsSourceName = wsEntry.getContainer().getParameterValue("sourceName");
            newWsSourceName = wsConfig.getContainer().getParameterValue("sourceName");
         }
         catch (RepositoryConfigurationException e)
         {
         }

         if (wsSourceName != null && newWsSourceName != null)
         {
            if (isMulti)
            {
               if (wsSourceName.equals(newWsSourceName))
               {
                  throw new RepositoryConfigurationException("SourceName " + wsSourceName + " alredy in use in "
                     + wsEntry.getName() + ". SourceName must be different in " + MULTIDB
                     + ". Check configuration for " + wsConfig.getName());
               }
            }
            else
            {
               if (!wsSourceName.equals(newWsSourceName))
               {
                  throw new RepositoryConfigurationException("SourceName must be equals in " + SINGLEDB + " "
                     + "repository." + " Check " + wsEntry.getName() + " and " + wsConfig.getName());
               }
            }
            continue;
         }

         // db-url
         String wsUri = null;
         String newWsUri = null;
         try
         {
            wsUri = wsEntry.getContainer().getParameterValue("db-url");
            newWsUri = wsConfig.getContainer().getParameterValue("db-url");
         }
         catch (RepositoryConfigurationException e)
         {
         }

         if (wsUri != null && newWsUri != null)
         {
            if (isMulti)
            {
               if (wsUri.equals(newWsUri))
               {
                  throw new RepositoryConfigurationException("db-url  " + wsUri + " alredy in use in "
                     + wsEntry.getName() + ". db-url must be different in " + MULTIDB + ". Check configuration for "
                     + wsConfig.getName());

               }
            }
            else
            {
               if (!wsUri.equals(newWsUri))
               {
                  throw new RepositoryConfigurationException("db-url must be equals in " + SINGLEDB + " "
                     + "repository." + " Check " + wsEntry.getName() + " and " + wsConfig.getName());
               }
            }
         }
      }
View Full Code Here

                  {
                     backupDirs.add(zipFile);
                  }
                  else
                  {
                     throw new RepositoryConfigurationException("There is no backup data for value storage with id "
                        + valueStorage.getId());
                  }
               }
            }
View Full Code Here

      {
         script = DBInitializerHelper.readScriptResource(scriptsPath);
      }
      catch (IOException e)
      {
         throw new RepositoryConfigurationException("Can not read script file " + scriptsPath, e);
      }

      String sql = null;
      for (String query : DBInitializerHelper.scripts(script))
      {
         String q = DBInitializerHelper.cleanWhitespaces(query);
         if (q.contains(objectName))
         {
            if (sql != null)
            {
               throw new RepositoryConfigurationException("Can't find unique script for object creation. Object name: "
                  + objectName);
            }

            sql = q;
         }
      }

      if (sql != null)
      {
         return sql;
      }

      throw new RepositoryConfigurationException("Script for object creation is not found. Object name: " + objectName);
   }
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_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);
      }
   }
View Full Code Here

      if (sourceNameParam == null)
      {
         sourceNameParam = params.getProperty("sourceName"); // try old, pre 1.9 name
         if (sourceNameParam == null)
         {
            throw new RepositoryConfigurationException("Repository service configuration. Source name ("
               + PARAM_SOURCE_NAME + ") is expected");
         }
      }
      this.sourceName = sourceNameParam;

      String dialect = params.getProperty(PARAM_DIALECT);
      if (dialect == null || DBConstants.DB_DIALECT_AUTO.equalsIgnoreCase(dialect))
      {
         Connection conn = null;
         try
         {
            conn = openConnection();
            dialect = DialectDetecter.detect(conn.getMetaData());
         }
         catch (NamingException e)
         {
            throw new RepositoryConfigurationException(e);
         }
         catch (SQLException e)
         {
            throw new RepositoryConfigurationException(e);
         }
         finally
         {
            if (conn != null)
            {
               try
               {
                  conn.close();
               }
               catch (SQLException e)
               {
                  throw new RepositoryConfigurationException(e);
               }
            }
         }
      }
View Full Code Here

   protected void checkInitialized() throws RepositoryConfigurationException
   {
      if (sourceName == null)
      {
         throw new RepositoryConfigurationException(
            "Repository service configuration persister isn not initialized. Call init() before.");
      }
   }
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.