Package org.apache.derby.io

Examples of org.apache.derby.io.StorageFactory


                                new PrivilegedExceptionAction()
                                {
                                    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(backupRoot.exists())
      {
        //First make sure backup have service.properties
        File bserviceProp = new File(restoreFrom, PersistentService.PROPERTIES_NAME);
        if(bserviceProp.exists())
        {
          //create service root if required
          if(createRoot)
            createServiceRoot(serviceName, deleteExistingRoot);
                    try
                    {
                        AccessController.doPrivileged(
                            new PrivilegedExceptionAction()
                            {
                                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()
                {
                    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
                                    throw StandardException.newException(SQLState.SERVICE_DIRECTORY_EXISTS_ERROR,
                                                                         getDirectoryPath( name));
                            }

                            if (serviceDirectory.mkdirs())
                            {
                                try
                                {
                                    return storageFactory.getCanonicalName();
                                }
                                catch (IOException ioe)
                                {
                                    serviceDirectory.deleteAll();
                                    throw ioe;
                                }
                            }
                            throw StandardException.newException(SQLState.SERVICE_DIRECTORY_CREATE_ERROR,
                                                                 serviceDirectory, null);
                        }
                        finally { storageFactory.shutdown(); }
                    }
                }
                );
    }
        catch (SecurityException se) { t = se; }
View Full Code Here

                new PrivilegedExceptionAction()
                {
                    public Object run()
                        throws StandardException, IOException, InstantiationException, IllegalAccessException
                    {
                        StorageFactory storageFactory = privGetStorageFactoryInstance( true, serviceName, null, null);
                        try
                        {
                            if (SanityManager.DEBUG)
                                SanityManager.ASSERT(serviceName.equals( storageFactory.getCanonicalName()), serviceName);
                            StorageFile serviceDirectory = storageFactory.newStorageFile( null);
                            return serviceDirectory.deleteAll() ? this : null;
                        }
                        finally { storageFactory.shutdown(); }
                    }
                }
                ) != null;
        }
        catch( PrivilegedActionException pae){ return false;}
View Full Code Here

                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

            case HAS_MORE_ELEMENTS_ACTION:
                for (; index < contents.length; contents[index++] = null)
                {
                    try
                    {
                        StorageFactory storageFactory = privGetStorageFactoryInstance( true, contents[index], null, null);
                        try
                        {
                            StorageFile properties = storageFactory.newStorageFile( PersistentService.PROPERTIES_NAME);
                            if (!properties.exists())
                                continue;
                            // convert to a canonical name while we are here.
                            contents[index] = storageFactory.getCanonicalName();
                            validIndex = true;

                            return this;
                        }
                        finally { storageFactory.shutdown(); }
                    }
                    catch (Exception se) { continue; }
                }
                return null;
            }
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.