Package org.atomojo.app.client

Examples of org.atomojo.app.client.Link


     
      hostConf.attach(router);
     
      this.staticApplications = new ArrayList<AppInfo>();
      List<Link> metadataSet = hostConf.getLinks().get("metadata");
      Link metadata = metadataSet==null ? null : metadataSet.size()>0 ? metadataSet.get(0) : null;
      List<Link> autoconfList = hostConf.getLinks().get("autoconf");
      this.resourceManager = new ResourceManager(getLogger(),hostConf.getLinks());
      this.context.getAttributes().put(ResourceManager.ATTR, resourceManager);
      // TODO: make the expiration configurable
      client = context.getClientDispatcher();
View Full Code Here


               }
               Application app = null;
               if (proxyTerm!=null) {
                  String value = proxyTerm.getFirstValue();
                  List<Link> links = entry.getLinks().get(value);
                  Link target = null;
                  if (links!=null && links.size()>0) {
                     target = links.get(0);
                  }
                  if (target==null) {
                     links = hostConf.getLinks().get(value);
                     if (links!=null && links.size()>0) {
                        target = links.get(0);
                     }
                  }
                  if (target!=null) {
                     app = new ProxyApplication(appContext,target);
                  }
               } else if (classTerm!=null) {
                  String className = classTerm.getFirstValue();
                  List<Link> libraryLinks = entry.getLinks().get("library");
                  String href = null;
                  Text text = entry.getContent();
                  if (text!=null) {
                     href = text.getSourceLink();
                  }
                  Class<Application> appClass = null;
                  Class<?> foundClass = null;
                  if ((libraryLinks==null || libraryLinks.size()==0) && href==null) {
                     foundClass = Class.forName(className);
                  } else {
                     URL [] downloads = new URL[(libraryLinks==null ? 0 : libraryLinks.size())+(href==null ? 0 : 1)];
                     if (href!=null) {
                        downloads[0] = entry.getDocument().getDocumentElement().getBaseURI().resolve(href).toURL();
                     }
                     if (libraryLinks!=null) {
                        for (int pos = href==null ? 0 : 1; pos<libraryLinks.size(); pos++) {
                           Link link = libraryLinks.get(pos);
                           downloads[pos] = link.getLink().toURL();
                        }
                     }
                    
                     URL [] urls = new URL[downloads.length];
                     for (int i=0; i<downloads.length; i++) {
View Full Code Here

            Element linkE = links.next();
            String href = linkE.getAttributeValue("href");
            if (href!=null) {
               URI tlocation = linkE.getBaseURI().resolve(href);
               String mtype = linkE.getAttributeValue("type");
               Link l = new Link(linkE.getAttributeValue("rel"),mtype==null ? null : MediaType.valueOf(mtype),tlocation);
               l.setIdentity(linkE.getAttributeValue("username"),linkE.getAttributeValue("password"));
               if (l.getRelation()!=null) {
                  server.getLinks().put(l.getRelation(),l);
               }
            }
         }
        
         Iterator<Element> hostElements = serverE.getElementsByName(HOST);
View Full Code Here

            Element linkE = links.next();
            String href = linkE.getAttributeValue("href");
            if (href!=null) {
               URI tlocation = linkE.getBaseURI().resolve(href);
               String mtype = linkE.getAttributeValue("type");
               Link l = new Link(linkE.getAttributeValue("rel"),mtype==null ? null : MediaType.valueOf(mtype),tlocation);
               l.setIdentity(linkE.getAttributeValue("username"),linkE.getAttributeValue("password"));
               if (l.getRelation()!=null) {
                  linkSet.put(l.getRelation(),l);
               }
            }
         }
      }
View Full Code Here

            Element linkE = appLinks.next();
            String href = linkE.getAttributeValue("href");
            if (href!=null) {
               URI tlocation = linkE.getBaseURI().resolve(href);
               String mtype = linkE.getAttributeValue("type");
               Link l = new Link(linkE.getAttributeValue("rel"),mtype==null ? null : MediaType.valueOf(mtype),tlocation);
               l.setIdentity(linkE.getAttributeValue("username"),linkE.getAttributeValue("password"));
               if (l.getRelation()!=null) {
                  confLinks.put(l.getRelation(),l);
               }
            }
         }
        
         loadContext(appContext,useConf);
View Full Code Here

      Iterator<Element> autoconfElements = top.getElementsByName(AdminXML.NM_AUTOCONF);
      while (autoconfElements.hasNext()) {
         Element autoconfE = autoconfElements.next();
         String href = autoconfE.getAttributeValue("href");
         if (href!=null) {
            Link l = new Link("autoconf",MediaType.APPLICATION_ATOM_XML,autoconfE.getBaseURI().resolve(href));
            l.setIdentity(autoconfE.getAttributeValue("username"),autoconfE.getAttributeValue("password"));
            autoconfs.add(l);
         }
      }
      Iterator<Element> interfaceElements = top.getElementsByName(AdminXML.NM_INTERFACE);
      while (interfaceElements.hasNext()) {
View Full Code Here

      }
      if ((args.length-index)<2) {
         System.err.println("A source and target feed URI is required.");
         return;
      }
      Link source = new Link("source",toURI(args[index]));
      if (sourceIdentity!=null) {
         int colon = sourceIdentity.indexOf(':');
         source.setIdentity(sourceIdentity.substring(0,colon), sourceIdentity.substring(colon+1));
      }
      Link target = new Link("target",toURI(args[index+1]));
      if (targetIdentity!=null) {
         int colon = targetIdentity.indexOf(':');
         target.setIdentity(targetIdentity.substring(0,colon), targetIdentity.substring(colon+1));
      }
      FeedSynchronizer sync = new FeedSynchronizer(source,target);
      sync.run();
      int errorCount = sync.getErrorCount();
      if (errorCount>0) {
View Full Code Here

         context.getParameters().set(name,value,false);
      }

      List<Link> auths = hostConf.getLinks().get("auth-service");
      if (auths!=null && auths.size()>0) {
         Link authLink = auths.get(0);
         getLogger().info("Adding identity and security filters.");
         router = new Router(context);
         router.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
         security = new SecurityGuard(context);
         security.setNext(router);
         final IdentityFilter filter = new IdentityFilter(context,security,new Reference(authLink.getLink().toString()));
         vhost.attachDefault(filter);
         this.context.getAttributes().put(IdentityManager.ATTR, new IdentityManager() {
            public void add(String id,Identity identity) {
               filter.addIdentity(id, identity);
            }
            public boolean remove(String id)
            {
               return filter.removeIdentity(id);
            }
         });
      }
      this.staticApplications = new ArrayList<AppInfo>();
      for (Configuration.Content content : hostConf.getContentSources()) {
         try {
            final String uri = content.getSource().toString();
            String scheme = content.getSource().getScheme();
            if (scheme.equals("http") || scheme.equals("https")) {
               getLogger().info("  Proxy: "+content.getSource()+" at "+content.getMatch());
               ProxyApplication proxy = new ProxyApplication(context,uri.toString());
               proxy.getTunnelService().setEnabled(false);
               router.attach(content.getMatch(),proxy);
            } else {
               // hope the directory resource can handle it
               getLogger().info("  Directory: "+content.getSource()+" at "+content.getMatch());
               Application app = new Application(context) {
                  public Restlet createRoot() {
                     Directory directory = new Directory(getContext(),uri);
                     directory.setIndexName("index.html");
                     return directory;
                  }
               };
               router.attach(content.getMatch(),app);
            }
         } catch (Exception ex) {
            getLogger().log(Level.SEVERE,"Cannot add content at "+content.getMatch(),ex);
         }
      }
      List<Link> metadataSet = hostConf.getLinks().get("metadata");
      Link metadata = metadataSet==null ? null : metadataSet.size()>0 ? metadataSet.get(0) : null;
      List<Link> autoconfList = hostConf.getLinks().get("autoconf");
      this.resourceManager = new ResourceManager(getLogger(),hostConf.getLinks());
      this.context.getAttributes().put(ResourceManager.ATTR, resourceManager);
      // TODO: make the expiration configurable
      client = context.getClientDispatcher();
View Full Code Here

               }
               Application app = null;
               if (proxyTerm!=null) {
                  String value = proxyTerm.getFirstValue();
                  List<Link> links = entry.getLinks().get(value);
                  Link target = null;
                  if (links!=null && links.size()>0) {
                     target = links.get(0);
                  }
                  if (target==null) {
                     links = hostConf.getLinks().get(value);
                     if (links!=null && links.size()>0) {
                        target = links.get(0);
                     }
                  }
                  if (target!=null) {
                     app = new ProxyApplication(appContext,target);
                  }
               } else if (classTerm!=null) {
                  String className = classTerm.getFirstValue();
                  List<Link> libraryLinks = entry.getLinks().get("library");
                  String href = null;
                  Text text = entry.getContent();
                  if (text!=null) {
                     href = text.getSourceLink();
                  }
                  Class<Application> appClass = null;
                  Class<?> foundClass = null;
                  if ((libraryLinks==null || libraryLinks.size()==0) && href==null) {
                     foundClass = Class.forName(className);
                  } else {
                     URL [] downloads = new URL[(libraryLinks==null ? 0 : libraryLinks.size())+(href==null ? 0 : 1)];
                     if (href!=null) {
                        downloads[0] = entry.getDocument().getDocumentElement().getBaseURI().resolve(href).toURL();
                     }
                     if (libraryLinks!=null) {
                        for (int pos = href==null ? 0 : 1; pos<libraryLinks.size(); pos++) {
                           Link link = libraryLinks.get(pos);
                           downloads[pos] = link.getLink().toURL();
                        }
                     }
                    
                     URL [] urls = new URL[downloads.length];
                     for (int i=0; i<downloads.length; i++) {
View Full Code Here

      getLogger().info("app.link="+relation);
      if (relation!=null) {
         LinkSet linkSet = (LinkSet)context.getAttributes().get("org.atomojo.www.app.links");
         List<Link> links = linkSet.get(relation);
         if (links!=null && links.size()>0) {
            Link link = links.get(0);
            base = link.getLink().toString();
            username = link.getUsername();
            password = link.getPassword();
         }
      }
   }
View Full Code Here

TOP

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

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.