Skip to content

Commit

Permalink
check for empty payload.url (#130)
Browse files Browse the repository at this point in the history
* check for empty payload.url

* more logging
  • Loading branch information
dkovacevic committed Dec 6, 2023
1 parent 3d2222a commit bf78793
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
Expand Down Expand Up @@ -61,6 +62,11 @@ public Response create(@ApiParam(hidden = true) @CookieParam(Z_ROMAN) String tok
@Context ContainerRequestContext context,
@ApiParam @Valid _NewService payload) {
try {
//hack
if (payload.url != null && payload.url.isEmpty()) {
payload.url = null;
}

UUID providerId = (UUID) context.getProperty(Const.PROVIDER_ID);

Provider provider = providersDAO.get(providerId);
Expand Down Expand Up @@ -122,7 +128,7 @@ public Response create(@ApiParam(hidden = true) @CookieParam(Z_ROMAN) String tok

if (update.getStatus() >= 400) {
String msg = update.readEntity(String.class);
Logger.debug("ServiceResource.create: enable service response: %s", msg);
Logger.debug("ServiceResource.create: enable service (%s) response: %s", service.id, msg);
return Response.
ok(msg).
status(update.getStatus()).
Expand Down Expand Up @@ -355,7 +361,7 @@ static class _NewService {
@ValidationMethod(message = "`url` is not a valid URL")
@JsonIgnore
public boolean isUrlValid() {
if (url == null)
if (url == null || url.isEmpty())
return true;
try {
new URL(url).toURI();
Expand Down

0 comments on commit bf78793

Please sign in to comment.