コード例 #1
0
  public UnmapRouteCommand(Target target, App app, Route route) {
    super(target);

    String[] bindings = {route.getGuid(), app.getName(), app.getGuid()};
    this.commandName =
        NLS.bind("Unmap route (guid: {0}) from application {1} (guid: {2})", bindings);

    this.app = app;
    this.route = route;
  }
コード例 #2
0
  @Override
  protected ServerStatus _doIt() {
    try {

      /* unmap route from application */
      URI targetURI = URIUtil.toURI(target.getUrl());
      DeleteMethod unmapRouteMethod =
          new DeleteMethod(
              targetURI
                  .resolve("/v2/apps/" + app.getGuid() + "/routes/" + route.getGuid())
                  .toString()); //$NON-NLS-1$//$NON-NLS-2$
      ServerStatus confStatus = HttpUtil.configureHttpMethod(unmapRouteMethod, target.getCloud());
      if (!confStatus.isOK()) return confStatus;

      return HttpUtil.executeMethod(unmapRouteMethod);

    } catch (Exception e) {
      String msg =
          NLS.bind("An error occured when performing operation {0}", commandName); // $NON-NLS-1$
      logger.error(msg, e);
      return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e);
    }
  }