Examples of RequestParameter


Examples of org.apache.sling.api.request.RequestParameter

  public void process(SlingHttpServletRequest request,
      List<Modification> changes) throws Exception {

    Session session = request.getResourceResolver().adaptTo(Session.class);

    RequestParameter linkParam = request.getRequestParameter(":link");
    if (linkParam != null){
      String linkPath = linkParam.getString();
      // check if a new node have been created
      if (changes.size() > 0 && changes.get(0).getType() == ModificationType.CREATE) {
        // hack to get the resource path
        // is it possible to add the response to the method header ?
        String resourcePath = changes.get(0).getSource();
View Full Code Here

Examples of org.apache.sling.api.request.RequestParameter

  private MessageStore store;

  @Override
  protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
      throws ServletException, IOException {
    RequestParameter param = request.getRequestParameter(IMPORT_FILE_ATTRIB_NAME);
    if (param != null) {
      logger.info("Processing attachment: " + param.toString());

      InputStream mboxIS = param.getInputStream();
      store.saveAll(parser.parse(mboxIS));

      response.sendRedirect(MailArchiveServerConstants.ARCHIVE_PATH + ".html");
    } else {
      logger.info("No attachment to process.");
View Full Code Here

Examples of org.apache.sling.api.request.RequestParameter

    private MailStatsProcessor processor;

    @Override
    protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
            throws ServletException, IOException {
        final RequestParameter param = request.getRequestParameter(IMPORT_FILE_ATTRIB_NAME);
        if(param == null) {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Missing required parameter " + IMPORT_FILE_ATTRIB_NAME);
            return;
        }
       
        InputStream is = null;
        final PrintWriter pw = response.getWriter();
        response.setContentType("text/plain");
        response.setCharacterEncoding("UTF-8");
       
        try {
            is = param.getInputStream();
            pw.println("Creating stats from supplied mbox file...");
            int counter=0;
            final Iterator<Message> it = parser.parse(is);
            while(it.hasNext()) {
                final Message m = it.next();
View Full Code Here

Examples of org.apache.sling.api.request.RequestParameter

    public void setContentImporter(ContentImporter importer) {
        this.contentImporter = importer;
    }

    private String getRequestParamAsString(SlingHttpServletRequest request, String key) {
      RequestParameter requestParameter = request.getRequestParameter(key);
      if (requestParameter == null) {
        return null;
      }
      return requestParameter.getString();
    }
View Full Code Here

Examples of org.apache.sling.api.request.RequestParameter

        }
        final String contentRootName = targetName + "." + contentType;

        try {
            InputStream contentStream = null;
          RequestParameter contentParameter = request.getRequestParameter(SlingPostConstants.RP_CONTENT);
            if (contentParameter != null) {
                contentStream = contentParameter.getInputStream();
            } else {
                RequestParameter contentFile = request.getRequestParameter(SlingPostConstants.RP_CONTENT_FILE);
                if (contentFile != null) {
                    contentStream = contentFile.getInputStream();
                }
            }

            if (contentStream == null) {
                response.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED,
View Full Code Here

Examples of org.apache.sling.api.request.RequestParameter

    // SLING-1091: If a :name parameter is supplied, the (first) value of this parameter is used unmodified as the name
    //    for the new node. If the name is illegally formed with respect to JCR name requirements, an exception will be
    //    thrown when trying to create the node. The assumption with the :name parameter is, that the caller knows what
    //    he (or she) is supplying and should get the exact result if possible.
    RequestParameterMap parameters = request.getRequestParameterMap();
    RequestParameter specialParam = parameters.getValue(SlingPostConstants.RP_NODE_NAME);
    if ( specialParam != null ) {
        if ( specialParam.getString() != null && specialParam.getString().length() > 0 ) {
            // If the path ends with a *, create a node under its parent, with
            // a generated node name
            basePath = basePath += "/" + specialParam.getString();

            // if the resulting path already exists then report an error
            Session session = request.getResourceResolver().adaptTo(Session.class);
              String jcrPath = removeAndValidateWorkspace(basePath, session);
              if (request.getResourceResolver().getResource(jcrPath) != null) {
View Full Code Here

Examples of org.apache.sling.api.request.RequestParameter

     * @param request
     * @param key
     * @return
     */
    public static boolean hasMany(SlingHttpServletRequest request, String key) {
        final RequestParameter rp = request.getRequestParameter(key);
        if (rp == null) {
            return false;
        }
        return getAll(request, key).length > 1;
    }
View Full Code Here

Examples of org.apache.sling.api.request.RequestParameter

     * @param request
     * @param key
     * @return
     */
    public static String[] getAll(SlingHttpServletRequest request, String key) {
        final RequestParameter rp = request.getRequestParameter(key);
        if (rp == null) {
            return new String[0];
        }
        return StringUtils.split(rp.getString(), DELIMITER);
    }
View Full Code Here

Examples of org.apache.sling.api.request.RequestParameter

    public boolean requestDataUsed() {
        return this.requestDataUsed;
    }

    public String getParameter(String name) {
        RequestParameter param = this.getRequestParameter(name);
        return (param != null) ? param.getString() : null;
    }
View Full Code Here

Examples of org.apache.sling.api.request.RequestParameter

        // Parse the request
        try {
            List<?> /* FileItem */items = upload.parseRequest(rc);
            for (Iterator<?> ii = items.iterator(); ii.hasNext();) {
                FileItem fileItem = (FileItem) ii.next();
                RequestParameter pp = new MultipartRequestParameter(fileItem);
                parameters.addParameter(fileItem.getFieldName(), pp);
            }
        } catch (FileUploadException fue) {
            // TODO: log
        }
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.