Package org.restlet

Examples of org.restlet.Context


      URI uri = getIntrospection();
      if (uri==null) {
         uri = getRoot();
      }
      AuthCredentials auth = getAuthCredentials();
      Client client = new Client(new Context(db.getLogger()),Protocol.valueOf(uri.getScheme()));
      client.getContext().getAttributes().put("hostnameVerifier", org.apache.commons.ssl.HostnameVerifier.DEFAULT);
     
      Request request = new Request(Method.HEAD,uri.toString());
      request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,auth.getName(),auth.getPassword()));
      Response response = client.handle(request);
View Full Code Here


      }

      public Application getApplication(Context context,Map<String,List<Link>> links)
         throws InstantiationException,IllegalAccessException,NoSuchMethodException,InvocationTargetException
      {
         Context appContext = context.createChildContext();
         for (Parameter param : context.getParameters()) {
            String name = param.getName();
            if (name.equals("keystorePath") ||
                name.equals("keystorePassword") ||
                name.equals("keyPassword")) {
               continue;
            }
            appContext.getParameters().add(param);
         }
         IdentityManager manager = (IdentityManager)context.getAttributes().get(IdentityManager.ATTR);
         if (manager!=null) {
            appContext.getAttributes().put(IdentityManager.ATTR,manager);
         }
         appContext.getAttributes().put(WebComponent.LINKS_ATTR,links);
         Object scriptManager = context.getAttributes().get(ScriptManager.ATTR);
         if (scriptManager!=null) {
            appContext.getAttributes().put(ScriptManager.ATTR,scriptManager);
         }
         Object resourceManager = context.getAttributes().get(ResourceManager.ATTR);
         if (resourceManager!=null) {
            appContext.getAttributes().put(ResourceManager.ATTR,resourceManager);
         }
         for (String name : parameters.keySet()) {
            appContext.getLogger().info("Setting parameter "+name+"="+parameters.get(name));
            appContext.getParameters().add(name,parameters.get(name));
         }
         return appDef.getInstance(appContext);
      }
View Full Code Here

         for (String name : iface.getHosts().keySet()) {
            final Configuration.Host host = iface.getHosts().get(name);
            if (confHosts.get(host.getName()) != null) {
               getLogger().warning("Ignoring duplicate host name " + host.getName());
            } else {
               Context hostContext = getContext().createChildContext();
              
               ConfiguredHost confHost = new ConfiguredHost(hostContext, getInternalRouter(), iface, host, new Date(), true);
               confHosts.put(host.getName(), confHost);
               if (host.getLinks().get("autoconf") != null) {
                  hasStaticAutoConf = true;
View Full Code Here

                           getLogger().warning("Ignoring duplicate host for " + host.getName() + " from auto-configuration.");
                           return;
                        }
                     }

                     Context hostContext = getContext().createChildContext();
                    
                     ConfiguredHost confHost = new ConfiguredHost(hostContext, getInternalRouter(),iface, host, edited, false);

                     // The auto host should not be in confHosts as it isn't static
                     //confHosts.put(host.getName(), confHost);
View Full Code Here

                  getLogger().info(t.getURI()+": "+t.getFirstValue());
               }
               getLogger().info(T_APP_MATCH.toString());
               Term classTerm = entry.getTerm(T_APP_CLASS);
               Term proxyTerm = entry.getTerm(T_APP_PROXY);
               Context appContext = context.createChildContext();
               LinkSet set = new LinkSet();
               set.addLinkSet(entry.getLinks());
               set.addLinkSet(hostConf.getLinks());
               appContext.getAttributes().put(WebComponent.LINKS_ATTR,set);
               appContext.getAttributes().put(ScriptManager.ATTR,scriptManager);
               appContext.getAttributes().put(ResourceManager.ATTR,resourceManager);
               for (URI t : entry.getTerms().keySet()) {
                  String value = entry.getTerm(t).getFirstValue();
                  getLogger().info("Setting parameter: "+t+"="+value);
                  appContext.getParameters().set(t.toString(),value,false);
               }
               appContext.getParameters().set("username",autoConf.getUsername(),false);
               appContext.getParameters().set("password",autoConf.getPassword(),false);
               for (Term t : entry.getTerms().values()) {
                  String key = t.getURI().toString();
                  if (t.getValues()!=null) {
                     for (String value : t.getValues()) {
                        appContext.getParameters().add(key, value);
                     }
                  } else {
                     appContext.getParameters().add(key,"true");
                  }
               }
               Application app = null;
               if (proxyTerm!=null) {
                  String value = proxyTerm.getFirstValue();
View Full Code Here

         entry.mediaType = mediaType;
         entry.query = query;
         List<Link> links = linkSet.get(relation);
         if (links!=null && links.size()>0) {
            entry.link = links.get(0);
            entry.client = new Client(new Context(log),Protocol.valueOf(entry.link.getLink().getScheme()));
            entry.resource = new Reference(entry.link.getLink().toString());           
         } else {
            entry.link = null;
            entry.resource = null;
            entry.client = null;
View Full Code Here

         this.mediaType = mediaType;
         this.query = query;
         List<Link> links = linkSet.get(relation);
         if (links!=null && links.size()>0) {
            link = links.get(0);
            client = new Client(new Context(log),Protocol.valueOf(link.getLink().getScheme()));
            resource = new Reference(link.getLink().toString());
         } else {
            link = null;
            resource = null;
            client = null;
View Full Code Here

     * @param plugin The plugin data that is going to be used on the update
     */
    @Deprecated
    public static void putPlugin(CookieSetting cS, String nodeId, MarketPlacePlugin plugin) {

        Client client = new Client(new Context(), Protocol.HTTP);
        client.getContext().getParameters().add("use ForwardedForHeader", "false");
        ClientResource pluginResource = new ClientResource(DRUPALPATH + "/rest/node/" + nodeId);
        pluginResource.setNext(client);
        pluginResource.getRequest().getCookies().add(cS);
        //the only data needed to update a plugin is the node, type, and field_os
View Full Code Here

     * @param nodeId The nodeId of the node on the drupal site
     * @param plugin The plugin data that is going to be used on the update
     */
    public static void putPlugin(CookieSetting cS, String nodeId, MarketPlacePlugin2 plugin) {

        Client client = new Client(new Context(), Protocol.HTTP);
        client.getContext().getParameters().add("use ForwardedForHeader", "false");
        ClientResource pluginResource = new ClientResource(DRUPALPATH + "/rest/node/" + nodeId);
        pluginResource.setNext(client);
        pluginResource.getRequest().getCookies().add(cS);
        //the only data needed to update a plugin is the node, type, field_os and plugin_category
View Full Code Here

     * @throws IOException
     */
    public static MarketPlaceFile postFile(CookieSetting cS, String uid, String pathName, String name) throws IOException {
        //TODO: check what happens when the file already exists
        // Instantiate the client connector, and configure it.
        Client client = new Client(new Context(), Protocol.HTTP);
        client.getContext().getParameters().add("use ForwardedForHeader", "false");

        ClientResource testFileResource = new ClientResource(DRUPALPATH + "/rest/file");

        testFileResource.setNext(client);
View Full Code Here

TOP

Related Classes of org.restlet.Context

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.