
com.sun.enterprise.admin.remote.RestPayloadImpl Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package com.sun.enterprise.admin.remote;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import org.glassfish.admin.payload.PayloadImpl;
import org.glassfish.api.admin.Payload;
import org.jvnet.mimepull.Header;
/**
* Payload implementation for ReST interface.
*
* @author mmares
*/
public class RestPayloadImpl extends PayloadImpl {
public static class Outbound extends PayloadImpl.Outbound {
private String complexType;
public Outbound(boolean client2Server) {
if (client2Server) {
complexType = "multipart/form-data";
} else {
complexType = "multipart/mixed";
}
}
@Override
public String getComplexContentType() {
return complexType;
}
@Override
protected void writePartsTo(OutputStream os) throws IOException {
throw new UnsupportedOperationException("Not supported for RestPauloadImpl.");
}
@Override
public void writeTo(final OutputStream os) throws IOException {
throw new UnsupportedOperationException("Not supported for RestPauloadImpl.");
}
// public MultiPart addToMultipart(MultiPart mp, Logger logger) {
// if (mp == null) {
// if (client2Server) {
// logger.finest("addToMultipart: Creating FormDataMultiPart for result");
// mp = new FormDataMultiPart();
// } else {
// logger.finest("addToMultipart: Creating MultiPart [mixed] for result");
// mp = new MultiPart();
// }
// }
// ArrayList parts = getParts();
// if (logger.isLoggable(Level.FINEST)) {
// logger.log(Level.FINEST, "addToMultipart: parts.size = {0}", parts.size());
// }
// int index = 0;
// for (Payload.Part part : parts) {
// index++;
// String contentType = part.getContentType();
// MediaType mt = new MediaType();
// if (contentType != null && !contentType.isEmpty()) {
// int ind = contentType.indexOf('/');
// if (ind > -1) {
// mt = new MediaType(contentType.substring(0, ind), contentType.substring(ind + 1));
// } else {
// mt = new MediaType(contentType, MediaType.WILDCARD);
// }
// }
// BodyPart bp;
// if (logger.isLoggable(Level.FINEST)) {
// logger.log(Level.FINEST, "addToMultipart[{0}]: name: {1}, type: {2}", new Object[]{index, part.getName(), mt});
// }
// if (client2Server) {
// bp = new FormDataBodyPart(part.getName(), part, mt);
// } else {
// bp = new BodyPart(part, mt);
// ContentDisposition cd = ContentDisposition.type("file").fileName(part.getName()).build();
// if (logger.isLoggable(Level.FINEST)) {
// logger.log(Level.FINEST, "addToMultipart[{0}]: Content Disposition: {1}", new Object[]{index, cd});
// }
// bp.setContentDisposition(cd);
// }
// Properties props = part.getProperties();
// for (Map.Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy