Package org.restlet

Examples of org.restlet.Context


   {
      this(client,URI.create(location.toString()),URI.create(editURI.toString()));
   }
   public FeedClient(Client client,URI location,URI editURI)
   {
      this.context = new Context(Logger.getLogger(EntryClient.class.getName()));
      this.feed = null;
      this.location = location;
      this.editURI = editURI;
      this.locClient = client==null ? new Client(context,Protocol.valueOf(location.getScheme())) : client;
      locClient.getContext().getAttributes().put("hostnameVerifier", org.apache.commons.ssl.HostnameVerifier.DEFAULT);
View Full Code Here


   }
   /** Creates a new instance of FeedClient */
   public FeedClient(Client client,URI location,URI editURI,Identity identity)
   {
      super(identity);
      this.context = new Context(Logger.getLogger(EntryClient.class.getName()));
      this.feed = null;
      this.location = location;
      this.editURI = editURI;
      this.locClient = client==null ? new Client(context,Protocol.valueOf(location.getScheme())) : client;
      locClient.getContext().getAttributes().put("hostnameVerifier", org.apache.commons.ssl.HostnameVerifier.DEFAULT);
View Full Code Here

   }
  
   public FeedClient(Feed feed,Identity identity)
   {
      super(identity);
      this.context = new Context(Logger.getLogger(EntryClient.class.getName()));
      this.feed = feed;
      this.location = feed.getDocument().getBaseURI();
      List<Link> editLinks = feed.getLinks().get("edit");
      if (editLinks==null || editLinks.size()==0) {
         this.editURI = this.location;
View Full Code Here

         return Status.CLIENT_ERROR_NOT_FOUND;
      }
     
      URI mediaURI = media.getLocation();
      if (client==null) {
         client = new Client(new Context(Logger.getLogger(EntryClient.class.getName())),Protocol.valueOf(mediaURI.getScheme()));
         client.getContext().getAttributes().put("hostnameVerifier", org.apache.commons.ssl.HostnameVerifier.DEFAULT);
      }
      Request request = new Request(Method.PUT,mediaURI.toString());
      if (identity!=null) {
         request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,identity.getName(),identity.getPassword()));
View Full Code Here

  
   public Status get()
      throws IOException,XMLException
   {
      if (client==null) {
         client = new Client(new Context(Logger.getLogger(EntryClient.class.getName())),location.getSchemeProtocol());
         client.getContext().getAttributes().put("hostnameVerifier", org.apache.commons.ssl.HostnameVerifier.DEFAULT);
      }
      Request request = new Request(Method.GET,location);
      if (identity!=null) {
         request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,identity.getName(),identity.getPassword()));
View Full Code Here

   }
  
   public Status exists()
   {
      if (client==null) {
         client = new Client(new Context(Logger.getLogger(EntryClient.class.getName())),location.getSchemeProtocol());
         client.getContext().getAttributes().put("hostnameVerifier", org.apache.commons.ssl.HostnameVerifier.DEFAULT);
      }
      Request request = new Request(Method.HEAD,location);
      if (identity!=null) {
         request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,identity.getName(),identity.getPassword()));
View Full Code Here

         entryLoc = new Reference(entryURI.toString());
      } else {
         entryLoc = location;
      }
      if (client==null) {
         client = new Client(new Context(Logger.getLogger(EntryClient.class.getName())),entryLoc.getSchemeProtocol());
         client.getContext().getAttributes().put("hostnameVerifier", org.apache.commons.ssl.HostnameVerifier.DEFAULT);
      }
      Request request = new Request(Method.DELETE,entryLoc);
      if (identity!=null) {
         request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,identity.getName(),identity.getPassword()));
View Full Code Here

      System.out.println(entryURI.toString());
      System.out.flush();
       */
     
      if (client==null) {
         client = new Client(new Context(Logger.getLogger(EntryClient.class.getName())),Protocol.valueOf(entryURI.getScheme()));
         client.getContext().getAttributes().put("hostnameVerifier", org.apache.commons.ssl.HostnameVerifier.DEFAULT);
      }
      Request request = new Request(Method.PUT,entryURI.toString());
      if (identity!=null) {
         request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,identity.getName(),identity.getPassword()));
View Full Code Here

                                 log.log(Level.SEVERE,"I/O error while deleting entry for media "+src,ex);
                              }
                              // we have a media entry
                              URI srcRef = baseURI.resolve(src);

                              Client client = new Client(new Context(log),Protocol.valueOf(srcRef.getScheme()));
                              client.getContext().getAttributes().put("hostnameVerifier", org.apache.commons.ssl.HostnameVerifier.DEFAULT);
                              Request request = new Request(Method.GET,new Reference(srcRef.toString()));
                              if (auth!=null) {
                                 if (auth.getScheme().equals("cookie")) {
                                    Cookie cookie = new Cookie(auth.getName(),auth.getPassword());
                                    cookie.setPath("/");
                                    request.getCookies().add(cookie);
                                 } else {
                                    request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,auth.getName(),auth.getPassword()));
                                 }
                              }
                              Response response = client.handle(request);
                              if (!response.getStatus().isSuccess()) {
                                 log.log(Level.SEVERE,"Failed to retrieve media, status="+response.getStatus().getCode()+", src="+srcRef);
                                 errorCount++;
                                 return;
                              }
                              if (contentType!=null) {
                                 // The entry's media type wins.  Sometimes file resources do not
                                 // report the media type correctly
                                 response.getEntity().setMediaType(contentType);
                              }
                              try {
                                 entry = app.createMediaEntry(user,feed,response.getEntity(),src,entryId);
                                 app.updateEntry(user,feed,entry,entryDoc);
                              } catch (AppException ex) {
                                 log.severe("Failed to create media entry "+index.getId()+", src="+srcRef);
                                 if (ex.getStatus()==Status.SERVER_ERROR_INTERNAL) {
                                    log.log(Level.SEVERE,ex.getMessage(),ex);
                                 } else {
                                    log.severe("Status="+ex.getStatus().getCode()+", "+ex.getMessage());
                                 }
                                 errorCount++;
                              }
                           }
                        } else {
                           try {
                              app.updateEntry(user,feed,entryId,entryDoc);
                           } catch (AppException ex) {
                              if (ex.getStatus()==Status.SERVER_ERROR_INTERNAL) {
                                 log.log(Level.SEVERE,ex.getMessage(),ex);
                              } else {
                                 log.severe("Status="+ex.getStatus().getCode()+", "+ex.getMessage());
                              }
                              errorCount++;
                              return;
                           }
                           if (src!=null) {
                              URI srcRef = baseURI.resolve(src);

                              Client client = new Client(new Context(log),Protocol.valueOf(srcRef.getScheme()));
                              client.getContext().getAttributes().put("hostnameVerifier", org.apache.commons.ssl.HostnameVerifier.DEFAULT);
                              /*
                             
                              Request headRequest = new Request(Method.HEAD,new Reference(srcRef.toString()));
                              if (auth!=null) {
View Full Code Here

      }
   }
  
   protected boolean feedExists(URI location)
   {
      Client client = new Client(new Context(log),Protocol.valueOf(location.getScheme()));
      client.getContext                                                                                                                                                             ().getAttributes().put("hostnameVerifier", org.apache.commons.ssl.HostnameVerifier.DEFAULT);
      Request request = new Request(Method.HEAD,location.toString());
      request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,username,password));
      Response response = client.handle(request);
      return response.getStatus().isSuccess();
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.