final String appGuid = path.segment(0);
boolean addRoute = "routes".equals(path.segment(1)); //$NON-NLS-1$
final String routeGuid = addRoute ? path.segment(2) : null;
if (addRoute)
return new CFJob(request, false) {
@Override
protected IStatus performJob() {
try {
ComputeTargetCommand computeTarget = new ComputeTargetCommand(this.userId, targetJSON2);
IStatus status = computeTarget.doIt();
if (!status.isOK())
return status;
Target target = computeTarget.getTarget();
GetAppByGuidCommand getAppByGuid = new GetAppByGuidCommand(target.getCloud(), appGuid);
IStatus getAppByGuidStatus = getAppByGuid.doIt();
if (!getAppByGuidStatus.isOK())
return getAppByGuidStatus;
App app = getAppByGuid.getApp();
GetRouteByGuidCommand getRouteByGuid = new GetRouteByGuidCommand(target.getCloud(), routeGuid);
IStatus getRouteByGuidStatus = getRouteByGuid.doIt();
if (!getRouteByGuidStatus.isOK())
return getRouteByGuidStatus;
Route route = getRouteByGuid.getRoute();
MapRouteCommand unmapRoute = new MapRouteCommand(target, app, route.getGuid());
return unmapRoute.doIt();
} catch (Exception e) {
String msg = NLS.bind("Failed to handle request for {0}", pathString); //$NON-NLS-1$
ServerStatus status = new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e);
logger.error(msg, e);
return status;
}
}
};
final JSONObject jsonData = extractJSONData(request);
final JSONObject targetJSON = jsonData.optJSONObject(CFProtocolConstants.KEY_TARGET);
final String state = jsonData.optString(CFProtocolConstants.KEY_STATE, null);
final String appName = jsonData.optString(CFProtocolConstants.KEY_NAME, null);
final String contentLocation = ServletResourceHandler.toOrionLocation(request, jsonData.optString(CFProtocolConstants.KEY_CONTENT_LOCATION, null));
/* custom packager details */
final String packagerName = jsonData.optString(CFProtocolConstants.KEY_PACKAGER, null);
/* non-manifest deployments using a .json representation */
final JSONObject manifestJSON = jsonData.optJSONObject(CFProtocolConstants.KEY_MANIFEST);
final JSONObject instrumentationJSON = jsonData.optJSONObject(CFProtocolConstants.KEY_INSTRUMENTATION);
final boolean persistManifest = jsonData.optBoolean(CFProtocolConstants.KEY_PERSIST, false);
/* default application startup is one minute */
int userTimeout = jsonData.optInt(CFProtocolConstants.KEY_TIMEOUT, 60);
final int timeout = (userTimeout > 0) ? userTimeout : 0;
return new CFJob(request, false) {
@Override
protected IStatus performJob() {
try {