Search in sources :

Example 1 with GenericType

use of org.jboss.resteasy.util.GenericType in project candlepin by candlepin.

the class OwnerResource method getArchiveFromResponse.

private UploadMetadata getArchiveFromResponse(MultipartInput input) throws IOException {
    String filename = "";
    InputPart part = input.getParts().get(0);
    MultivaluedMap<String, String> headers = part.getHeaders();
    String contDis = headers.getFirst("Content-Disposition");
    StringTokenizer st = new StringTokenizer(contDis, ";");
    while (st.hasMoreTokens()) {
        String entry = st.nextToken().trim();
        if (entry.startsWith("filename")) {
            filename = entry.substring(entry.indexOf("=") + 2, entry.length() - 1);
            break;
        }
    }
    return new UploadMetadata(part.getBody(new GenericType<File>() {
    }), filename);
}
Also used : StringTokenizer(java.util.StringTokenizer) GenericType(org.jboss.resteasy.util.GenericType) InputPart(org.jboss.resteasy.plugins.providers.multipart.InputPart)

Aggregations

StringTokenizer (java.util.StringTokenizer)1 InputPart (org.jboss.resteasy.plugins.providers.multipart.InputPart)1 GenericType (org.jboss.resteasy.util.GenericType)1