From 635825ebd9d2c30bdccd9420f87c3905607a0413 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Mon, 9 Sep 2019 14:25:27 +0200 Subject: [PATCH] Error message has been moved in a constant --- src/main/java/org/gcube/gcat/rest/Profile.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/gcat/rest/Profile.java b/src/main/java/org/gcube/gcat/rest/Profile.java index 9d55ef4..38cea48 100644 --- a/src/main/java/org/gcube/gcat/rest/Profile.java +++ b/src/main/java/org/gcube/gcat/rest/Profile.java @@ -37,6 +37,9 @@ public class Profile extends BaseREST implements org.gcube.gcat.api.interfaces.P public static final String PROFILE_NAME_PARAMETER = "PROFILE_NAME"; public static final String PROFILE_VALIDATION_ERROR; + public static final String CANNOT_MANAGE_PROFILE_SCHEMA = "You cannot manage the profile schema"; + + static { StringBuilder validationError = new StringBuilder(); validationError.append("The Profile is not valid because of the following error at validation time:\n%s\n\n"); @@ -101,7 +104,7 @@ public class Profile extends BaseREST implements org.gcube.gcat.api.interfaces.P setCalledMethod("PUT /" + PROFILES + "/{" + PROFILE_NAME_PARAMETER + "}"); try { if(name.compareToIgnoreCase(SCHEMA) == 0) { - throw new NotAllowedException("You cannot manage the profile schema", new Throwable("You cannot manage the profile schema"), + throw new NotAllowedException(CANNOT_MANAGE_PROFILE_SCHEMA, new Throwable(CANNOT_MANAGE_PROFILE_SCHEMA), HttpMethod.GET.toString(), HttpMethod.HEAD.toString()); } ISProfile isProfile = new ISProfile(); @@ -131,7 +134,7 @@ public class Profile extends BaseREST implements org.gcube.gcat.api.interfaces.P setCalledMethod("DELETE /" + PROFILES + "/{" + PROFILE_NAME_PARAMETER + "}"); try { if(name.compareToIgnoreCase(SCHEMA) == 0) { - throw new NotAllowedException("You cannot manage the profile schema", new Throwable("You cannot manage the profile schema"), + throw new NotAllowedException(CANNOT_MANAGE_PROFILE_SCHEMA, new Throwable(CANNOT_MANAGE_PROFILE_SCHEMA), HttpMethod.GET.toString(), HttpMethod.HEAD.toString()); } ISProfile isProfile = new ISProfile();