Examples of StorageFactory


Examples of org.apache.derby.io.StorageFactory

                new PrivilegedExceptionAction<Object>()
                {
                    public Object run()
                        throws StandardException, IOException, InstantiationException, IllegalAccessException
                    {
                        StorageFactory storageFactory = privGetStorageFactoryInstance( true, serviceName, null, null);
                        try
                        {
                            if (SanityManager.DEBUG)
                            {
                                // Run this through getCanonicalServiceName as
                                // an extra sanity check. Prepending the
                                // protocol lead in to the canonical name from
                                // the storage factory should be enough.
                                String tmpCanonical = getCanonicalServiceName(
                                        getProtocolLeadIn() +
                                        storageFactory.getCanonicalName());
                                // These should give the same result.
                                SanityManager.ASSERT(
                                        tmpCanonical.equals(getProtocolLeadIn()
                                        + storageFactory.getCanonicalName()));
                                SanityManager.ASSERT(
                                    serviceName.equals(tmpCanonical),
                                    "serviceName = " + serviceName +
                                    " ; protocolLeadIn + " +
                                    "storageFactory.getCanoicalName = " +
                                    tmpCanonical);
                            }
                            StorageFile serviceDirectory = storageFactory.newStorageFile( null);
                            return serviceDirectory.deleteAll() ? this : null;
                        }
                        finally { storageFactory.shutdown(); }
                    }
                }
                ) != null;
        }
        catch( PrivilegedActionException pae){ return false;}
View Full Code Here

Examples of org.apache.derby.io.StorageFactory

                new PrivilegedExceptionAction<String>()
                {
                    public String 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

Examples of org.apache.derby.io.StorageFactory

                    "INDEXDESCRIPTORMAKER",
                }
              );
   
        connection = LuceneSupport.getDefaultConnection();
        StorageFactory  dir = LuceneSupport.getStorageFactory( connection );
   
    StorageFile luceneDir = dir.newStorageFile( Database.LUCENE_DIR );
        ArrayList<StorageFile> allIndexes = new ArrayList<StorageFile>();

        StorageFile[]  schemas = listDirectories( dir, luceneDir );
        if ( schemas != null )
        {
View Full Code Here

Examples of org.apache.derby.io.StorageFactory

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

                         return luceneDir.exists();
                     }
                 }
                 ).booleanValue();
View Full Code Here

Examples of org.apache.derby.io.StorageFactory

                                                          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

Examples of org.apache.derby.io.StorageFactory

                                is.close();
                            }
                        }
                        else
                        {
                            StorageFactory storageFactory = privGetStorageFactoryInstance( true, serviceName, null, null);
                            StorageFile file = storageFactory.newStorageFile( PersistentService.PROPERTIES_NAME);
                            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

Examples of org.atomojo.app.StorageFactory

  
   public void startServer()
      throws Exception
   {
      dbList.get("data").connect();
      StorageFactory storageFactory = new XMLDBStorageFactory();
      www = new WebComponent(getDatabaseDirectory(),dbList,storageFactory,conf);
      www.start();
   }
View Full Code Here

Examples of org.atomojo.app.StorageFactory

     
      ServerConfiguration conf = new ServerConfiguration();
      File serverConfFile = new File(dir,"server.conf");
      assertTrue(serverConfFile.exists());
      conf.load(serverConfFile.toURI());
      StorageFactory storageFactory = new FileStorageFactory();
      WebComponent web = new WebComponent(dir,dbList,storageFactory,conf);
      for (DB db : dbList.values()) {
         db.connect();
      }
      web.start();
View Full Code Here

Examples of org.atomojo.app.StorageFactory

         return new StringRepresentation("Non-XML media type for entity body: "+entity.getMediaType().getName());
      }
     
      Map<String,DBInfo> dbList = (Map<String,DBInfo>)getContext().getAttributes().get(DatabaseListResource.DB_LIST);
      Map<String,DBInfo> autodbList = (Map<String,DBInfo>)getContext().getAttributes().get(DatabaseListResource.AUTO_DB_LIST);
      StorageFactory storageFactory = (StorageFactory)getContext().getAttributes().get(DatabaseListResource.STORAGE_FACTORY);
      XMLRepresentationParser parser = new XMLRepresentationParser();
      try {
         DocumentDestination dest = new DocumentDestination();
        
         parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,AdminXML.NM_BACKUP));
         Document doc = dest.getDocument();
        
         Element top = doc.getDocumentElement();
         String location = top.getAttributeValue("location");
         if (location==null) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("The 'location' attribute is missing.");
         }
         location = location.trim();
         if (location.length()==0) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("The 'location' attribute is empty.");
         }
         File dir = new File(location);
         if (!dir.exists()) {
            if (!dir.mkdirs()) {
               getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
               return new StringRepresentation("The "+dir.getAbsolutePath()+" doesn't exist and can't be created.");
            }
         }
         if (!dir.canWrite()) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("Cannot write to "+dir.getAbsolutePath());
         }
        
         Set<String> dbNames = new TreeSet<String>();
         Iterator<Element> names = top.getElementsByName(AdminXML.NM_NAME);
         while (names.hasNext()) {
            dbNames.add(names.next().getText());
         }

         List<Map<String,DBInfo>> lists = new ArrayList<Map<String,DBInfo>>();
         lists.add(dbList);
         lists.add(autodbList);
        
         boolean ok = true;
         for (Map<String,DBInfo> map : lists) {
            for (DBInfo dbinfo : map.values()) {
               DB db = dbinfo.getDB();
               if (dbNames.size()>0 && !dbNames.contains(db.getName())) {
                  continue;
               }
               try {
                  Storage storage = storageFactory.getStorage(db);
                  Backup backup = new Backup(db,storage,AtomApplication.RESOURCE_BASE);
                  File zipFile = new File(dir,db.getName()+".zip");
                  backup.toZip(db.getName(), zipFile);
               } catch (Exception ex) {
                  getLogger().log(Level.SEVERE,"Cannot backup database "+db.getName()+" due to exception.",ex);
View Full Code Here

Examples of org.atomojo.app.StorageFactory

         return new StringRepresentation("Non-XML media type for entity body: "+entity.getMediaType().getName());
      }
     
      Map<String,DBInfo> dbList = (Map<String,DBInfo>)getContext().getAttributes().get(DatabaseListResource.DB_LIST);
      Map<String,DBInfo> autodbList = (Map<String,DBInfo>)getContext().getAttributes().get(DatabaseListResource.AUTO_DB_LIST);
      StorageFactory storageFactory = (StorageFactory)getContext().getAttributes().get(DatabaseListResource.STORAGE_FACTORY);

      try {
         DocumentDestination dest = new DocumentDestination();
        
         parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,AdminXML.NM_RESTORE));
         Document doc = dest.getDocument();
        
         Element top = doc.getDocumentElement();
         String location = top.getAttributeValue("location");
         if (location==null) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("The 'location' attribute is missing.");
         }
         location = location.trim();
         if (location.length()==0) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("The 'location' attribute is empty.");
         }
         File dir = new File(location);
         if (!dir.exists()) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("The "+dir.getAbsolutePath()+" doesn't exist.");
         }
         if (!dir.canRead()) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("Cannot write to "+dir.getAbsolutePath());
         }

         Set<String> dbNames = new TreeSet<String>();
         Iterator<Element> names = top.getElementsByName(AdminXML.NM_NAME);
         while (names.hasNext()) {
            dbNames.add(names.next().getText());
         }
        
         List<Map<String,DBInfo>> lists = new ArrayList<Map<String,DBInfo>>();
         lists.add(dbList);
         lists.add(autodbList);
        
         User user = (User)getRequest().getAttributes().get(App.USER_ATTR);
        
         boolean ok = true;
         List<String> failures = new ArrayList<String>();
         for (Map<String,DBInfo> map : lists) {
            for (DBInfo dbinfo : map.values()) {
               DB db = dbinfo.getDB();
               if (dbNames.size()>0 && !dbNames.contains(db.getName())) {
                  continue;
               }
               File dbDir = new File(dir,db.getName());
               boolean needsCleanup = false;
               try {
                  Storage storage = storageFactory.getStorage(db);
                  File zipFile = new File(dir,db.getName()+".zip");
                  if (!dbDir.exists() && zipFile.exists()) {
                     // This is what we want but it doesn't work
                     //introspectionURI = new URI("jar:"+zipFile.toURI()+"!/_introspection_.xml");
                     getLogger().info("Extracting backup for restore...");
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.