Package org.atomojo.app.client

Examples of org.atomojo.app.client.FeedClient


         this.confHosts = ifaceHosts.get(serverConf.getKey());
         this.webClient = getContext().getClientDispatcher();
      }

      public void configure() {
         FeedClient client = new FeedClient(webClient,new Reference(link.getLink()));
         client.setIdentity(link.getUsername(), link.getPassword());

         getContext().getLogger().info("Loading configuration for " + serverConf.getAddress() + ":" + serverConf.getPort() + " from " + link.getLink());

         changes = false;
         final Map<String, Boolean> found = new TreeMap<String, Boolean>();
         try {
            client.get(new FeedDestination() {

               public void onFeed(Document feedDoc) {
               }

               public void onEntry(Document entryDoc) {
View Full Code Here


         return;
      }
      // Load the layout locations
      URI protectedTermLoc = URI.create(autoConf.getLink().toString()+T_SECURITY_PROTECTED_PATH.toString());
      getLogger().info("Loading protected paths from "+protectedTermLoc);
      FeedClient layoutFeedClient = new FeedClient(client,new Reference(protectedTermLoc));
      if (autoConf.getUsername()!=null) {
         layoutFeedClient.setIdentity(autoConf.getUsername(),autoConf.getPassword());
      }
     
      try {
        
         FeedBuilder builder = new FeedBuilder();
         Response response = layoutFeedClient.get(builder);
         if (response.getStatus().isSuccess()) {
            Feed feed = builder.getFeed();
            feed.index();
           
            Set<String> names = new TreeSet<String>();
View Full Code Here

  
   protected void configureLayouts() {
      // Load layouts
      URI layoutTemLoc = URI.create(autoConf.getLink().toString()+T_LAYOUT.toString());
      getLogger().info("Loading Layouts from "+layoutTemLoc);
      FeedClient appFeedClient = new FeedClient(client,new Reference(layoutTemLoc));
      if (autoConf.getUsername()!=null) {
         appFeedClient.setIdentity(autoConf.getUsername(),autoConf.getPassword());
      }
      try {
         FeedBuilder builder = new FeedBuilder();
         Response response = appFeedClient.get(builder);
         boolean found = false;
         if (!response.getStatus().isSuccess()) {
            if (response.getStatus().getCode()!=404) {
               getLogger().severe("Cannot get feed "+layoutTemLoc+", status="+response.getStatus().getCode());
            } else {
View Full Code Here

  
   protected void configureResources() {
      // Load layouts
      URI resourceTermLoc = URI.create(autoConf.getLink().toString()+T_RESOURCE.toString());
      getLogger().info("Loading resources from "+resourceTermLoc);
      FeedClient appFeedClient = new FeedClient(client,new Reference(resourceTermLoc));
      if (autoConf.getUsername()!=null) {
         appFeedClient.setIdentity(autoConf.getUsername(),autoConf.getPassword());
      }
      try {
         FeedBuilder builder = new FeedBuilder();
         Response response = appFeedClient.get(builder);
         boolean found = false;
         if (!response.getStatus().isSuccess()) {
            if (response.getStatus().getCode()!=404) {
               getLogger().severe("Cannot get feed "+resourceTermLoc+", status="+response.getStatus().getCode());
            } else {
View Full Code Here

  
   protected void configureApplications() {
      // Load applications
      URI appTermLoc = URI.create(autoConf.getLink().toString()+T_APP.toString());
      getLogger().info("Loading Applications from "+appTermLoc);
      FeedClient appFeedClient = new FeedClient(client,new Reference(appTermLoc));
      if (autoConf.getUsername()!=null) {
         appFeedClient.setIdentity(autoConf.getUsername(),autoConf.getPassword());
      }
      try {
         FeedBuilder builder = new FeedBuilder();
         Response response = appFeedClient.get(builder);
         boolean found = false;
         if (!response.getStatus().isSuccess()) {
            if (response.getStatus().getCode()!=404) {
               getLogger().severe("Cannot get feed "+appTermLoc+", status="+response.getStatus().getCode());
            } else {
View Full Code Here

         this.link = link;
         this.hosts = new TreeMap<String,AutoConfiguredHost>();
      }
     
      public void configure() {
         FeedClient client = new FeedClient(link.getLink());
         client.setIdentity(link.getUsername(),link.getPassword());
        
         getLogger().info("Loading configuration from "+link.getLink());
        
         try {
            boolean changes = false;
            final List<Entry> hostsToDo = new ArrayList<Entry>();
            final List<Entry> dbToDo = new ArrayList<Entry>();
            final Map<String,Boolean> currentAuthList = new TreeMap<String,Boolean>();
            final Map<String,Boolean> changedAuth = new TreeMap<String,Boolean>();
            client.get(new FeedDestination() {
               public void onFeed(Document feedDoc) {
               }
               public void onEntry(Document entryDoc) {
                  Entry entry = new Entry(entryDoc);
                  entry.index();
View Full Code Here

    }

    public void testParse() throws Exception
    {
       setLogLevel(Level.FINER);
       FeedClient feedClient = new FeedClient(FeedClientTest.class.getResource("feed.atom").toURI());
       Response response = feedClient.get(new FeedDestination() {
          public void onFeed(Document doc) {
             System.out.println("Feed:");
             try {
                StringWriter w = new StringWriter();
                XMLWriter.writeDocument(doc,w);
View Full Code Here

      }
      web.start();
     
      Identity admin = new Identity("admin","admin");
      Reference autoRef = new Reference("http://localhost:8080/R/");
      FeedClient client = new FeedClient(autoRef,admin);
     
      Status status = client.create("<feed xmlns='http://www.w3.org/2005/Atom'><title>autoconf</title></feed>");
      assertTrue(status.isSuccess());
     
      client.createEntry(
         "<entry xmlns='http://www.w3.org/2005/Atom'>" +
         "<title>test1 db</title>" +
         "<category scheme='http://www.atomojo.org/O/configuration/' term='db'/>"+
         "<category scheme='http://www.atomojo.org/O/configuration/db/' term='auth' value='auth'/>" +
         "<category scheme='http://www.atomojo.org/O/configuration/db/' term='name' value='test1'/>" +
         "<category scheme='http://www.atomojo.org/O/configuration/db/' term='group' value='test'/>" +
         "<category scheme='http://www.atomojo.org/O/configuration/db/' term='alias' value='web1'/>" +
         "</entry>");
     
      client.createEntry(
         "<entry xmlns='http://www.w3.org/2005/Atom'>" +
         "<title>testweb1 host</title>" +
         "<category scheme='http://www.atomojo.org/O/configuration/' term='host'/>"+
         "<content type='text/xml'>" +
         "<host name='testweb1' xmlns='http://www.atomojo.org/Vocabulary/Admin/2007/1/0' database='test1'/>" +
View Full Code Here

            assertTrue(status.isSuccess());
       */
      for (int j=0; j<10; j++)
         for (int i=0; i<100; i++) {
            Reference feedRef = new Reference(config.getServerLocation()+"R/"+i+"/");
            FeedClient feedClient = new FeedClient(client,feedRef);
            feedClient.setIdentity("admin","admin");

            Entry entry = null;
            if (!feedClient.exists()) {
               log.info("Creating feed "+i);
               Status status = feedClient.create("<feed xmlns='http://www.w3.org/2005/Atom'><title>Feed "+i+"</title></feed>");
               if (!status.isSuccess()) {
                  log.info("Failure, status="+status.getCode());
               }
               assertTrue(status.isSuccess());
            } else {

               log.info("Checking feed "+i);
               final AtomicReference<Entry> theEntry = new AtomicReference<Entry>();
               feedClient.get(new FeedDestination() {
                  public void onEntry(Document entryDoc) {
                     Entry entry = new Entry(entryDoc);
                     entry.index();
                     theEntry.set(entry);
                  }
               });
               entry = theEntry.get();
            }
            if (entry==null) {
               try {
                  log.info("Creating entry in "+i);
                  feedClient.createEntry("<entry xmlns='http://www.w3.org/2005/Atom'><title>Entry "+i+"</title></entry>");
               } catch (StatusException ex) {
                  log.info("Failure, status="+ex.getStatus().getCode());
                  assertTrue(false);
               }
            } else {
               log.info("Updating entry in "+i);
               entry.setTitle("Updated "+entry.getTitle());
               EntryClient entryClient = feedClient.getEntryClient(entry);
               Status status = entryClient.update();
               if (!status.isSuccess()) {
                  log.info("Failure, status="+status.getCode());
               }
               assertTrue(status.isSuccess());
View Full Code Here

            assertTrue(status.isSuccess());
       */
      for (int j=0; j<10; j++)
         for (int i=0; i<10; i++) {
            Reference feedRef = new Reference(config.getServerLocation()+"R/"+i+"/");
            FeedClient feedClient = new FeedClient(client,feedRef);
            feedClient.setIdentity("admin","admin");

            log.info("Checking feed "+j+","+i);
            Entry entry = null;
            final AtomicReference<Entry> theEntry = new AtomicReference<Entry>();
            Status status = feedClient.get(new FeedDestination() {
               public void onEntry(Document entryDoc) {
                  Entry entry = new Entry(entryDoc);
                  entry.index();
                  theEntry.set(entry);
               }
            }).getStatus();
            if (status.getCode()==404) {
               log.info("Creating feed "+j+","+i);
               status = feedClient.create("<feed xmlns='http://www.w3.org/2005/Atom'><title>Feed "+j+","+i+"</title></feed>");
               if (!status.isSuccess()) {
                  log.info("Failure, status="+status.getCode());
               }
               assertTrue(status.isSuccess());
            } else if (status.isSuccess()) {
               entry = theEntry.get();
            } else {
               if (!status.isSuccess()) {
                  log.info("Failure, status="+status.getCode());
               }
               assertTrue(status.isSuccess());
            }
            if (entry==null) {
               try {
                  log.info("Creating entry in "+j+","+i);
                  feedClient.createEntry("<entry xmlns='http://www.w3.org/2005/Atom'><title>Entry "+i+"</title></entry>");
               } catch (StatusException ex) {
                  log.info("Failure, status="+ex.getStatus().getCode());
                  assertTrue(false);
               }
            } else {
               log.info("Updating entry in "+i);
               entry.setTitle("Updated "+entry.getTitle());
               EntryClient entryClient = feedClient.getEntryClient(entry);
               status = entryClient.update();
               if (!status.isSuccess()) {
                  log.info("Failure, status="+status.getCode());
               }
               assertTrue(status.isSuccess());
View Full Code Here

TOP

Related Classes of org.atomojo.app.client.FeedClient

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.