Package org.apache.sling.api.request

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


        // find the first request parameter that matches one of
        // our parameterNames, in order, and has a value
        if (parameters!=null) {
            // we first check for the special sling parameters
            RequestParameter specialParam = parameters.getValue(SlingPostConstants.RP_NODE_NAME);
            if ( specialParam != null ) {
                if ( specialParam.getString() != null && specialParam.getString().length() > 0 ) {
                    valueToUse = specialParam.getString();
                    doFilter = false;
                }
            }
            if ( valueToUse == null ) {
                specialParam = parameters.getValue(SlingPostConstants.RP_NODE_NAME_HINT);
                if ( specialParam != null ) {
                    if ( specialParam.getString() != null && specialParam.getString().length() > 0 ) {
                        valueToUse = specialParam.getString();
                    }
                }
            }

            if (valueToUse == null) {
View Full Code Here


        for (int i = 0; i < kvs.length; i++) {
            final Param kv = kvs[i];
            final RequestParameter[] param = new RequestParameter[kv.value.length];
            for (int j = 0; j < kv.value.length; j++) {
                final String strValue = kv.value[j];
                final RequestParameter aparam = context.mock(RequestParameter.class, "requestParameter" + i + "#" + j);
                context.checking(new Expectations() {
                    {
                        allowing(aparam).getString();
                        will(returnValue(strValue));
                    }
View Full Code Here

        }

        if (items != null && items.size() > 0) {
            for (Iterator<?> ii = items.iterator(); ii.hasNext();) {
                FileItem fileItem = (FileItem) ii.next();
                RequestParameter pp = new MultipartRequestParameter(fileItem);
                parameters.addParameter(pp, false);
            }
        }
    }
View Full Code Here

    }

    //---------- String parameter support

    public String getStringValue(final String name) {
        final RequestParameter param = getValue(name);
        return (param != null) ? param.getString() : null;
    }
View Full Code Here

    }

    // ---------- Servlet API 3.0 Part

    public Object getPart(final String name) {
        final RequestParameter p = this.getValue(name);
        if (p instanceof MultipartRequestParameter) {
            return new SlingPart((MultipartRequestParameter) p);
        }

        // no such part
View Full Code Here

        String resourcePath = request.getResource().getPath();
        if (session.itemExists(resourcePath)) {
            Node source = (Node) session.getItem(resourcePath);

            // create a symetric link
            RequestParameter linkParam = request.getRequestParameter("target");
            if (linkParam != null) {
                String linkPath = linkParam.getString();
                if (session.itemExists(linkPath)) {
                    Item targetItem = session.getItem(linkPath);
                    if (targetItem.isNode()) {
                        linkHelper.createSymetricLink(source,
                            (Node) targetItem, "link");
View Full Code Here

  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

  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

    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

    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

TOP

Related Classes of org.apache.sling.api.request.RequestParameter

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.