Package it.eng.qbe.datasource.configuration.dao

Examples of it.eng.qbe.datasource.configuration.dao.DAOException


  // ============================================================
 
  public JarFileRetriever(File datamartsDir) {
    Assert.assertNotNull(datamartsDir, "Parameter [datamartsDir] cannot be null");
    if(!datamartsDir.exists()) {
      throw new DAOException("Folder [" + datamartsDir.getName() + "] does not exist.");
    }
    if(!datamartsDir.isDirectory()) {
      throw new DAOException("File [" + datamartsDir.getName() + "] is not a folder.");
    }
    this.setDatamartsDir(datamartsDir);
  }
View Full Code Here


   
    targetDatamartDir = new File(getDatamartsDir(), datamartName);   
    datamartJarFile = new File(targetDatamartDir, "datamart.jar");
   
    if (!datamartJarFile.exists()) {
      throw new DAOException("Impossible to load datamart [" + datamartName + "]. The associated mapping file [" + datamartJarFile + "] does not exist");
    }
   
    return datamartJarFile;
  }
View Full Code Here

    ZipEntry zipEntry;
   
    try {
      zipFile = new ZipFile(datamartFile);
    } catch (Throwable t) {
      throw new DAOException("Impossible to read jar file [" + datamartFile + "]");
    }
   
    zipEntry = zipFile.getEntry("META-INF/persistence.xml");
   
    return zipEntry!=null;
View Full Code Here

      } else {
        logger.debug("File [" + calculatedFieldsFile + "] does not exist. No calculated fields have been loaded.");
      }
    } catch(Throwable t){
      if(t instanceof DAOException) throw (DAOException)t;
      throw new DAOException("An unpredicted error occurred while loading calculated fields on file [" + calculatedFieldsFile + "]", t);
    }finally {
      if(in != null) {
        try {
          in.close();
        } catch(IOException e) {
          throw new DAOException("Impossible to properly close stream to file file [" + calculatedFieldsFile + "]", e);
        }
      }
      logger.debug("OUT");
    }
   
View Full Code Here

      calculatedFieldsFile = getCalculatedFieldsFile();
      Assert.assertNotNull(calculatedFieldsFile, "Destination file cannot be null");
      logger.debug("Calculated fields will be saved on file [" + calculatedFieldsFile + "]");
     
      if( !calculatedFieldsFile.getParentFile().exists() ) {
        DAOException e = new DAOException("Destination file folder [" + calculatedFieldsFile.getPath()+ "] does not exist");
        e.addHint("Check if [" + calculatedFieldsFile.getPath()+ "] folder exist on your server filesystem. If not create it.");
        throw e;
      }
     
      if( calculatedFieldsFile.exists() ) {
        logger.warn("File [" + calculatedFieldsFile + "] already exists. New settings will override the old ones.");
      }
     
      document = DocumentHelper.createDocument();
          root = document.addElement( ROOT_TAG );
               
      logger.debug("In the target model there are [" + calculatedFields.keySet() + "] entity/es that contain calculated fields" );
      it = calculatedFields.keySet().iterator();
      while(it.hasNext()) {
        entityName = (String)it.next();
        logger.debug("Serializing [" + calculatedFields.size() + "] calculated fields for entity [" + entityName + "]");
        fields = (List)calculatedFields.get(entityName);
        for(int i = 0; i < fields.size(); i++) {
          field = (ModelCalculatedField)fields.get(i);
          logger.debug("Serializing calculated field [" + field.getName() + "] for entity [" + entityName + "]");
          root.addElement( FIELD_TAG )
                  .addAttribute( FIELD_TAG_ENTIY_ATTR, entityName )
                  .addAttribute( FIELD_TAG_NAME_ATTR, field.getName() )
                  .addAttribute( FIELD_TAG_TYPE_ATTR, field.getType() )
                  .addAttribute( FIELD_TAG_IN_LINE_ATTR, ""+field.isInLine() )
                  .addCDATA( field.getExpression() );
        }
      }
     
      guardedWrite(document, calculatedFieldsFile);

    } catch(Throwable t){
      if(t instanceof DAOException) throw (DAOException)t;
      throw new DAOException("An unpredicetd error occurred while saving calculated fields on file [" + calculatedFieldsFile + "]");
    } finally {
      logger.debug("OUT");
    }
  }
View Full Code Here

      logger.debug("Lock acquired");
     
      try {
        in = new FileInputStream(file);
      } catch (FileNotFoundException fnfe) {
        DAOException e = new DAOException("Impossible to load calculated fields from file [" + file.getName() + "]", fnfe);
        e.addHint("Check if [" + file.getPath()+ "] folder exist on your server filesystem. If not create it.");
        throw e;
      }
      Assert.assertNotNull(in, "Input stream cannot be null");       
     
      reader = new SAXReader();
      try {
        document = reader.read(in);
      } catch (DocumentException de) {
        DAOException e = new DAOException("Impossible to parse file [" + file.getName() + "]", de);
        e.addHint("Check if [" + file + "] is a well formed XML file");
        throw e;
      }
      Assert.assertNotNull(document, "Document cannot be null");
    } catch(Throwable t) {
      if(t instanceof DAOException) throw (DAOException)t;
      throw new DAOException("An unpredicetd error occurred while writing on file [" + file + "]");
    } finally {
      if(in != null) {
        try {
          in.close();
        } catch(IOException e) {
          throw new DAOException("Impossible to properly close stream to file [" + file + "]", e);
        }
      }
      logger.debug("releasing lock...");
      releaseLock();
      logger.debug("lock released");
View Full Code Here

     
      out = null;
      try {
        out = new FileWriter( file );
      } catch (IOException e) {
        throw new DAOException("Impossible to open file [" + file + "]", e);
      }
      Assert.assertNotNull(out, "Output stream cannot be null");
         
      format = OutputFormat.createPrettyPrint();
      format.setEncoding("ISO-8859-1");
      format.setIndent("    ");
      writer = new XMLWriter(out , format );
          try {
           
        writer.write( document );
        writer.flush();
      } catch (IOException e) {
        throw new DAOException("Impossible to write to file [" + file + "]", e);
      }
    } catch(Throwable t) {
      if(t instanceof DAOException) throw (DAOException)t;
      throw new DAOException("An unpredicetd error occurred while writing on file [" + file + "]");
    } finally {
      if(writer != null) {
        try {
          writer.close();
        } catch(IOException e) {
          throw new DAOException("Impossible to properly close stream to file file [" + file + "]", e);
        }
      }
      logger.debug("releasing lock...");
      releaseLock();
      logger.debug("lock released");
View Full Code Here

TOP

Related Classes of it.eng.qbe.datasource.configuration.dao.DAOException

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.