Package org.atomojo.app.db

Examples of org.atomojo.app.db.RemoteApp


     
      try {
         DocumentDestination dest = new DocumentDestination();
         parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,AdminXML.NM_APP));
         doc = dest.getDocument();
         RemoteApp app = new RemoteApp(db,doc.getDocumentElement());
         String lname = app.getName();
         if (!lname.equals(name)) {
            getResponse().setStatus(Status.CLIENT_ERROR_EXPECTATION_FAILED);
            return new StringRepresentation("Cannot change the name of the remote app.");
         }
         if (app.exists()) {
            if (app.update()) {
               getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
               return null;
            } else {
               getContext().getLogger().severe("Cannot store XML for remote app.");
               getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
View Full Code Here


   }
  
   public Representation delete() {
      final DB db = (DB)getRequest().getAttributes().get(App.DB_ATTR);
      final String name = getRequest().getAttributes().get("name").toString();
      RemoteApp app = new RemoteApp(db,name);
      if (app.exists()) {
         if (app.delete()) {
            getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
         } else {
            getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
         }
      } else {
View Full Code Here

               ItemDestination dest = new WriterItemDestination(out,"UTF-8");
               ItemConstructor constructor = InfosetFactory.getDefaultInfoset().createItemConstructor();
               dest.send(constructor.createDocument());
               dest.send(constructor.createElement(AdminXML.NM_APPS));
               while (apps.hasNext()) {
                  RemoteApp app = apps.next();
                  app.marshall();;
                  DocumentSource.generate(app.getElement(),false,dest);
               }
               dest.send(constructor.createElementEnd(AdminXML.NM_APPS));
               dest.send(constructor.createDocumentEnd());
               out.flush();
               out.close();
View Full Code Here

     
      try {
         DocumentDestination dest = new DocumentDestination();
         parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,AdminXML.NM_APP));
         doc = dest.getDocument();
         RemoteApp app = new RemoteApp(db,doc.getDocumentElement());
         if (app.exists()) {
            getResponse().setStatus(Status.CLIENT_ERROR_CONFLICT);
            return new StringRepresentation("Remote app with name "+app.getName()+" already exists.");
         }
         if (app.create()) {
            getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
            Reference ref = new Reference(getRequest().getResourceRef().toString()+"/"+app.getName());
            getResponse().setLocationRef(ref);
            return null;
         } else {
            getContext().getLogger().severe("Cannot store XML for remote app");
            getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
View Full Code Here

  
   public Representation get()
   {
      final DB db = (DB)getRequest().getAttributes().get(App.DB_ATTR);
      final String name = getRequest().getAttributes().get("name").toString();
      RemoteApp app = new RemoteApp(db,name);
      if (app.exists()) {
         return app.getRepresentation();
      } else {
         getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
         return null;
      }
   }
View Full Code Here

                     getLogger().info("No database backup for database "+db.getName());
                     continue;
                  }
                  URI introspectionURI = introspect.toURI();

                  RemoteApp app = new RemoteApp(db,"backup");
                  app.setIntrospection(introspectionURI);
                  app.setRoot(dbDir.toURI());

                  SyncTarget target = new SyncTarget(db,"");
                  SyncProcess proc = new SyncProcess(db,"restore",true,target,app,null);

                  PullSynchronizer restore = new PullSynchronizer(getLogger(),getApplication().getMetadataService(),user,db,storage,proc);
View Full Code Here

         if (location==null && appE==null) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("A location or remote app is required.");
         }

         RemoteApp app = null;
         if (location==null) {
            app = new RemoteApp(db,appE);
            app.unmarshall();
            if (!app.getIntrospection().isAbsolute()) {
               getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
               return new StringRepresentation("URI could not be resolved to absolute URI: "+appE.getAttributeValue("introspect"));
            }
         } else {
            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());
            }
            File introspect = new File(dir,"_introspection_.xml");
            if (!introspect.exists()) {
               getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
               return new StringRepresentation("Introspection document "+introspect.getAbsolutePath()+" does not exist.");
            }
           
            app = new RemoteApp(db,"backup");
            app.setIntrospection(introspect.toURI());
            app.setRoot(dir.toURI());
         }
        
         SyncTarget target = new SyncTarget(db,"");
        
         SyncProcess proc = new SyncProcess(db,"restore",true,target,app,null);
View Full Code Here

TOP

Related Classes of org.atomojo.app.db.RemoteApp

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.