Examples of PhotovaultException


Examples of org.photovault.common.PhotovaultException

        }
        Map values = null;
        try {
            values = dcraw.getFileInfo(f);
        } catch (IOException ex) {
            throw new PhotovaultException( ex.getMessage(), ex );
        }
       
        if ( values.containsKey( "Decodable with dcraw" ) ) {
            if ( values.get( "Decodable with dcraw" ).equals( "yes" ) ) {
                validRawFile = true;
View Full Code Here

Examples of org.photovault.common.PhotovaultException

     * @return The created object.
     */
    public RawConversionSettings create()
        throws PhotovaultException {
        if ( !( colorBalanceSet && dlMultSet )  ) {
            throw new PhotovaultException(
                    "Color balance or daylight multipliers not set" );
        }
        RawConversionSettings s = new RawConversionSettings();
        s.daylightRedGreenRatio = dlRedGreenRatio;
        s.daylightBlueGreenRatio = dlBlueGreenRatio;
View Full Code Here

Examples of org.photovault.common.PhotovaultException

            connDesc.setDbAlias( "photovault" );
            File derbyDir = new File( dbDesc.getEmbeddedDirectory(), "derby" );
            System.setProperty( "derby.system.home", derbyDir.getAbsolutePath()  );
            if ( ( user != null && user.length() != 0 ) ||
                    ( passwd != null && passwd.length() != 0 ) )  {
                throw new PhotovaultException( "No username or password allowed for Derby database" );
            }
        } else {
            // This is a MySQL database
            String dbhost = dbDesc.getHost();
            String dbname = dbDesc.getDbName();
            connDesc.setDbAlias( "//" + dbhost + "/" + dbname );
            connDesc.setUserName( user );
            connDesc.setPassWord( passwd );
            connDesc.setDriver( "com.mysql.jdbc.Driver" );
            connDesc.setDbms( "MySQL" );
            connDesc.setSubProtocol( "mysql" );
        }       
 
       
        // Open the database connection
        db = odmg.newDatabase();       
  boolean success = false;
  try {
      log.debug( "Opening database" );
      db.open( "pv#" + user + "#" + passwd, Database.OPEN_READ_WRITE );
      log.debug( "Success!!!" );
  } catch ( Throwable e ) {
      log.error( "Failed to get connection: " + e.getMessage() );
            e.printStackTrace();
        }
       
        // Check whether the database was opened correctly
        try {
            PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(connKey);
            broker.beginTransaction();
            Connection con = broker.serviceConnectionManager().getConnection();
            broker.commitTransaction();
            broker.close();
        } catch (Exception ex) {
            /*
             Finding the real reason for the error needs a bit of guesswork: first
             lets find the original exception
            */
            Throwable rootCause = ex;
            while ( rootCause.getCause() != null ) {
                rootCause = rootCause.getCause();
            }
            log.error( rootCause.getMessage() );
            if ( rootCause instanceof SQLException ) {
                if ( rootCause instanceof EmbedSQLException ) {
                    /*
                     We are using Derby, the problem is likely that another
                     instance of the database has been started
                     */
                     throw new PhotovaultException( "Cannot start database.\n"
                             + "Do you have another instance of Photovault running?", rootCause );
                }
                if ( dbDesc.getInstanceType() == PVDatabase.TYPE_SERVER ) {
                    throw new PhotovaultException( "Cannot log in to MySQL database", rootCause );
                }
            }
            throw new PhotovaultException( "Unknown error while starting database:\n"
                    + rootCause.getMessage(), rootCause );
        }

  // Test the connection by fetching something
  try {
            DbInfo dbinfo = DbInfo.getDbInfo();
            if ( dbinfo != null ) {
//            PhotoFolder folder = PhotoFolder.getRoot();
//      if ( folder != null ) {
    success = true;
      } else {
    log.error( "Could not open database connection" );
    try {
        db.close();
    } catch (ODMGException e ) {
        log.error( "Error closing database" );
    }
      }
  } catch ( Exception t ) {
      log.error( "Could not open database connection" );
      log.error( t.getMessage() );
            t.printStackTrace();
            try {
    db.close();
      } catch ( Exception e ) {
                log.error( "Error closing database" );
            }
            throw new PhotovaultException( "Unknown error while starting database:\n"
                    + t.getMessage(), t );
           
  }
        if ( !success ) {
            throw new PhotovaultException( "Unknown exception while starting database" );
        }
    }   
View Full Code Here

Examples of org.photovault.common.PhotovaultException

        PVDatabase db = settings.getDatabase( dbName );
        String sqldbName = db.getDbName();
        log.debug( "Mysql DB name: " + sqldbName );
        if ( sqldbName == null ) {
            JOptionPane.showMessageDialog( ld, "Could not find dbname for configuration " + db, "Configuration error", JOptionPane.ERROR_MESSAGE );
            throw new PhotovaultException( "Could not find dbname for configuration " + db );
        }
       
        ODMG.initODMG( user, passwd, db );
        log.debug( "Connection succesful!!!" );
        // Login is succesfull
View Full Code Here

Examples of org.photovault.common.PhotovaultException

    protected void checkJAI() throws PhotovaultException {
        try {
            String jaiVersion = JAI.getBuildVersion();
        } catch ( Throwable t ) {
            throw new PhotovaultException(
                      "Java Advanced Imaging not installed\n"
                    + "properly. It is needed by Photovault,\n"
                    + "please download and install it from\n"
                    + "http://java.sun.com/products/java-media/jai/");
        }
View Full Code Here

Examples of org.photovault.common.PhotovaultException

                    p.setColorChannelMapping( o );
                }
            }
        } catch ( LockNotGrantedException e ) {
            txw.abort();
            throw new PhotovaultException( "Photo locked for other use", e );
        }
        txw.commit();
    }
View Full Code Here

Examples of org.photovault.common.PhotovaultException

  // Find the JPEG image reader
  // TODO: THis shoud decode also other readers from fname
        String fname = imageFile.getName();
        int lastDotPos = fname.lastIndexOf( "." );
        if ( lastDotPos <= 0 || lastDotPos >= fname.length()-1 ) {
            throw new PhotovaultException( "Cannot determine file type extension of " + imageFile.getAbsolutePath() );
        }
        String suffix = fname.substring( lastDotPos+1 );
        Iterator readers = ImageIO.getImageReadersBySuffix( suffix );
        if ( readers.hasNext() ) {
            ImageReader reader = (ImageReader)readers.next();
            ImageInputStream iis = null;
            try {
                iis = ImageIO.createImageInputStream( imageFile );
                if ( iis != null ) {
                    reader.setInput( iis, true );
                   
                    width = reader.getWidth( 0 );
                    height = reader.getHeight( 0 );
                    reader.dispose();
                }
            } catch (IOException ex) {
                log.debug( "Exception in readImageFile: " + ex.getMessage() );
                throw ex;
            } finally {
                if ( iis != null ) {
                    try {
                        iis.close();
                    } catch (IOException ex) {
                        log.warn( "Cannot close image stream: " + ex.getMessage() );
                    }
                }
            }
        } else {
            RawImage ri = new RawImage( imageFile );
            if ( ri.isValidRawFile() ) {
                // PlanarImage img = ri.getCorrectedImage();
                width = ri.getWidth();
                height = ri.getHeight();
            } else {
                throw new PhotovaultException( "Unknown image file extension " + suffix +
                        "\nwhile reading " + imageFile.getAbsolutePath() );
            }
        }
       
    }
View Full Code Here

Examples of org.photovault.common.PhotovaultException

                return;
            }
        }
        // if we get this far no instance of the original image has been found
        setImage( null );
        throw new PhotovaultException( "No suitable instance of photo "
                + photo.getUid() + " found" );
       
    }
View Full Code Here

Examples of org.photovault.common.PhotovaultException

     @return  Input stream to the converted TIFF image
     */
    InputStream getRawImageAsTiff( File rawFile )
            throws PhotovaultException, IOException {
        if ( DCRAW_CMD == null ) {
            throw new PhotovaultException( "Cannot find suitable dcraw executable\n" +
                    "for this architecture" );
        }
        ArrayList cmd = new ArrayList();
        cmd.add( DCRAW_CMD );
        // Output to stdout
View Full Code Here

Examples of org.photovault.common.PhotovaultException

     @throws IOException if there was an error while reading the data.
     */
    Map getFileInfo( File rawFile )
    throws IOException, PhotovaultException {
        if ( DCRAW_CMD == null ) {
            throw new PhotovaultException( "Cannot find suitable dcraw executable\n" +
                    "for this architecture" );
        }
       
        ProcessBuilder pb = new ProcessBuilder( DCRAW_CMD, "-i", "-v",
                rawFile.getAbsolutePath() );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.