Package org.apache.abdera.protocol.server

Examples of org.apache.abdera.protocol.server.Target


      } else
        return ProviderHelper.notfound(request);
  }

  private void setEditDetail(RequestContext request) throws IOException {
    Target target = request.getTarget();
    String feed = target.getParameter("feed");
    String id = target.getParameter("entry");
    Entry entry = (Entry) request.getDocument().getRoot();
    entry.setEdited(new Date());
    Link link = entry.getEditLink();
    Map<String,Object> params = new HashMap<String,Object>();
    params.put("feed", feed);
View Full Code Here


    }
  }
 
  public ResponseContext postEntry(
    RequestContext request) {
      Target target = request.getTarget();
      String feed = target.getParameter("feed");
      Session session = new Session(host,port);
      Database db = session.getDatabase(feed);
      try {
        CharArrayWriter cwriter = new CharArrayWriter();
        setEditDetail(request);
View Full Code Here

    return Sanitizer.sanitize(slug, "", true, Normalizer.Form.D);
  }
 
  public ResponseContext getEntry(
    RequestContext request) {
      Target target = request.getTarget();
      String feed = target.getParameter("feed");
      String entry = target.getParameter("entry");
      Session session = new Session(host,port);
      Database db = session.getDatabase(feed);
      Document doc = null;
      try {
        doc = db.getDocument(entry);
View Full Code Here

        return ProviderHelper.notfound(request);
  }
 
  public ResponseContext putEntry(
    RequestContext request) {
      Target target = request.getTarget();
      String feed = target.getParameter("feed");
      Session session = new Session(host,port);
      Database db = session.getDatabase(feed);
      try {
        CharArrayWriter cwriter = new CharArrayWriter();
        setEditDetail(request);
        request.getDocument().getRoot().writeTo("json", cwriter);
        String json = new String(cwriter.toCharArray());
        JSONObject obj = JSONObject.fromObject(json);
        String key = target.getParameter("entry");
        Document doc = null;
        try {
          doc = db.getDocument(key);
        } catch (Exception e) {
          // error if the doc isn't found, we deal with the null result below
View Full Code Here

    RegexTargetResolver r = new RegexTargetResolver();
    r.setPattern("", TargetType.TYPE_SERVICE);
    r.setPattern("/([^/?#]+)", TargetType.TYPE_COLLECTION);
   
    DummyRequestContext drc = null;
    Target target = null;
   
    drc = new DummyRequestContext("/test","http://example.org/");
    target = r.resolve(drc);
    assertNotNull(target);
    assertEquals(target.getType(), TargetType.TYPE_SERVICE);
   
    drc = new DummyRequestContext("/test/foo","http://example.org/");
    target = r.resolve(drc);
    assertNotNull(target);
    assertEquals(target.getType(), TargetType.TYPE_COLLECTION);
   
    drc = new DummyRequestContext("/test/foo/","http://example.org/");
    target = r.resolve(drc);
    assertNull(target);
View Full Code Here

    if (provider == null) {
      noprovider(response);
      return false;
    }
    // Check The Target
    Target target = request.getTarget();
    if (target == null) {
      notfound(response);
      return false;
    }
    // Check The Method
    if (!checkMethod(provider,request)) {
      notallowed(
        response,
        request.getMethod(),
        provider.getAllowedMethods(target.getType()));
      return false;
    }
    return true;
  }
View Full Code Here

  protected boolean checkMethod(
    Provider provider,
    RequestContext context)
      throws IOException {
    String method = context.getMethod();
    Target target = context.getTarget();
    String[] methods = provider.getAllowedMethods(target.getType());
    java.util.Arrays.sort(methods);
    return (java.util.Arrays.binarySearch(methods, method) >= 0);
  }
View Full Code Here

   * @param request Request context
   * @return All parameters on request context
   */
  protected Map<String, Object> getRequestParams(RequestContext request) {
    Map<String, Object> params = new HashMap<String, Object>();
    Target target = request.getTarget();
    for (String name: target.getParameterNames()) {
      params.put(name, target.getParameter(name));
    }

    String userEmail = getUserEmailForRequest(request);
    if (userEmail != null) {
      params.put("opensocial_viewer_email", userEmail);
View Full Code Here

      return ProviderHelper.returnBase(document, responseCode, null);
    }
  }

  protected String getEntryId(RequestContext request) {
    Target target = request.getTarget();
    String entryId = target.getParameter(PARAM_ENTRY);
    return entryId;
  }
View Full Code Here

TOP

Related Classes of org.apache.abdera.protocol.server.Target

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.