Package org.apache.derby.io

Examples of org.apache.derby.io.StorageFactory


                new PrivilegedExceptionAction()
                {
                    public Object run()
                        throws StandardException, IOException, InstantiationException, IllegalAccessException
                    {
                        StorageFactory storageFactory = privGetStorageFactoryInstance( true, nm, null, null);
                        try
                        {
                            return storageFactory.getCanonicalName();
                        }
                        finally { storageFactory.shutdown();}
                    }
                }
                );
        }
    catch (PrivilegedActionException pae)
View Full Code Here


    /** Get the location of the Lucene indexes */
    private StorageFile getLuceneDir()
        throws StandardException
    {
        StorageFactory  dir = getStorageFactory();
   
    return dir.newStorageFile( Database.LUCENE_DIR );
    }
View Full Code Here

    private void    backupLucene( String backupDir )
        throws StandardException
    {
        try {
            File            backupRoot = new File( backupDir );
            StorageFactory  storageFactory = getStorageFactory();
            String      canonicalDbName = storageFactory.getCanonicalName();
            String      dbname = StringUtil.shortDBName( canonicalDbName, storageFactory.getSeparator() );
            File        backupDB = new File( backupRoot, dbname );
       
            final   File            targetDir = new File( backupDB, Database.LUCENE_DIR );
            final   StorageFile sourceDir = getLuceneDir();
View Full Code Here

                                                          String databaseName,
                                                          String tempDirName,
                                                          String uniqueName)
         throws InstantiationException, IllegalAccessException, IOException
    {
        StorageFactory storageFactory = (StorageFactory) storageFactoryClass.newInstance();
        String dbn;
        if( databaseName != null
            && subSubProtocol != null
            && databaseName.startsWith( subSubProtocol + ":"))
            dbn = databaseName.substring( subSubProtocol.length() + 1);
        else
            dbn = databaseName;
        storageFactory.init( useHome ? home : null, dbn, tempDirName, uniqueName);
        return storageFactory;
    } // end of privGetStorageFactoryInstance
View Full Code Here

        conn.prepareStatement( "drop schema " + LUCENE_SCHEMA + " restrict" ).execute();

        //
        // Now delete the Lucene subdirectory;
        //
        StorageFactory storageFactory = getStorageFactory(conn);
        StorageFile luceneDir =
                storageFactory.newStorageFile(Database.LUCENE_DIR);
        if (exists(luceneDir)) {
            deleteFile(luceneDir);
        }
  }
View Full Code Here

                (
                 new PrivilegedExceptionAction<Object>()
                 {
                     public Object run() throws SQLException
                     {
                         StorageFactory storageFactory = getStorageFactory( conn );
                         StorageFile    luceneDir = storageFactory.newStorageFile( Database.LUCENE_DIR );

                         luceneDir.mkdir();
   
                         return null;
                     }
View Full Code Here

     * </p>
     */
  static DerbyLuceneDir getDerbyLuceneDir( Connection conn, String schema, String table, String textcol )
        throws SQLException
    {
        StorageFactory  storageFactory = getStorageFactory( conn );
        DerbyLuceneDir  result = DerbyLuceneDir.getDirectory( storageFactory, schema, table, textcol );

        return result;
    }
View Full Code Here

                                is.close();
                            }
                        }
                        else
                        {
                            StorageFactory storageFactory = privGetStorageFactoryInstance( true, serviceName, null, null);
                            StorageFile file = storageFactory.newStorageFile( PersistentService.PROPERTIES_NAME);
                            resolveServicePropertiesFiles(storageFactory, file);
                            try {
                                InputStream is = file.getInputStream();
                                try {
                                    // Need to load the properties before closing the
                                    // StorageFactory.
                                    serviceProperties.load(new BufferedInputStream(is));
                                } finally {
                                    is.close();
                                }
                            } finally {
                               storageFactory.shutdown();
                            }
                        }
                        return null;
                    }
                }
View Full Code Here

                                new PrivilegedExceptionAction<Object>()
                                {
                                    public Object run()
                                        throws IOException, StandardException, InstantiationException, IllegalAccessException
                                    {
                                        StorageFactory storageFactory
                                          = privGetStorageFactoryInstance( true, serviceName, null, null);
                                        try
                                        {
                                            StorageFile serviceDirectory = storageFactory.newStorageFile( null);
                                            return serviceDirectory.exists() ? this : null;
                                        }
                                        finally {storageFactory.shutdown();}
                                    }
                                }
                                ) == null)
                        {
                            createRoot =true;
                            deleteExistingRoot = false;
                        }
                       
                    }
                    catch( PrivilegedActionException pae)
                    {
                        throw Monitor.exceptionStartingModule( (IOException) pae.getException());
                    }
        }
      }
    }

    //restore the service properties from backup
    if(restoreFrom != null)
    {
      //First make sure backup service directory exists in the specified path
      File backupRoot = new File(restoreFrom);
      if (fileExists(backupRoot))
      {
        //First make sure backup have service.properties
        File bserviceProp = new File(restoreFrom, PersistentService.PROPERTIES_NAME);
        if(fileExists(bserviceProp))
        {
          //create service root if required
          if(createRoot)
            createServiceRoot(serviceName, deleteExistingRoot);
                    try
                    {
                        AccessController.doPrivileged(
                            new PrivilegedExceptionAction<Object>()
                            {
                                public Object run()
                                    throws IOException, StandardException, InstantiationException, IllegalAccessException
                                {
                                    WritableStorageFactory storageFactory =
                                      (WritableStorageFactory) privGetStorageFactoryInstance( true,
                                                                                              serviceName,
                                                                                              null,
                                                                                              null);
                                    try
                                    {
                                        StorageFile cserviceProp = storageFactory.newStorageFile( PersistentService.PROPERTIES_NAME);

                                        if(cserviceProp.exists())
                                            if(!cserviceProp.delete())
                                                throw StandardException.newException(SQLState.UNABLE_TO_DELETE_FILE,
                                                                                     cserviceProp);
                                        return null;
                                    }
                                    finally { storageFactory.shutdown();}
                                }
                            }
                            );
                    }
                    catch( PrivilegedActionException pae)
View Full Code Here

                new PrivilegedExceptionAction<Object>()
                {
                    public Object run()
                        throws StandardException, IOException, InstantiationException, IllegalAccessException
                    {
                        StorageFactory storageFactory = privGetStorageFactoryInstance( true, name, null, null);
                        try
                        {
                            StorageFile serviceDirectory = storageFactory.newStorageFile( null);

                            if (serviceDirectory.exists())
                            {
                                if (deleteExisting)
                                {
                                    if (!serviceDirectory.deleteAll())
                                        throw StandardException.newException(SQLState.SERVICE_DIRECTORY_REMOVE_ERROR,
                                                                             getDirectoryPath( name));
                                }
                                else
                                {
                                    vetService( storageFactory, name );
                                    throw StandardException.newException(SQLState.SERVICE_DIRECTORY_EXISTS_ERROR,
                                                                         getDirectoryPath( name));
                                }
                            }

                            if (serviceDirectory.mkdirs())
                            {
                                serviceDirectory.limitAccessToOwner();
                                // DERBY-5096. The storageFactory canonicalName may need to be adjusted
                                // for casing after the directory is created. Just reset it after making the
                                // the directory to make sure.
                                String serviceDirCanonicalPath = serviceDirectory.getCanonicalPath();
                                storageFactory.setCanonicalName(serviceDirCanonicalPath);
                                try
                                {
                                    return storageFactory.getCanonicalName();
                                }
                                catch (IOException ioe)
                                {
                                    serviceDirectory.deleteAll();
                                    throw ioe;
                                }
                            }
                            throw StandardException.newException(SQLState.SERVICE_DIRECTORY_CREATE_ERROR, serviceDirectory);
                        }
                        finally { storageFactory.shutdown(); }
                    }
                }
                );
    }
        catch (SecurityException se) { t = se; }
View Full Code Here

TOP

Related Classes of org.apache.derby.io.StorageFactory

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.