Package com.dotmarketing.exception

Examples of com.dotmarketing.exception.DotDataException


        Folder parentFolder;
        try {
            parentFolder = folderAPI.findParentFolder(this, APILocator.getUserAPI().getSystemUser(), false);
        } catch (Exception e) {
            Logger.error(Folder.class, e.getMessage(), e);
            throw new DotDataException(e.getMessage(), e);
        }
        if(parentFolder != null)
            return parentFolder;

        try {
View Full Code Here


    } catch (Exception e) {
        /*try {
            conn.rollback();
        }
        catch(SQLException ex) {}*/
      throw new DotDataException(e.getMessage(), e);
    }
    finally {
        try {
            conn.close();
        }
        catch(SQLException ex) {
            throw new DotDataException(ex.getMessage(), ex);
        }
    }
     
    List<String> schemaList = new ArrayList<String>();

    //Execute the SQL Script in accordance with the database type
    if(DbConnectionFactory.isPostgres()){
      schemaList = SQLUtil.tokenize(getPostgresScript());
    }else if(DbConnectionFactory.isMySql()){
      schemaList = SQLUtil.tokenize(getMySQLScript());
    }else if(DbConnectionFactory.isOracle()){
      schemaList = SQLUtil.tokenize(getOracleScript());
    }else if(DbConnectionFactory.isMsSql()) {
      schemaList = SQLUtil.tokenize(getMSSQLScript());
    }else {
        schemaList = SQLUtil.tokenize(getH2Script());
    }

    try {
        conn = DbConnectionFactory.getDataSource().getConnection();
            conn.setAutoCommit(false);
       
      if(DbConnectionFactory.isMySql()){
        dc.executeStatement("SET storage_engine=INNODB", conn);
      }else if(DbConnectionFactory.isMsSql()){
        dc.executeStatement("SET TRANSACTION ISOLATION LEVEL READ COMMITTED;", conn);
      }
     
      for (String query : schemaList) {
                if(!runInSingleTransaction){
                    try {
                        HibernateUtil.startTransaction();
                        dc.executeStatement(query);
                    } catch (Exception e) {
                        Logger.error(this, "Unable to execute query : " + query);
                        HibernateUtil.rollbackTransaction();
                        continue;
                    }
                    HibernateUtil.commitTransaction();
                } else {
                    try {
                        dc.executeStatement(query, conn);
                    } catch (SQLException e) {
                        Logger.fatal(this, "Unable to execute SQL upgrade", e);
                        throw new DotDataException(e.getMessage(), e);
                    }
                }
            }
     
      conn.commit();
    } catch (SQLException e) {
        try {
                conn.rollback();
            } catch (SQLException e1) {
                throw new DotDataException(e1.getMessage(), e1);
            }
      Logger.fatal(this, "Unable to execute SQL upgrade", e);
      throw new DotDataException(e.getMessage(), e);
    }
    finally {
        try {
                conn.close();
            } catch (SQLException e) {
                throw new DotDataException(e.getMessage(), e);
            }
    }
   
    try {
        conn = DbConnectionFactory.getDataSource().getConnection();
            conn.setAutoCommit(true);
   
      if (foreignKeys!=null && rebuildForeignKeys) {
        for (ForeignKey key:foreignKeys) {
          try {
            createConstraint(conn, key);
          } catch (SQLException e) {
            Logger.error(AbstractJDBCStartupTask.class,"SQLException: " +e.getMessage());
          }
        }
      }

      if (indexes!=null && rebuildIndices) {
        idxfor: for (Index index:indexes) {
          try {
            for (PrimaryKey pk:primaryKeys) {
              if(index.tableName.equalsIgnoreCase(pk.tableName) && index.indexName.equalsIgnoreCase(pk.keyName)) {
                continue idxfor;
              }
            }
            createIndex(conn, index);
          } catch (SQLException e) {
              Logger.warn(this, "can't create index on table "+index.tableName+" columns "+getColumnList(index.columnNames)+" message "+e.getMessage());
          }
        }
      }

      if (primaryKeys!=null && rebuildPrimaryKeys) {
        for (PrimaryKey key:primaryKeys) {
          try {
            createPrimaryKey(conn, key);
          } catch (SQLException e) {
              Logger.warn(this, "can't create primary key on table "+key.tableName+" columns "+getColumnList(key.columnNames)+" message "+e.getMessage());
          }
        }
      }
      } catch (SQLException e) {
            Logger.fatal(this, "Unable to execute SQL upgrade", e);
            throw new DotDataException(e.getMessage(), e);
        }
        finally {
            try {
                conn.close();
            } catch (SQLException e) {
                throw new DotDataException(e.getMessage(), e);
            }
        }
  }
View Full Code Here

        //ReindexThread.startThread(Config.getIntProperty("REINDEX_THREAD_SLEEP", 500), Config.getIntProperty("REINDEX_THREAD_INIT_DELAY", 5000));
     
    } catch (Exception e) {
      HibernateUtil.rollbackTransaction();
      Logger.fatal(this, "Unable to execute the upgrade task : " + name, e);
      throw new DotDataException("Unable to execute startup task : ",e);
    } finally {
      // This will commit the changes and close the connection
      HibernateUtil.closeSession();
     
      // DOTCMS-4352
      try {
        if(conn != null && !conn.isClosed()){
          Statement s1 = conn.createStatement();
          if(DbConnectionFactory.isMySql()){
            s1.execute(commit);
          }
          if(!conn.getAutoCommit()){
            conn.commit();
          }
          conn.close();
        }
      } catch (Exception e) {
        Logger.debug(StartupTasksExecutor.class, "Exception: "
            + e.getMessage(), e);
        throw new DotDataException(
            "Exception finishing upgrade tasks: " + e.getMessage(),
            e);
      }
      Logger.info(this, "Finishing upgrade tasks.");
    }
View Full Code Here

    try {
      FileAsset file = saveFile(user,host,uploadedFile,folderPath, title);
      contentlet.setStringProperty(field.getVelocityVarName(), file.getIdentifier());
    } catch (Exception e) {
      Logger.error(SubmitContentUtil.class, e.getMessage());
      throw new DotDataException("File could not be saved. "+e.getMessage());
    }
  }
View Full Code Here

    if(UtilMethods.isSet(userId)){
      try {
        user = APILocator.getUserAPI().loadUserById(userId,APILocator.getUserAPI().getSystemUser(),false);
      } catch (Exception e) {
        Logger.error(SubmitContentUtil.class, e.getMessage(), e);
        throw new DotDataException(e.getMessage(), e);
      }
    }else{
      user = APILocator.getUserAPI().getAnonymousUser();
    }
View Full Code Here

      FileAsset file = saveFile(user,host,uploadedFile,folderPath, title);
      conAPI.setContentletProperty(contentlet, field, ((FileAsset)file).getIdentifier());
      return contentlet;
    } catch (Exception e) {
      Logger.error(SubmitContentUtil.class, e.getMessage());
      throw new DotDataException("File could not be saved. "+e.getMessage());
    }
  }
View Full Code Here

 
 
  @Override
  public Template copyTemplate(Template currentTemplate, Host host) throws DotDataException, DotSecurityException {
    if(currentTemplate ==null){
      throw new DotDataException("Template is null");
    }
    Template newTemplate = new Template();

    try {
      BeanUtils.copyProperties(newTemplate, currentTemplate);
    } catch (Exception e1) {
      Logger.error(TemplateFactoryImpl.class,e1.getMessage(),e1);
      throw new DotDataException(e1.getMessage());
    }
    newTemplate.setInode(null);
    newTemplate.setModDate(new Date());
    newTemplate.setDrawed(currentTemplate.isDrawed());
    newTemplate.setDrawedBody(currentTemplate.getDrawedBody());
View Full Code Here

      // Checking the max file size
      if ((uploadedFile != null) && ((uploadFileMaxSize > 0) && (uploadedFile.length() > uploadFileMaxSize))) {
        if (currentFile != null)
          unLockAsset(currentFile);
        throw new DotDataException("Uploaded file is bigger than the file max size allowed.");
      }

      // CHECK THE FOLDER PATTERN
      if (UtilMethods.isSet(file.getFileName()) && !APILocator.getFolderAPI().matchFilter(folder, file.getFileName())) {
        // when there is an error saving should unlock working asset
        if (currentFile != null)
          unLockAsset(currentFile);
        throw new DotDataException("message.file_asset.error.filename.filters");
      }

      // Setting some flags
      boolean editFile = false;
      boolean newUploadedFile = true;

      // checks if the file is new or it's being edited
      if (fileExists) {
        editFile = true;
        // if it's being edited it keeps the same file name as the
        // current one
        fileName = currentFile.getFileName();
      }

      // checks if another identifier with the same name exists in the
      // same
      // folder
      if (!editFile && (getWorkingFileByFileName(fileName, folder, user, respectFrontendRoles) != null)) {
        throw new DotDataException("message.file_asset.error.filename.exists");
      }

      // to check if a file is being uploaded
      if (fileName.length() == 0) {
        newUploadedFile = false;
      }

      // getting mime type
      if (editFile && newUploadedFile && (file.getMimeType() != null) && (currentFile != null)
          && (!file.getMimeType().equals(currentFile.getMimeType()))) {
        // when there is an error saving should unlock working asset
        unLockAsset(currentFile);
        throw new DotDataException("message.file_asset.error.mimetype");
      }

      //save(file);
      // ffac.deleteFromCache(file);
      // get the file Identifier
View Full Code Here

   * @throws DotStateException
   */
  protected WebAsset saveAsset(WebAsset newWebAsset, Identifier id, User user, boolean respectAnonPermissions) throws DotDataException, DotStateException, DotSecurityException {

    if (!InodeUtils.isSet(id.getInode())) {
      throw new DotDataException("Identifier not found!");
    }
    /*WebAsset oldWebAsset = (WebAsset) APILocator.getVersionableAPI().findWorkingVersion(id, user, respectAnonPermissions);

    if (!InodeUtils.isSet(oldWebAsset.getInode())) {
      throw new DotDataException("Working copy of id: " + id.getAssetType() + ":" + id.getInode() + " not found!");
View Full Code Here

    upAPI = APILocator.getUserProxyAPI();
  }

  public User loadUserById(String userId, User user, boolean respectFrontEndRoles) throws DotDataException, DotSecurityException,com.dotmarketing.business.NoSuchUserException {
    if(!UtilMethods.isSet(userId)){
      throw new DotDataException("You must specifiy an userId to search for");
    }
    User u = uf.loadUserById(userId);
    if(!UtilMethods.isSet(u)){
      throw new com.dotmarketing.business.NoSuchUserException("No user found with passed in email");
    }
View Full Code Here

TOP

Related Classes of com.dotmarketing.exception.DotDataException

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.