use of com.predic8.membrane.core.transport.PortOccupiedException in project service-proxy by membrane.
the class DynamicAdminPageInterceptor method handleServiceProxySaveRequest.
@Mapping("/admin/service-proxy/save/?(\\?.*)?")
public Response handleServiceProxySaveRequest(Map<String, String> params, String relativeRootPath) throws Exception {
if (readOnly)
return createReadOnlyErrorResponse();
logAddFwdRuleParams(params);
Rule r = new ServiceProxy(new ServiceProxyKey("*", params.get("method"), ".*", getPortParam(params), null), params.get("targetHost"), getTargetPortParam(params));
r.setName(params.get("name"));
try {
router.getRuleManager().addProxyAndOpenPortIfNew(r);
} catch (PortOccupiedException e) {
return Response.internalServerError("The port could not be opened: Either it is occupied or Membrane does " + "not have enough privileges to do so.").build();
}
return respond(getServiceProxyPage(params, relativeRootPath));
}
Aggregations