Examples of ResponseContextException


Examples of org.apache.abdera.protocol.server.context.ResponseContextException

  @Override
  public Node postMedia(MimeType mimeType, String slug,
                               InputStream inputStream, RequestContext request)
    throws ResponseContextException {
    if (slug == null) {
      throw new ResponseContextException("A slug header must be supplied.", 500);
    }
    Node n = postEntry(slug, null, null, new Date(), null, null, request);
   
    try {
      n.setProperty(MEDIA, inputStream);
      n.setProperty(CONTENT_TYPE, mimeType.toString());

      String summary = postSummaryForEntry(n);
      if (summary != null) {
        n.setProperty(SUMMARY, summary);
      }

      getSession(request).save();
     
      return n;
    } catch (RepositoryException e) {
      try {
        getSession(request).refresh(false);
      } catch (Throwable t) {
        log.warn(t);
      }
      throw new ResponseContextException(500, e);
    }
  }
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.ResponseContextException

      try {
        session.refresh(false);
      } catch (Throwable t) {
        log.warn(t);
      }     
      throw new ResponseContextException(500, e);
    }
  }
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.ResponseContextException

                              Content content, Session session)
    throws ResponseContextException, RepositoryException {
    if (title == null) {
      EmptyResponseContext ctx = new EmptyResponseContext(500);
      ctx.setStatusText("Entry title cannot be empty.");
      throw new ResponseContextException(ctx);
    }

    entry.setProperty(TITLE, title);

    if (summary != null) {
      entry.setProperty(SUMMARY, summary);
    }
   
    Calendar upCal = Calendar.getInstance();
    upCal.setTime(updated);
    entry.setProperty(UPDATED, upCal);

    if (authors != null) {
      for (Person p : authors) {
        Node addNode = entry.addNode(AUTHOR);
        addNode.setProperty(AUTHOR_EMAIL, p.getEmail());
        addNode.setProperty(AUTHOR_LANGUAGE, p.getLanguage());
        addNode.setProperty(AUTHOR_NAME, p.getName());
      }
    }

    if (content != null) {
      switch(content.getContentType()) {
      case TEXT:
  entry.setProperty(CONTENT, content.getText());
  entry.setProperty(CONTENT_TYPE, Type.TEXT.toString());
  break;
      case XHTML:
  entry.setProperty(CONTENT, asString(content));
  entry.setProperty(CONTENT_TYPE, Type.XHTML.toString());
  break;
      default:
  throw new ResponseContextException("Invalid content element type.", 500);
      }
    }

    if (summary != null) {
      entry.setProperty(SUMMARY, summary);
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.ResponseContextException

  private String asString(Content content2) throws ResponseContextException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    try {
  content2.<Element>getFirstChild().writeTo(bos);
    } catch (IOException e) {
      throw new ResponseContextException(500, e);
    }
    return new String(bos.toByteArray());
  }
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.ResponseContextException

      try {
        session.refresh(false);
      } catch (Throwable t) {
        log.warn(t);
      }           
      throw new ResponseContextException(500, e);
    }
  }
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.ResponseContextException

  private Node getNode(Session session, String resourceName) throws ResponseContextException,
    RepositoryException {
    try {
      return session.getNodeByUUID(collectionNodeId).getNode(resourceName);
    } catch (PathNotFoundException e) {
      throw new ResponseContextException(404);
    }
  }
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.ResponseContextException

          authors.add(author);
        }
      }
      return authors;
    } catch (RepositoryException e) {
      throw new ResponseContextException(500, e);
    }
  }
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.ResponseContextException

      Node n = session.getNodeByUUID(collectionNodeId);
      for (NodeIterator nodes = n.getNodes(); nodes.hasNext();) {
        entries.add(nodes.nextNode());
      }
    } catch (RepositoryException e) {
      throw new ResponseContextException(500, e);
    }

    return entries;
  }
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.ResponseContextException

  @Override
  public Node getEntry(String resourceName, RequestContext request) throws ResponseContextException {
    try {
      return getNode(getSession(request), resourceName);
    } catch (RepositoryException e) {
      throw new ResponseContextException(500, e);
    }
  }
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.ResponseContextException

  @Override
  public String getId(Node entry) throws ResponseContextException {
    try {
      return "urn:" + entry.getUUID();
    } catch (RepositoryException e) {
      throw new ResponseContextException(500, e);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.