All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.aemds.guide.submitutils.FormFieldRequestParameter Maven / Gradle / Ivy

/*************************************************************************
 *
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2014 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 **************************************************************************/

package com.adobe.aemds.guide.submitutils;

import com.adobe.aemds.guide.service.GuideException;
import org.apache.sling.api.request.RequestParameter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.InputStream;
import java.io.UnsupportedEncodingException;

/**
 * Created with IntelliJ IDEA.
 * User: syr
 * Date: 1/20/14
 * Time: 12:52 PM
 * To change this template use File | Settings | File Templates.
 */
public class FormFieldRequestParameter implements RequestParameter {
    private String parameterValue;
    private Logger logger = LoggerFactory.getLogger(FormFieldRequestParameter.class);

    public FormFieldRequestParameter(String parameterValue) {
        this.parameterValue = parameterValue;
    }

    public InputStream getInputStream() {
        return null;
    }

    public String getFileName() {
        return null;
    }

    public boolean isFormField() {
        return true;
    }

    public String getContentType() {
        return null;
    }

    // included in the versions>2.7.0  of org.apache.sling.api.*
    public String getName(){
        return null;
    }

    public byte[] get() {
        return parameterValue.getBytes();
    }

    public String getString() {
        return parameterValue;
    }

    public String getString(String encoding) {
        String result = null;
        try {
            byte[] bytes = this.get();
            result = new String(bytes, encoding);
        } catch (UnsupportedEncodingException e) {
            logger.error("Exception in encoding : " + e.getMessage(), e);
            throw new GuideException(e);
        }
        return result;
    }

    public long getSize() {
        byte[] bytes = this.get();
        return bytes.length;
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy