
rapture.common.shared.plugin.AddManifestItemDispatch Maven / Gradle / Ivy
/**
* Copyright (C) 2011-2013 Incapture Technologies LLC
*
* This is an autogenerated license statement. When copyright notices appear below
* this one that copyright supercedes this statement.
*
* Unless required by applicable law or agreed to in writing, software is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied.
*
* Unless explicit permission obtained in writing this software cannot be distributed.
*/
/**
* This file is autogenerated and any changes will be overwritten
*/
package rapture.common.shared.plugin;
import java.util.List;
import java.util.Map;
import java.net.HttpURLConnection;
import rapture.common.EntitlementSet;
import rapture.common.exception.RaptureException;
import rapture.common.exception.RaptureExceptionFactory;
import rapture.server.ArgumentParser;
import rapture.kernel.Kernel;
import rapture.common.Messages;
import rapture.server.BaseDispatcher;
import rapture.common.model.GeneralResponse;
import rapture.common.CallingContext;
import rapture.common.DispatchReturn;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
@SuppressWarnings("all")
public class AddManifestItemDispatch extends BaseDispatcher {
private static final Logger log = Logger.getLogger(AddManifestItemDispatch.class);
@Override
public DispatchReturn dispatch(String params, HttpServletRequest req, HttpServletResponse resp) {
log.debug("dispatch "+params);
try {
AddManifestItemPayload payload = ArgumentParser.parsePayload(params, AddManifestItemPayload.class);
CallingContext sessionContext = validateSession(req, payload); // will throw RaptNotLoggedInException if not a valid logged in context
preHandlePayload(sessionContext, payload, EntitlementSet.Plugin_addManifestItem.getPath());
Kernel.getPlugin().addManifestItem(sessionContext == null ? payload.getContext() : sessionContext , payload.getPluginName(),payload.getUri());
String ret = processResponse(new GeneralResponse(new Object()));
return new DispatchReturn(sessionContext, ret); }
catch (RaptureException e) {
return new DispatchReturn(null, error(e));
} catch (Exception e) {
return new DispatchReturn(null, error(RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, Messages.getMessage("Api", "ServerError", null, null), e)));
}
}
}