diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties index 56b27315..e40ab3a3 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties @@ -13,8 +13,8 @@ ## build.namespace=portos_bo - build.number=3203 - build.date=1624539251511 + build.number=3204 + build.date=1624550365014 build.auto.upgrade=true ## diff --git a/liferay-plugins-sdk-6.2/portlets/portos-company-configuration-portlet/docroot/WEB-INF/.gitignore b/liferay-plugins-sdk-6.2/portlets/portos-company-configuration-portlet/docroot/WEB-INF/.gitignore new file mode 100644 index 00000000..840e7d31 --- /dev/null +++ b/liferay-plugins-sdk-6.2/portlets/portos-company-configuration-portlet/docroot/WEB-INF/.gitignore @@ -0,0 +1 @@ +/classes/ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/commons-collections.jar b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/commons-collections.jar new file mode 100644 index 00000000..fa5df82a Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/commons-collections.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/commons-io.jar b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/commons-io.jar new file mode 100644 index 00000000..00556b11 Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/commons-io.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/commons-lang.jar b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/commons-lang.jar new file mode 100644 index 00000000..98467d3a Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/commons-lang.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/commons-logging.jar b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/commons-logging.jar new file mode 100644 index 00000000..8758a96b Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/commons-logging.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/javassist.jar b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/javassist.jar new file mode 100644 index 00000000..5af8eaeb Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/javassist.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/jstl-api.jar b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/jstl-api.jar new file mode 100644 index 00000000..80a5737f Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/jstl-api.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/jstl-impl.jar b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/jstl-impl.jar new file mode 100644 index 00000000..e5a9342f Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/jstl-impl.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/log4j.jar b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/log4j.jar new file mode 100644 index 00000000..068867eb Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/log4j.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/util-bridges.jar b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/util-bridges.jar new file mode 100644 index 00000000..7d7435fe Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/util-bridges.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/util-taglib.jar b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/util-taglib.jar new file mode 100644 index 00000000..fbba5f0a Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/util-taglib.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/tld/c.tld b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/tld/c.tld new file mode 100644 index 00000000..98efa6a6 --- /dev/null +++ b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/tld/c.tld @@ -0,0 +1,572 @@ + + + + + JSTL 1.2 core library + JSTL core + 1.2 + c + http://java.sun.com/jsp/jstl/core + + + + Provides core validation features for JSTL tags. + + + org.apache.taglibs.standard.tlv.JstlCoreTLV + + + + + + Catches any Throwable that occurs in its body and optionally + exposes it. + + catch + org.apache.taglibs.standard.tag.common.core.CatchTag + JSP + + +Name of the exported scoped variable for the +exception thrown from a nested action. The type of the +scoped variable is the type of the exception thrown. + + var + false + false + + + + + + Simple conditional tag that establishes a context for + mutually exclusive conditional operations, marked by + <when> and <otherwise> + + choose + com.liferay.taglib.core.ChooseTag + JSP + + + + + Simple conditional tag, which evalutes its body if the + supplied condition is true and optionally exposes a Boolean + scripting variable representing the evaluation of this condition + + if + com.liferay.taglib.core.IfTag + JSP + + +The test condition that determines whether or +not the body content should be processed. + + test + true + true + boolean + + + +Name of the exported scoped variable for the +resulting value of the test condition. The type +of the scoped variable is Boolean. + + var + false + false + + + +Scope for var. + + scope + false + false + + + + + + Retrieves an absolute or relative URL and exposes its contents + to either the page, a String in 'var', or a Reader in 'varReader'. + + import + org.apache.taglibs.standard.tag.rt.core.ImportTag + org.apache.taglibs.standard.tei.ImportTEI + JSP + + +The URL of the resource to import. + + url + true + true + + + +Name of the exported scoped variable for the +resource's content. The type of the scoped +variable is String. + + var + false + false + + + +Scope for var. + + scope + false + false + + + +Name of the exported scoped variable for the +resource's content. The type of the scoped +variable is Reader. + + varReader + false + false + + + +Name of the context when accessing a relative +URL resource that belongs to a foreign +context. + + context + false + true + + + +Character encoding of the content at the input +resource. + + charEncoding + false + true + + + + + + The basic iteration tag, accepting many different + collection types and supporting subsetting and other + functionality + + forEach + org.apache.taglibs.standard.tag.rt.core.ForEachTag + org.apache.taglibs.standard.tei.ForEachTEI + JSP + + +Collection of items to iterate over. + + items + false + true + java.lang.Object + + java.lang.Object + + + + +If items specified: +Iteration begins at the item located at the +specified index. First item of the collection has +index 0. +If items not specified: +Iteration begins with index set at the value +specified. + + begin + false + true + int + + + +If items specified: +Iteration ends at the item located at the +specified index (inclusive). +If items not specified: +Iteration ends when index reaches the value +specified. + + end + false + true + int + + + +Iteration will only process every step items of +the collection, starting with the first one. + + step + false + true + int + + + +Name of the exported scoped variable for the +current item of the iteration. This scoped +variable has nested visibility. Its type depends +on the object of the underlying collection. + + var + false + false + + + +Name of the exported scoped variable for the +status of the iteration. Object exported is of type +javax.servlet.jsp.jstl.core.LoopTagStatus. This scoped variable has nested +visibility. + + varStatus + false + false + + + + + + Iterates over tokens, separated by the supplied delimeters + + forTokens + org.apache.taglibs.standard.tag.rt.core.ForTokensTag + JSP + + +String of tokens to iterate over. + + items + true + true + java.lang.String + + java.lang.String + + + + +The set of delimiters (the characters that +separate the tokens in the string). + + delims + true + true + java.lang.String + + + +Iteration begins at the token located at the +specified index. First token has index 0. + + begin + false + true + int + + + +Iteration ends at the token located at the +specified index (inclusive). + + end + false + true + int + + + +Iteration will only process every step tokens +of the string, starting with the first one. + + step + false + true + int + + + +Name of the exported scoped variable for the +current item of the iteration. This scoped +variable has nested visibility. + + var + false + false + + + +Name of the exported scoped variable for the +status of the iteration. Object exported is of +type +javax.servlet.jsp.jstl.core.LoopTag +Status. This scoped variable has nested +visibility. + + varStatus + false + false + + + + + + Like <%= ... >, but for expressions. + + out + org.apache.taglibs.standard.tag.rt.core.OutTag + JSP + + +Expression to be evaluated. + + value + true + true + + + +Default value if the resulting value is null. + + default + false + true + + + +Determines whether characters <,>,&,'," in the +resulting string should be converted to their +corresponding character entity codes. Default value is +true. + + escapeXml + false + true + + + + + + + Subtag of <choose> that follows <when> tags + and runs only if all of the prior conditions evaluated to + 'false' + + otherwise + com.liferay.taglib.core.OtherwiseTag + JSP + + + + + Adds a parameter to a containing 'import' tag's URL. + + param + org.apache.taglibs.standard.tag.rt.core.ParamTag + JSP + + +Name of the query string parameter. + + name + true + true + + + +Value of the parameter. + + value + false + true + + + + + + Redirects to a new URL. + + redirect + org.apache.taglibs.standard.tag.rt.core.RedirectTag + JSP + + +The URL of the resource to redirect to. + + url + false + true + + + +Name of the context when redirecting to a relative URL +resource that belongs to a foreign context. + + context + false + true + + + + + + Removes a scoped variable (from a particular scope, if specified). + + remove + org.apache.taglibs.standard.tag.common.core.RemoveTag + empty + + +Name of the scoped variable to be removed. + + var + true + false + + + +Scope for var. + + scope + false + false + + + + + + Sets the result of an expression evaluation in a 'scope' + + set + org.apache.taglibs.standard.tag.rt.core.SetTag + JSP + + +Name of the exported scoped variable to hold the value +specified in the action. The type of the scoped variable is +whatever type the value expression evaluates to. + + var + false + false + + + +Expression to be evaluated. + + value + false + true + + java.lang.Object + + + + +Target object whose property will be set. Must evaluate to +a JavaBeans object with setter property property, or to a +java.util.Map object. + + target + false + true + + + +Name of the property to be set in the target object. + + property + false + true + + + +Scope for var. + + scope + false + false + + + + + + Creates a URL with optional query parameters. + + url + org.apache.taglibs.standard.tag.rt.core.UrlTag + JSP + + +Name of the exported scoped variable for the +processed url. The type of the scoped variable is +String. + + var + false + false + + + +Scope for var. + + scope + false + false + + + +URL to be processed. + + value + false + true + + + +Name of the context when specifying a relative URL +resource that belongs to a foreign context. + + context + false + true + + + + + + Subtag of <choose> that includes its body if its + condition evalutes to 'true' + + when + com.liferay.taglib.core.WhenTag + JSP + + +The test condition that determines whether or not the +body content should be processed. + + test + true + true + boolean + + + + diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Parameters.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Parameters.java index 549a48b6..97f6bf88 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Parameters.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Parameters.java @@ -13,6 +13,7 @@ public class Parameters { public static final String FIRST_NAME = "firstName"; public static final String LAST_NAME = "lastName"; public static final String NAME = "name"; + public static final String NULLABLE = "nullable"; public static final String PASSWORD = "password"; public static final String STATUS_CODE = "statusCode"; public static final String STATUS_MESSAGE = "statusMessage"; diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Response.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Response.java index 48052488..58595a6f 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Response.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Response.java @@ -6,17 +6,21 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import javax.servlet.http.HttpServletResponse; + import org.apache.commons.lang.StringUtils; import com.liferay.portal.kernel.json.JSONFactoryUtil; import com.liferay.portal.kernel.json.JSONSerializer; +import com.liferay.portal.kernel.servlet.ServletResponseUtil; import com.liferay.portal.kernel.util.StringPool; public class Response { private static final JSONSerializer serializer = JSONFactoryUtil.createJSONSerializer().exclude("*.class"); - public static String get(int statusCode, Map extraData, List additionalInfo) { + public static void write(HttpServletResponse response, int statusCode, Map extraData, + List additionalInfo) throws IOException { Map map = new LinkedHashMap<>(); map.put(Parameters.STATUS_CODE, statusCode); @@ -24,21 +28,25 @@ public class Response { if (null != extraData) { map.putAll(extraData); } - if (null != additionalInfo) { + if ((null != additionalInfo) && !additionalInfo.isEmpty()) { map.put(Parameters.ADDITIONAL_INFO, StringUtils.join(additionalInfo, StringPool.NEW_LINE)); } - return serializer.serializeDeep(map); + ServletResponseUtil.write(response, serializer.serializeDeep(map)); } - public static String get(int statusCode) throws IOException { - return get(statusCode, null, null); + public static void write(HttpServletResponse response, int statusCode) throws IOException { + write(response, statusCode, null, null); } - public static String get(int statusCode, Map extraData) { - return get(statusCode, extraData, null); + public static void write(HttpServletResponse response, int statusCode, Map extraData) + throws IOException { + + write(response, statusCode, extraData, null); } - public static String get(int statusCode, List additionalInfo) { - return get(statusCode, null, additionalInfo); + public static void write(HttpServletResponse response, int statusCode, List additionalInfo) + throws IOException { + + write(response, statusCode, null, additionalInfo); } } diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Status.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Status.java index e17a7ba6..857951b1 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Status.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Status.java @@ -6,18 +6,20 @@ import java.util.Map; public class Status { public static final int OK = 0; - public static final int EXPIRED_TOKEN = 1; - public static final int INACTIVE_USER = 2; - public static final int INVALID_INPUT = 3; - public static final int INVALID_TOKEN = 4; - public static final int MALFORMED_REQUEST = 5; - public static final int SERVER_ERROR = 6; - public static final int WRONG_USERNAME_OR_PASSWORD = 7; + public static final int ACCESS_DENIED = 1; + public static final int EXPIRED_TOKEN = 2; + public static final int INACTIVE_USER = 3; + public static final int INVALID_INPUT = 4; + public static final int INVALID_TOKEN = 5; + public static final int MALFORMED_REQUEST = 6; + public static final int SERVER_ERROR = 7; + public static final int WRONG_USERNAME_OR_PASSWORD = 8; @SuppressWarnings("serial") private static final Map messages = new HashMap() { { put(OK, "OK"); + put(ACCESS_DENIED, "Accesso negato"); put(EXPIRED_TOKEN, "Questo token è scaduto"); put(INACTIVE_USER, "L'utente non è attivo"); put(INVALID_INPUT, "Dati forniti non validi"); diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Application.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Application.java index 03ea1196..8a6b3af8 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Application.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Application.java @@ -5,9 +5,9 @@ import java.io.Serializable; @SuppressWarnings("serial") public class Application implements Serializable { - private long applicationId; - private String code; - private String vatId; + private final long applicationId; + private final String code; + private final String vatId; public Application(long applicationId, String code, String vatId) { diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/ApplicationType.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/ApplicationType.java deleted file mode 100644 index 8e1f2dc5..00000000 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/ApplicationType.java +++ /dev/null @@ -1,26 +0,0 @@ -package it.mwg.sicilia.sue.api.v1.bean; - -import java.io.Serializable; - -@SuppressWarnings("serial") -public class ApplicationType implements Serializable { - - private String code; - private String description; - - public ApplicationType(String code, String description) { - - this.code = code; - this.description = description; - } - - public String getCode() { - - return code; - } - - public String getDescription() { - - return description; - } -} diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Field.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Field.java index f78b383c..f348d55a 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Field.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Field.java @@ -2,17 +2,19 @@ package it.mwg.sicilia.sue.api.v1.bean; import it.mwg.sicilia.sue.api.v1.parameter.Parameter; -public class Field { +public class Field implements Comparable { private final String name; private final String description; private final Parameter.TYPES type; + private final boolean nullable; - public Field(String name, String description, Parameter.TYPES type) { + public Field(String name, String description, Parameter.TYPES type, boolean nullable) { this.name = name; this.description = description; this.type = type; + this.nullable = nullable; } public String getName() { @@ -26,4 +28,13 @@ public class Field { public Parameter.TYPES getType() { return type; } + + @Override + public int compareTo(Field o) { + return this.name.compareTo(o.getName()); + } + + public boolean isNullable() { + return nullable; + } } diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/ListElement.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/ListItem.java similarity index 62% rename from liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/ListElement.java rename to liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/ListItem.java index e23d9a8c..8d06d352 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/ListElement.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/ListItem.java @@ -3,12 +3,12 @@ package it.mwg.sicilia.sue.api.v1.bean; import java.io.Serializable; @SuppressWarnings("serial") -public class ListElement implements Serializable { +public class ListItem implements Serializable { - private String code; - private String description; + private final String code; + private final String description; - public ListElement(String code, String description) { + public ListItem(String code, String description) { this.code = code; this.description = description; diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Value.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Value.java new file mode 100644 index 00000000..261e1285 --- /dev/null +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Value.java @@ -0,0 +1,24 @@ +package it.mwg.sicilia.sue.api.v1.bean; + +import java.io.Serializable; + +@SuppressWarnings("serial") +public class Value implements Serializable { + + private final Serializable value; + private final String description; + + public Value(Serializable value, String description) { + + this.value = value; + this.description = description; + } + + public Serializable getValue() { + return value; + } + + public String getDescription() { + return description; + } +} diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/Command.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/Command.java index 5779956e..6aa3d5f1 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/Command.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/Command.java @@ -29,7 +29,6 @@ import com.liferay.portal.kernel.json.JSONFactoryUtil; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.servlet.HttpMethods; -import com.liferay.portal.kernel.servlet.ServletResponseUtil; import com.liferay.portal.kernel.util.ContentTypes; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.Validator; @@ -143,13 +142,13 @@ public abstract class Command { accessToken = new AccessToken(token); sportello = SportelloLocalServiceUtil.getSportello(accessToken.getSportelloId()); } catch (InvalidTokenException e) { - ServletResponseUtil.write(response, Response.get(Status.INVALID_TOKEN)); + Response.write(response, Status.INVALID_TOKEN); } catch (ExpiredTokenException e) { - ServletResponseUtil.write(response, Response.get(Status.EXPIRED_TOKEN)); + Response.write(response, Status.EXPIRED_TOKEN); } catch (PortalException | SystemException e) { - ServletResponseUtil.write(response, Response.get(Status.INACTIVE_USER)); + Response.write(response, Status.INACTIVE_USER); } catch (Exception e) { - ServletResponseUtil.write(response, Response.get(Status.SERVER_ERROR)); + Response.write(response, Status.SERVER_ERROR); } return true; } catch (IOException e) { diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/CommandList.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/CommandList.java index d50792a7..9a3d3b30 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/CommandList.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/CommandList.java @@ -6,13 +6,12 @@ import it.mwg.sicilia.sue.api.v1.command.impl.GetApplications; import it.mwg.sicilia.sue.api.v1.command.impl.ListApplications; import it.mwg.sicilia.sue.api.v1.command.impl.ListDocuments; import it.mwg.sicilia.sue.api.v1.command.impl.ListFields; -import it.mwg.sicilia.sue.api.v1.command.impl.ListUses; +import it.mwg.sicilia.sue.api.v1.command.impl.ListValues; import it.mwg.sicilia.sue.api.v1.command.impl.Login; import it.mwg.sicilia.sue.api.v1.command.impl.Manual; import it.mwg.sicilia.sue.api.v1.command.impl.ManualHtml; import it.mwg.sicilia.sue.api.v1.command.impl.Nop; import it.mwg.sicilia.sue.api.v1.command.impl.SetFields; -import it.mwg.sicilia.sue.api.v1.command.impl.SetUse; import java.util.Collection; import java.util.LinkedHashMap; @@ -37,14 +36,12 @@ public class CommandList { addCommand(new ListDocuments("Elenco dei documenti riconosciuti dal portale", HttpMethods.GET, HttpMethods.POST)); addCommand(new ListFields("Elenco dei dati dell'istanza accettati dal portale", HttpMethods.GET, HttpMethods.POST)); - addCommand(new ListUses("Elenco delle destinazioni d'uso riconosciute dal portale", HttpMethods.GET, - HttpMethods.POST)); + addCommand(new ListValues("Elenca i valori ammissibili per un campo a selezione obbligata")); // Istanze addCommand(new AddApplication( "Crea una nuova istanza di endoprocedimento, crea l'utente se non esiste ancora sul portale")); - addCommand(new SetFields("Imposta i valori dei dati dell'istanza, l'elenco è fornito dal comando /" + addCommand(new SetFields("Imposta i valori dei dati dell'istanza, l'elenco dei campi valorizzabili è fornito dal comando /" + Command.getCommandName(ListFields.class))); - addCommand(new SetUse("Imposta la destinazione d'uso dell'immobile relativo all'istanza")); addCommand(new GetApplications("Elenca le istanze in lavorazione da questo SUE", HttpMethods.GET, HttpMethods.POST)); addCommand(new DeleteApplication("Elimina un'istanza")); diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/AddApplication.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/AddApplication.java index d54f2709..f1142565 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/AddApplication.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/AddApplication.java @@ -28,7 +28,6 @@ import javax.servlet.http.HttpServletResponse; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; -import com.liferay.portal.kernel.servlet.ServletResponseUtil; import com.liferay.portal.kernel.util.MapUtil; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.Validator; @@ -57,7 +56,7 @@ public class AddApplication extends Command { add(new Parameter(Parameters.APPLICATION_ID, TYPES.INTEGER, "Identificatore del procedimento creato, da utilizzare nelle successive operazioni")); add(new Parameter(Parameters.ADDITIONAL_INFO, TYPES.STRING, - "Eventuali informazioni aggiuntive sull'operazione o sugli errori incontrati")); + "Eventuali informazioni aggiuntive sull'operazione o sugli errori incontrati", false)); } }; @@ -73,14 +72,14 @@ public class AddApplication extends Command { String screenName = MapUtil.getString(parameters, Parameters.VAT_ID); if (Validator.isNull(screenName)) { additionalInfo.add("Parametro " + Parameters.VAT_ID + " mancante"); - ServletResponseUtil.write(response, Response.get(Status.MALFORMED_REQUEST, additionalInfo)); + Response.write(response, Status.MALFORMED_REQUEST, additionalInfo); return; } String tipoProcedura = MapUtil.getString(parameters, Parameters.CODE); if (Validator.isNull(tipoProcedura) || !IntPraticaLocalServiceUtil.getTipiProcedure().containsKey(tipoProcedura)) { additionalInfo.add("Tipo pratica non specificato o non valido"); - ServletResponseUtil.write(response, Response.get(Status.MALFORMED_REQUEST, additionalInfo)); + Response.write(response, Status.MALFORMED_REQUEST, additionalInfo); return; } String lastName = MapUtil.getString(parameters, Parameters.LAST_NAME, screenName); @@ -92,7 +91,7 @@ public class AddApplication extends Command { territorio = TerritorioLocalServiceUtil.findByComuneId(comune.getComuneId(), 0, 1).get(0); } catch (PortalException | SystemException e) { additionalInfo.add("Errore del server durante il caricamento del comune"); - ServletResponseUtil.write(response, Response.get(Status.INACTIVE_USER, additionalInfo)); + Response.write(response, Status.INACTIVE_USER, additionalInfo); return; } Date date = new Date(); @@ -137,7 +136,7 @@ public class AddApplication extends Command { } } catch (PortalException | SystemException e) { additionalInfo.add("Errore durante la creazione dell'utente " + screenName); - ServletResponseUtil.write(response, Response.get(Status.SERVER_ERROR, additionalInfo)); + Response.write(response, Status.SERVER_ERROR, additionalInfo); return; } ServiceContext serviceContext = new ServiceContext(); @@ -160,12 +159,12 @@ public class AddApplication extends Command { IntPraticaLocalServiceUtil.updateIntPratica(intPratica); } catch (PortalException | SystemException e) { additionalInfo.add("Errore durante la creazione dell'istanza"); - ServletResponseUtil.write(response, Response.get(Status.SERVER_ERROR, additionalInfo)); + Response.write(response, Status.SERVER_ERROR, additionalInfo); return; } Map result = new HashMap<>(); result.put(Parameters.APPLICATION_ID, dettPratica.getIntPraticaId()); - ServletResponseUtil.write(response, Response.get(Status.OK, result, additionalInfo)); + Response.write(response, Status.OK, result, additionalInfo); } } diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/DeleteApplication.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/DeleteApplication.java index 1cc7746f..6fc0fd33 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/DeleteApplication.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/DeleteApplication.java @@ -19,7 +19,6 @@ import javax.servlet.http.HttpServletResponse; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; -import com.liferay.portal.kernel.servlet.ServletResponseUtil; import com.liferay.portal.kernel.util.MapUtil; public class DeleteApplication extends Command { @@ -36,7 +35,7 @@ public class DeleteApplication extends Command { { addAll(BASE_OUTPUT_PARAMETERS); add(new Parameter(Parameters.ADDITIONAL_INFO, TYPES.STRING, - "Eventuali informazioni aggiuntive sull'operazione o sugli errori incontrati")); + "Eventuali informazioni aggiuntive sull'operazione o sugli errori incontrati", false)); } }; @@ -51,7 +50,7 @@ public class DeleteApplication extends Command { List additionalInfo = new ArrayList(); if (!parameters.containsKey(Parameters.APPLICATION_ID)) { additionalInfo.add("Parametro " + Parameters.APPLICATION_ID + " mancante"); - ServletResponseUtil.write(response, Response.get(Status.MALFORMED_REQUEST, additionalInfo)); + Response.write(response, Status.MALFORMED_REQUEST, additionalInfo); return; } long applicationId = MapUtil.getLong(parameters, Parameters.APPLICATION_ID); @@ -60,23 +59,23 @@ public class DeleteApplication extends Command { intPratica = IntPraticaLocalServiceUtil.getIntPratica(applicationId); } catch (PortalException | SystemException e) { additionalInfo.add("Istanza " + applicationId + " non trovata"); - ServletResponseUtil.write(response, Response.get(Status.INVALID_INPUT, additionalInfo)); + Response.write(response, Status.INVALID_INPUT, additionalInfo); return; } try { Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); if (territorio.getComuneId() != sportello.getComuneId() || !intPratica.isInLavorazioneSue()) { additionalInfo.add("Istanza " + applicationId + " non modificabile"); - ServletResponseUtil.write(response, Response.get(Status.INVALID_INPUT, additionalInfo)); + Response.write(response, Status.INVALID_INPUT, additionalInfo); return; } } catch (PortalException | SystemException e) { additionalInfo.add("Errore del server durante il caricamento dell'istanza"); - ServletResponseUtil.write(response, Response.get(Status.INVALID_INPUT, additionalInfo)); + Response.write(response, Status.INVALID_INPUT, additionalInfo); return; } IntPraticaLocalServiceUtil.deleteIntPratica(intPratica, true); - ServletResponseUtil.write(response, Response.get(Status.OK)); + Response.write(response, Status.OK); } } diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/GetApplications.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/GetApplications.java index 343131c6..5e75c037 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/GetApplications.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/GetApplications.java @@ -22,7 +22,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.liferay.portal.kernel.dao.orm.QueryUtil; -import com.liferay.portal.kernel.servlet.ServletResponseUtil; public class GetApplications extends Command { @@ -57,7 +56,7 @@ public class GetApplications extends Command { } Map result = new HashMap<>(); result.put(Parameters.APPLICATIONS, (Serializable) applications); - ServletResponseUtil.write(response, Response.get(Status.OK, result)); + Response.write(response, Status.OK, result); } } diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListApplications.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListApplications.java index 0a15d1ea..01a2bf1e 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListApplications.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListApplications.java @@ -3,7 +3,7 @@ package it.mwg.sicilia.sue.api.v1.command.impl; import it.mwg.sicilia.sue.api.v1.Parameters; import it.mwg.sicilia.sue.api.v1.Response; import it.mwg.sicilia.sue.api.v1.Status; -import it.mwg.sicilia.sue.api.v1.bean.ListElement; +import it.mwg.sicilia.sue.api.v1.bean.ListItem; import it.mwg.sicilia.sue.api.v1.command.Command; import it.mwg.sicilia.sue.api.v1.parameter.Parameter; import it.mwg.sicilia.sue.api.v1.parameter.Parameter.TYPES; @@ -19,8 +19,6 @@ import java.util.Map.Entry; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.liferay.portal.kernel.servlet.ServletResponseUtil; - public class ListApplications extends Command { private static final List OUTPUT_PARAMETERS = new ArrayList<>(); @@ -40,13 +38,13 @@ public class ListApplications extends Command { public void run(HttpServletRequest request, HttpServletResponse response) throws Exception { Map procedure = IntPraticaLocalServiceUtil.getTipiProcedure(); - List list = new ArrayList<>(procedure.size()); + List list = new ArrayList<>(procedure.size()); for (Entry entry : procedure.entrySet()) { - list.add(new ListElement(entry.getKey(), entry.getValue())); + list.add(new ListItem(entry.getKey(), entry.getValue())); } Map result = new HashMap<>(); result.put(Parameters.APPLICATIONS, (Serializable) list); - ServletResponseUtil.write(response, Response.get(Status.OK, result)); + Response.write(response, Status.OK, result); } @Override diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListDocuments.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListDocuments.java index 7feaf84f..be46c732 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListDocuments.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListDocuments.java @@ -3,7 +3,7 @@ package it.mwg.sicilia.sue.api.v1.command.impl; import it.mwg.sicilia.sue.api.v1.Parameters; import it.mwg.sicilia.sue.api.v1.Response; import it.mwg.sicilia.sue.api.v1.Status; -import it.mwg.sicilia.sue.api.v1.bean.ListElement; +import it.mwg.sicilia.sue.api.v1.bean.ListItem; import it.mwg.sicilia.sue.api.v1.command.Command; import it.mwg.sicilia.sue.api.v1.parameter.Parameter; import it.mwg.sicilia.sue.api.v1.parameter.Parameter.TYPES; @@ -19,8 +19,6 @@ import java.util.Map.Entry; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.liferay.portal.kernel.servlet.ServletResponseUtil; - public class ListDocuments extends Command { private static final List OUTPUT_PARAMETERS = new ArrayList<>(); @@ -40,13 +38,13 @@ public class ListDocuments extends Command { public void run(HttpServletRequest request, HttpServletResponse response) throws Exception { Map documents = DocumentiPraticaUtil.getTipiDocDomanda(); - List list = new ArrayList<>(documents.size()); + List list = new ArrayList<>(documents.size()); for (Entry entry : documents.entrySet()) { - list.add(new ListElement(entry.getKey(), entry.getValue())); + list.add(new ListItem(entry.getKey(), entry.getValue())); } Map result = new HashMap<>(); result.put(Parameters.DOCUMENTS, (Serializable) list); - ServletResponseUtil.write(response, Response.get(Status.OK, result)); + Response.write(response, Status.OK, result); } @Override diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListFields.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListFields.java index 422bd537..624666ac 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListFields.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListFields.java @@ -7,6 +7,7 @@ import it.mwg.sicilia.sue.api.v1.bean.Field; import it.mwg.sicilia.sue.api.v1.command.Command; import it.mwg.sicilia.sue.api.v1.parameter.Parameter; import it.mwg.sicilia.sue.api.v1.parameter.Parameter.TYPES; +import it.mwg.sicilia.sue.api.v1.util.DettPraticaUtil; import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; import java.io.Serializable; @@ -14,12 +15,15 @@ import java.sql.Types; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; +import java.util.Set; +import java.util.TreeSet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.liferay.portal.kernel.servlet.ServletResponseUtil; +import com.liferay.portal.kernel.language.LanguageUtil; import com.liferay.portal.kernel.util.StringPool; public class ListFields extends Command { @@ -32,6 +36,8 @@ public class ListFields extends Command { p.addSubParameter(new Parameter(Parameters.DESCRIPTION, TYPES.STRING, "Descrizione del parametro")); p.addSubParameter(new Parameter(Parameters.TYPE, TYPES.STRING, "Tipo del parametro (" + TYPES.STRING + ", " + TYPES.INTEGER + ", ecc.)")); + p.addSubParameter(new Parameter(Parameters.NULLABLE, TYPES.BOOLEAN, + "Se true il campo può essere impostato al valore NULL")); OUTPUT_PARAMETERS.add(p); }; @@ -42,25 +48,58 @@ public class ListFields extends Command { @Override public void run(HttpServletRequest request, HttpServletResponse response) throws Exception { - List list = new ArrayList<>(); + Set list = new TreeSet<>(); Map fieldTypes = DettPraticaLocalServiceUtil.getDettPraticaFieldsTypes(); List fields = DettPraticaLocalServiceUtil.getDettPraticaFields(); for (String field : fields) { - String description = StringPool.BLANK; + String description = LanguageUtil.get(Locale.ITALIAN, field.replaceAll("([A-Z])", "-$1").toLowerCase()) + .replace("", StringPool.BLANK).replace("", StringPool.BLANK) + .replace("
", StringPool.SPACE); boolean insert = true; + boolean nullable = false; + Integer fieldType = fieldTypes.get(field); switch (field) { + case "dccCoperturaAltroDesrizione": + description += " diventa obbligatorio quando dccCoperturaAltro = true"; + break; + case "dccElemNonStrutAltroDescrizione": + description += " diventa obbligatorio quando dccElemNonStrutAltro = true"; + break; + case "dccOpereDiRinforzoAltroDescrizione": + description += " diventa obbligatorio quando dccOpereDiRinforzoAltro = true"; + break; + case "dccOrizzontamentiAltroDescrizione": + description += " diventa obbligatorio quando dccOrizzontamentiAltro = true"; + break; + case "dccStruttureEleAltroDescrizione": + description += " diventa obbligatorio quando dccStruttureEleAltro = true"; + break; case "destinazione": description = "Codice della destinazione d'uso, l'elenco è fornito dal comando /" + getCommandName(ListUses.class); break; - default: + case "destinazioneAltroIntervento": + description += " diventa obbligatorio quando destinazione = 3"; + break; + case "dcAllegato": + case "dcFoglio": + case "dcParticelle": insert = false; + break; + case "deInfAltroDesc": + description += " diventa obbligatorio quando deInfAltro = true"; + break; + } + String values = DettPraticaUtil.getFieldValues(field); + if (null != values) { + description += ". Unici valori ammessi: " + values + StringPool.PERIOD; } if (insert) { TYPES type = TYPES.UNKNOWN; - switch (fieldTypes.get(field)) { + switch (fieldType) { case Types.BIGINT: case Types.INTEGER: + case Types.TIMESTAMP: type = TYPES.INTEGER; break; case Types.BOOLEAN: @@ -69,19 +108,16 @@ public class ListFields extends Command { case Types.DOUBLE: type = TYPES.FLOAT; break; - case Types.TIMESTAMP: - type = TYPES.FLOAT; - break; case Types.VARCHAR: type = TYPES.STRING; break; } - list.add(new Field(field, description, type)); + list.add(new Field(field, description, type, nullable)); } } Map result = new HashMap<>(); result.put(Parameters.FIELDS, (Serializable) list); - ServletResponseUtil.write(response, Response.get(Status.OK, result)); + Response.write(response, Status.OK, result); } @Override diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListUses.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListUses.java index 28a386f3..12fc5594 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListUses.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListUses.java @@ -3,24 +3,20 @@ package it.mwg.sicilia.sue.api.v1.command.impl; import it.mwg.sicilia.sue.api.v1.Parameters; import it.mwg.sicilia.sue.api.v1.Response; import it.mwg.sicilia.sue.api.v1.Status; -import it.mwg.sicilia.sue.api.v1.bean.ListElement; import it.mwg.sicilia.sue.api.v1.command.Command; import it.mwg.sicilia.sue.api.v1.parameter.Parameter; import it.mwg.sicilia.sue.api.v1.parameter.Parameter.TYPES; -import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; +import it.mwg.sicilia.sue.api.v1.util.DettPraticaUtil; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.liferay.portal.kernel.servlet.ServletResponseUtil; - public class ListUses extends Command { private static final List OUTPUT_PARAMETERS = new ArrayList<>(); @@ -39,13 +35,9 @@ public class ListUses extends Command { @Override public void run(HttpServletRequest request, HttpServletResponse response) throws Exception { - List uses = new ArrayList<>(); - for (Entry e : DettPraticaLocalServiceUtil.getDestinazioniUso().entrySet()) { - uses.add(new ListElement(e.getKey(), e.getValue())); - } Map result = new HashMap<>(); - result.put(Parameters.USES, (Serializable) uses); - ServletResponseUtil.write(response, Response.get(Status.OK, result)); + result.put(Parameters.USES, (Serializable) DettPraticaUtil.getUses()); + Response.write(response, Status.OK, result); } @Override diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListValues.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListValues.java new file mode 100644 index 00000000..daf8d787 --- /dev/null +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListValues.java @@ -0,0 +1,55 @@ +package it.mwg.sicilia.sue.api.v1.command.impl; + +import it.mwg.sicilia.sue.api.v1.Parameters; +import it.mwg.sicilia.sue.api.v1.command.Command; +import it.mwg.sicilia.sue.api.v1.parameter.Parameter; +import it.mwg.sicilia.sue.api.v1.parameter.Parameter.TYPES; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class ListValues extends Command { + + @SuppressWarnings("serial") + private static final List INPUT_PARAMETERS = new ArrayList() { + { + add(new Parameter(Parameters.NAME, TYPES.STRING, "Nome del campo per il quale si richiede l'elenco")); + } + }; + + private static final List OUTPUT_PARAMETERS = new ArrayList<>(); + static { + OUTPUT_PARAMETERS.addAll(BASE_OUTPUT_PARAMETERS); + Parameter p = new Parameter(Parameters.USES, TYPES.ARRAY, "Elenco di valori ammissibili"); + p.addSubParameter(new Parameter(Parameters.VALUE, TYPES.STRING, "Valore per il campo")); + p.addSubParameter(new Parameter(Parameters.DESCRIPTION, TYPES.STRING, "Descrizione del valore, se disponibile", + false)); + OUTPUT_PARAMETERS.add(p); + }; + + public ListValues(String description, String... methods) { + super(description, methods); + } + + @Override + public void run(HttpServletRequest request, HttpServletResponse response) throws Exception { + } + + @Override + public List getInputParameters() { + return INPUT_PARAMETERS; + } + + @Override + public List getOutputParameters() { + return OUTPUT_PARAMETERS; + } + + @Override + public boolean isSecure() { + return false; + } +} diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Login.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Login.java index 24aa8f73..1047410c 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Login.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Login.java @@ -21,7 +21,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.liferay.portal.kernel.exception.SystemException; -import com.liferay.portal.kernel.servlet.ServletResponseUtil; import com.liferay.portal.kernel.util.Validator; public class Login extends Command { @@ -61,13 +60,13 @@ public class Login extends Command { } catch (NoSuchSportelloException | SystemException e) { } if (Validator.isNull(sportello) || !sportello.checkPassword(password)) { - ServletResponseUtil.write(response, Response.get(Status.WRONG_USERNAME_OR_PASSWORD)); + Response.write(response, Status.WRONG_USERNAME_OR_PASSWORD); } else if (!sportello.isAttivo()) { - ServletResponseUtil.write(response, Response.get(Status.INACTIVE_USER)); + Response.write(response, Status.INACTIVE_USER); } else { Map result = new HashMap<>(); result.put(Parameters.TOKEN, new AccessToken(sportello).getToken()); - ServletResponseUtil.write(response, Response.get(Status.OK, result)); + Response.write(response, Status.OK, result); } } } diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Manual.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Manual.java index a4fc1058..936e2a43 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Manual.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Manual.java @@ -88,7 +88,7 @@ public class Manual extends Command { } } } - result.append("Esempio:\n").append(getCurlExample(command, getBaseUrl(request))); + result.append("Esempio:\n").append(getCurlExample(command, getBaseUrl(request), StringPool.TAB)); if (commands.hasNext()) { result.append("================================================================================\n"); } @@ -102,15 +102,22 @@ public class Manual extends Command { protected String getCurlExample(Command command, String baseUrl) { + return getCurlExample(command, baseUrl, StringPool.BLANK); + } + + protected String getCurlExample(Command command, String baseUrl, String prefix) { + StringBuilder sb = new StringBuilder(); - sb.append("\tcurl "); + sb.append(prefix).append("curl "); if (command.isSecure()) { - sb.append("--header \"").append(Parameters.X_AUTH_TOKEN).append(": $TOKEN\"").append(" \\\n\t\t"); + sb.append("--header \"").append(Parameters.X_AUTH_TOKEN).append(": $TOKEN\"").append(" \\\n") + .append(prefix).append(StringPool.TAB); } if (command.getMethods().contains(HttpMethods.GET)) { } else { - sb.append("--header \"Content-Type: application/json; charset=UTF-8\" \\\n\t\t"); - sb.append("--request POST \\\n\t\t"); + sb.append("--header \"Content-Type: application/json; charset=UTF-8\" \\\n").append(prefix) + .append(StringPool.TAB); + sb.append("--request POST \\\n").append(prefix).append(StringPool.TAB); Map data = new LinkedHashMap<>(); for (Parameter parameter : command.getInputParameters()) { if (parameter.getType().equals(TYPES.STRING)) { @@ -121,10 +128,32 @@ public class Manual extends Command { data.put(parameter.getName(), 123456); } else if (parameter.getType().equals(TYPES.BOOLEAN)) { data.put(parameter.getName(), true); + } else if (parameter.getType().equals(TYPES.ARRAY)) { + List> list = new ArrayList<>(); + for (int i = 1; i < 3; i++) { + Map item = new LinkedHashMap<>(); + for (Parameter subParameter : parameter.getSubParameters()) { + if (subParameter.getType().equals(TYPES.STRING) + || (subParameter.getType().equals(TYPES.VARYING) && (i % 2 == 1))) { + String value = subParameter.getName().substring(0, 1).toUpperCase() + + subParameter.getName().substring(1); + value = value.replaceAll("([A-Z])", " $1").substring(1) + StringPool.SPACE + i; + item.put(subParameter.getName(), value); + } else if (subParameter.getType().equals(TYPES.INTEGER) + || subParameter.getType().equals(TYPES.VARYING)) { + item.put(subParameter.getName(), i * 123); + } else if (subParameter.getType().equals(TYPES.BOOLEAN)) { + item.put(subParameter.getName(), i % 2 == 1); + } + } + list.add(item); + } + data.put(parameter.getName(), (Serializable) list); } } if (data.size() > 0) { - sb.append("--data '").append(serializer.serialize(data)).append("' \\\n\t\t"); + sb.append("--data '").append(serializer.serializeDeep(data)).append("' \\\n").append(prefix) + .append(StringPool.TAB); } } sb.append(baseUrl).append(command.getVerb()).append(StringPool.NEW_LINE); diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ManualHtml.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ManualHtml.java index c741bad2..a74612ae 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ManualHtml.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ManualHtml.java @@ -13,8 +13,6 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringUtils; - import com.liferay.portal.kernel.servlet.ServletResponseUtil; import com.liferay.portal.kernel.util.StringPool; @@ -42,118 +40,121 @@ public class ManualHtml extends Manual { .append("Manual").append("") - .append("") - .append(""); + .append("").append(""); result.append("
"); + result.append("
"); + result.append("
"); + result.append("

Sicilia SUE API v1

"); + result.append("
"); + result.append("
"); + for (Command command : CommandList.getList()) { result.append("
"); - result.append("
"); - result.append("

Sicilia SUE API v1

"); - result.append("
"); + result.append("
"); + result.append("

/").append(command.getVerb()); + if (command.isSecure()) + result.append(" [T]"); + result.append("

"); + result.append("

").append(command.getDescription()) + .append(".

"); + result.append("
"); + for (String cmd : command.getMethods()) { + result.append("").append(cmd).append(""); + } result.append("
"); - for (Command command : CommandList.getList()) { - result.append("
"); - result.append("
"); - result.append("

/").append(command.getVerb()); - if (command.isSecure()) - result.append(" [T]"); - result.append("

"); - - result.append("

").append(command.getDescription()).append(".

"); - - result.append("
"); - for(String cmd : command.getMethods() ){ - result.append(""+cmd+""); - } - result.append("
"); - - result.append("
"); - result.append(getCurlExample(command, getBaseUrl(request))); - result.append("
"); - - List parameters = command.getInputParameters(); - result.append("
"); - result.append("

Parametri

"); - if (parameters.isEmpty()) { - result.append("

Nessuno

"); - } else { - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(printTableParameters(parameters, 1)); - result.append(""); - result.append("
CampoObbligatorioTipoDescrizione
"); - } - result.append("
"); - - parameters = command.getOutputParameters(); - result.append("
"); - result.append("

Risposta

"); - if (parameters.isEmpty()) { - result.append("

Nessuno

"); - } else { - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(""); - result.append(printTableParameters(parameters, 1)); - result.append(""); - result.append("
CampoObbligatorioTipoDescrizione
"); - } - result.append("
"); - result.append("
"); - result.append("
"); + result.append("
");
+			result.append(getCurlExample(command, getBaseUrl(request)));
+			result.append("
"); + List parameters = command.getInputParameters(); + result.append("
"); + result.append("

Parametri

"); + if (parameters.isEmpty()) { + result.append("

Nessuno

"); + } else { + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(printTableParameters(parameters, 0, false)); + result.append(""); + result.append("
CampoObbligatorioTipoDescrizione
"); } - result.append("
"); - result.append("
"); - result.append("

"); - result.append("Note
[T] = Richiede token di autenticazione: header di richiesta \""); - result.append(Parameters.X_AUTH_TOKEN).append("\" oppure parametro \"").append(Parameters.TOKEN); - result.append("\"

"); - result.append("
"); result.append("
"); + parameters = command.getOutputParameters(); + result.append("
"); + result.append("

Risposta

"); + if (parameters.isEmpty()) { + result.append("

Nessuno

"); + } else { + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(""); + result.append(printTableParameters(parameters, 0, true)); + result.append(""); + result.append("
CampoOpzionaleTipoDescrizione
"); + } + result.append("
"); + result.append("
"); + result.append("
"); + } + result.append("
"); + result.append("
"); + result.append("

"); + result.append("Note
[T] = Richiede token di autenticazione: header di richiesta \""); + result.append(Parameters.X_AUTH_TOKEN).append("\" oppure parametro JSON \"").append(Parameters.TOKEN); + result.append("\"

"); + result.append("
"); + result.append("
"); result.append("
"); result.append(""); setTextHtml(response); ServletResponseUtil.write(response, result.toString()); } - - private String printTableParameters(List parameters, int level){ + + private String printTableParameters(List parameters, int level, boolean output) { + StringBuilder result = new StringBuilder(); - for (Parameter parameter : parameters) { result.append(""); - result.append("" + parameter.getName() + ""); - result.append(""); - if (parameter.isRequired()) - result.append("Sì"); - else - result.append("No"); - result.append(""); - result.append("" + parameter.getType().toString() + ""); - result.append("" + parameter.getDescription() + ""); + result.append("") + .append(parameter.getName()).append(""); + result.append(""); + if (output) { + if (parameter.isRequired()) { + result.append("No"); + } else { + result.append("Sì"); + } + } else { + if (parameter.isRequired()) { + result.append("Sì"); + } else { + result.append("No"); + } + } + result.append(""); + result.append("").append(parameter.getType().toString()).append(""); + result.append("").append(parameter.getDescription()).append(""); result.append(""); - if (parameter.getType().equals(TYPES.ARRAY)) { - printTableParameters(parameter.getSubParameters(), level++); + result.append(printTableParameters(parameter.getSubParameters(), level + 1, output)); } } - return result.toString(); - } @Override diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Nop.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Nop.java index 81621868..7a2a07a4 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Nop.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Nop.java @@ -10,7 +10,6 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.liferay.portal.kernel.servlet.ServletResponseUtil; import com.liferay.portal.kernel.util.StringPool; public class Nop extends Command { @@ -28,7 +27,7 @@ public class Nop extends Command { public void run(HttpServletRequest request, HttpServletResponse response) throws Exception { if (verifyAccessToken(request, response)) { - ServletResponseUtil.write(response, Response.get(Status.OK)); + Response.write(response, Status.OK); } } diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/SetFields.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/SetFields.java index 6496e03b..449eb3e6 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/SetFields.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/SetFields.java @@ -1,12 +1,13 @@ package it.mwg.sicilia.sue.api.v1.command.impl; -import it.mwg.sicilia.sue.api.v1.ApiUtil; import it.mwg.sicilia.sue.api.v1.Parameters; import it.mwg.sicilia.sue.api.v1.Response; import it.mwg.sicilia.sue.api.v1.Status; import it.mwg.sicilia.sue.api.v1.command.Command; import it.mwg.sicilia.sue.api.v1.parameter.Parameter; import it.mwg.sicilia.sue.api.v1.parameter.Parameter.TYPES; +import it.mwg.sicilia.sue.api.v1.util.ApiUtil; +import it.mwg.sicilia.sue.api.v1.util.DettPraticaUtil; import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.IntPratica; import it.tref.liferay.portos.bo.model.Territorio; @@ -24,7 +25,6 @@ import javax.servlet.http.HttpServletResponse; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; -import com.liferay.portal.kernel.servlet.ServletResponseUtil; import com.liferay.portal.kernel.util.MapUtil; public class SetFields extends Command { @@ -33,10 +33,21 @@ public class SetFields extends Command { static { INPUT_PARAMETERS.add(new Parameter(Parameters.APPLICATION_ID, TYPES.INTEGER, "Id dell'istanza")); Parameter p = new Parameter(Parameters.FIELDS, TYPES.ARRAY, "Elenco di campi da impostare"); - p.addSubParameter(new Parameter(Parameters.NAME, TYPES.STRING, "Nome del campo")); + p.addSubParameter(new Parameter(Parameters.NAME, TYPES.STRING, "Nome del campo come restituito da /" + + getCommandName(ListFields.class))); p.addSubParameter(new Parameter(Parameters.VALUE, TYPES.VARYING, "Valore da impostare per il campo")); + INPUT_PARAMETERS.add(p); } + @SuppressWarnings("serial") + private static final List OUTPUT_PARAMETERS = new ArrayList() { + { + addAll(BASE_OUTPUT_PARAMETERS); + add(new Parameter(Parameters.ADDITIONAL_INFO, TYPES.STRING, + "Eventuali informazioni aggiuntive sull'operazione o sugli errori incontrati", false)); + } + }; + public SetFields(String description, String... methods) { super(description, methods); } @@ -48,18 +59,18 @@ public class SetFields extends Command { List additionalInfo = new ArrayList(); if (!parameters.containsKey(Parameters.APPLICATION_ID)) { additionalInfo.add("Parametro " + Parameters.APPLICATION_ID + " mancante"); - ServletResponseUtil.write(response, Response.get(Status.MALFORMED_REQUEST, additionalInfo)); + Response.write(response, Status.MALFORMED_REQUEST, additionalInfo); return; } if (!parameters.containsKey(Parameters.FIELDS)) { additionalInfo.add("Parametro " + Parameters.FIELDS + " mancante"); - ServletResponseUtil.write(response, Response.get(Status.MALFORMED_REQUEST, additionalInfo)); + Response.write(response, Status.MALFORMED_REQUEST, additionalInfo); return; } Map fields = ApiUtil.getMapStringSerializable(parameters.get(Parameters.FIELDS)); if (null == fields) { additionalInfo.add("Parametro " + Parameters.FIELDS + " non corretto"); - ServletResponseUtil.write(response, Response.get(Status.MALFORMED_REQUEST, additionalInfo)); + Response.write(response, Status.MALFORMED_REQUEST, additionalInfo); return; } long applicationId = MapUtil.getLong(parameters, Parameters.APPLICATION_ID); @@ -68,7 +79,7 @@ public class SetFields extends Command { intPratica = IntPraticaLocalServiceUtil.getIntPratica(applicationId); } catch (PortalException | SystemException e) { additionalInfo.add("Istanza " + applicationId + " non trovata"); - ServletResponseUtil.write(response, Response.get(Status.INVALID_INPUT, additionalInfo)); + Response.write(response, Status.INVALID_INPUT, additionalInfo); return; } DettPratica dettPratica = null; @@ -76,16 +87,29 @@ public class SetFields extends Command { Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); if (territorio.getComuneId() != sportello.getComuneId() || !intPratica.isInLavorazioneSue()) { additionalInfo.add("Istanza " + applicationId + " non modificabile"); - ServletResponseUtil.write(response, Response.get(Status.INVALID_INPUT, additionalInfo)); + Response.write(response, Status.ACCESS_DENIED, additionalInfo); return; } dettPratica = DettPraticaLocalServiceUtil.getLastEditableByIntPratica(applicationId); } catch (PortalException | SystemException e) { additionalInfo.add("Errore del server durante il caricamento dell'istanza"); - ServletResponseUtil.write(response, Response.get(Status.INVALID_INPUT, additionalInfo)); + Response.write(response, Status.SERVER_ERROR, additionalInfo); + return; + } + List errors = DettPraticaUtil.checkValues(fields); + if (!errors.isEmpty()) { + additionalInfo.addAll(errors); + Response.write(response, Status.INVALID_INPUT, additionalInfo); + return; + } + String field = DettPraticaUtil.setFields(dettPratica, fields); + if (null != field) { + additionalInfo.add("Il campo " + field + " non esiste o non è modificabile"); + Response.write(response, Status.INVALID_INPUT, additionalInfo); return; } - ServletResponseUtil.write(response, Response.get(Status.OK)); + DettPraticaLocalServiceUtil.updateDettPratica(dettPratica); + Response.write(response, Status.OK, additionalInfo); } } @@ -96,7 +120,7 @@ public class SetFields extends Command { @Override public List getOutputParameters() { - return BASE_OUTPUT_PARAMETERS; + return OUTPUT_PARAMETERS; } } diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/SetUse.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/SetUse.java deleted file mode 100644 index 140579fd..00000000 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/SetUse.java +++ /dev/null @@ -1,103 +0,0 @@ -package it.mwg.sicilia.sue.api.v1.command.impl; - -import it.mwg.sicilia.sue.api.v1.Parameters; -import it.mwg.sicilia.sue.api.v1.Response; -import it.mwg.sicilia.sue.api.v1.Status; -import it.mwg.sicilia.sue.api.v1.command.Command; -import it.mwg.sicilia.sue.api.v1.parameter.Parameter; -import it.mwg.sicilia.sue.api.v1.parameter.Parameter.TYPES; -import it.tref.liferay.portos.bo.model.DettPratica; -import it.tref.liferay.portos.bo.model.IntPratica; -import it.tref.liferay.portos.bo.model.Territorio; -import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; -import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil; -import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil; - -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.liferay.portal.kernel.exception.PortalException; -import com.liferay.portal.kernel.exception.SystemException; -import com.liferay.portal.kernel.servlet.ServletResponseUtil; -import com.liferay.portal.kernel.util.MapUtil; - -public class SetUse extends Command { - - @SuppressWarnings("serial") - private static final List INPUT_PARAMETERS = new ArrayList() { - { - add(new Parameter(Parameters.APPLICATION_ID, TYPES.INTEGER, "Id dell'istanza")); - add(new Parameter(Parameters.CODE, TYPES.STRING, "Codice della destinazione d'uso come restituito da /" - + getCommandName(ListUses.class))); - add(new Parameter(Parameters.DESCRIPTION, TYPES.STRING, - "Descrizione della destinazione d'uso, obbligatoria* se " + Parameters.CODE + " = 3", false)); - } - }; - - public SetUse(String description, String... methods) { - super(description, methods); - } - - @Override - public void run(HttpServletRequest request, HttpServletResponse response) throws Exception { - - if (verifyAccessToken(request, response)) { - List additionalInfo = new ArrayList(); - if (!parameters.containsKey(Parameters.APPLICATION_ID)) { - additionalInfo.add("Parametro " + Parameters.APPLICATION_ID + " mancante"); - ServletResponseUtil.write(response, Response.get(Status.MALFORMED_REQUEST, additionalInfo)); - return; - } - if (!parameters.containsKey(Parameters.CODE)) { - additionalInfo.add("Parametro " + Parameters.CODE + " mancante"); - ServletResponseUtil.write(response, Response.get(Status.MALFORMED_REQUEST, additionalInfo)); - return; - } - long applicationId = MapUtil.getLong(parameters, Parameters.APPLICATION_ID); - String code = MapUtil.getString(parameters, Parameters.CODE); - if (!DettPraticaLocalServiceUtil.getDestinazioniUso().containsKey(code)) { - additionalInfo.add("Parametro " + Parameters.CODE + " = " + code + " non valido"); - ServletResponseUtil.write(response, Response.get(Status.MALFORMED_REQUEST, additionalInfo)); - return; - } - IntPratica intPratica = null; - try { - intPratica = IntPraticaLocalServiceUtil.getIntPratica(applicationId); - } catch (PortalException | SystemException e) { - additionalInfo.add("Istanza " + applicationId + " non trovata"); - ServletResponseUtil.write(response, Response.get(Status.INVALID_INPUT, additionalInfo)); - return; - } - DettPratica dettPratica = null; - try { - Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); - if (territorio.getComuneId() != sportello.getComuneId() || !intPratica.isInLavorazioneSue()) { - additionalInfo.add("Istanza " + applicationId + " non modificabile"); - ServletResponseUtil.write(response, Response.get(Status.INVALID_INPUT, additionalInfo)); - return; - } - dettPratica = DettPraticaLocalServiceUtil.getLastEditableByIntPratica(applicationId); - } catch (PortalException | SystemException e) { - additionalInfo.add("Errore del server durante il caricamento dell'istanza"); - ServletResponseUtil.write(response, Response.get(Status.INVALID_INPUT, additionalInfo)); - return; - } - dettPratica.setDestinazione(code); - DettPraticaLocalServiceUtil.updateDettPratica(dettPratica); - ServletResponseUtil.write(response, Response.get(Status.OK)); - } - } - - @Override - public List getInputParameters() { - return INPUT_PARAMETERS; - } - - @Override - public List getOutputParameters() { - return BASE_OUTPUT_PARAMETERS; - } -} diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/ApiUtil.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/util/ApiUtil.java similarity index 97% rename from liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/ApiUtil.java rename to liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/util/ApiUtil.java index 97e6c270..efdaa366 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/ApiUtil.java +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/util/ApiUtil.java @@ -1,5 +1,6 @@ -package it.mwg.sicilia.sue.api.v1; +package it.mwg.sicilia.sue.api.v1.util; +import it.mwg.sicilia.sue.api.v1.ApiConstants; import it.mwg.sicilia.sue.service.ApiSettingLocalServiceUtil; import java.io.Serializable; diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/util/DettPraticaUtil.java b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/util/DettPraticaUtil.java new file mode 100644 index 00000000..b48c98da --- /dev/null +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/util/DettPraticaUtil.java @@ -0,0 +1,175 @@ +package it.mwg.sicilia.sue.api.v1.util; + +import it.mwg.sicilia.sue.api.v1.bean.Value; +import it.tref.liferay.portos.bo.model.DettPratica; +import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; + +import java.io.Serializable; +import java.lang.reflect.Method; +import java.sql.Types; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +public class DettPraticaUtil { + + private static final List FIELDS = DettPraticaLocalServiceUtil.getDettPraticaFields(); + private static final Map FIELD_TYPES; + private static final Map> FIELD_VALUES = new HashMap<>(); + + public static String setFields(DettPratica dettPratica, Map fields) { + + for (String fieldName : fields.keySet()) { + if (!FIELDS.contains(fieldName)) { + return fieldName; + } + String methodName = "set" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1); + Serializable field = fields.get(fieldName); + Class clazz = field.getClass(); + try { + Method method; + if (Boolean.class.equals(clazz)) { + method = dettPratica.getClass().getMethod(methodName, boolean.class); + } else if (Long.class.equals(clazz)) { + try { + method = dettPratica.getClass().getMethod(methodName, long.class); + } catch (NoSuchMethodException e) { + method = dettPratica.getClass().getMethod(methodName, int.class); + field = ((Long) field).intValue(); + } + } else { + method = dettPratica.getClass().getMethod(methodName, clazz); + } + method.invoke(dettPratica, field); + } catch (Exception e) { + return fieldName; + } + } + return null; + } + + public static List checkValues(Map fields) { + + List result = new ArrayList<>(); + for (String fieldName : fields.keySet()) { + Serializable field = fields.get(fieldName); + Class clazz = null; + switch (FIELD_TYPES.get(fieldName)) { + case Types.BIGINT: + case Types.INTEGER: + case Types.TIMESTAMP: + clazz = Long.class; + break; + case Types.BOOLEAN: + clazz = Boolean.class; + break; + case Types.DOUBLE: + clazz = Double.class; + break; + case Types.VARCHAR: + clazz = String.class; + break; + } + if (!field.getClass().equals(clazz)) { + result.add("Tipo dati non corretto per il campo " + fieldName); + } + } + for (String field : fields.keySet()) { + // if (FIELD_MAPS.containsKey(field)) { + // Serializable value = fields.get(field); + // if (!FIELD_MAPS.get(field).keySet().contains(value)) { + // result.add("Valore " + value + " non valido per il campo " + field); + // } + // } else if (FIELD_VALUES.containsKey(field)) { + // Serializable value = fields.get(field); + // if (!FIELD_VALUES.get(field).contains(value)) { + // result.add("Valore non valido " + field + " = " + value); + // } + // } + } + return result; + } + + public static String getFieldValues(String fieldName) { + + String result = getLabelsString(fieldName); + if (null == result) { + result = getValuesString(fieldName); + } + return result; + } + + private static String getLabelsString(String fieldName) { + + String result = null; + // if (FIELD_MAPS.containsKey(fieldName)) { + // StringBuilder sb = new StringBuilder(); + // for (Serializable value : FIELD_MAPS.get(fieldName)) { + // if (sb.length() > 0) { + // sb.append(StringPool.COMMA_AND_SPACE); + // } + // sb.append(StringPool.QUOTE).append(value).append(StringPool.QUOTE); + // } + // result = sb.toString(); + // } + return result; + } + + private static String getValuesString(String fieldName) { + + String result = null; + // if (FIELD_VALUES.containsKey(fieldName)) { + // StringBuilder sb = new StringBuilder(); + // for (Serializable value : FIELD_VALUES.get(fieldName)) { + // if (sb.length() > 0) { + // sb.append(StringPool.COMMA_AND_SPACE); + // } + // if (String.class.equals(value.getClass())) { + // sb.append(StringPool.QUOTE).append(value).append(StringPool.QUOTE); + // } else { + // sb.append(value); + // } + // } + // result = sb.toString(); + // } + return result; + } + + private static List withoutLabel(Serializable... values) { + + List result = new ArrayList<>(); + for (int i = 0; i < values.length; i++) { + result.add(new Value(values[i], (String) values[i])); + } + return result; + } + + private static List withLabel(Serializable... values) { + + List result = new ArrayList<>(); + for (int i = 0; i < values.length; i += 2) { + result.add(new Value(values[i], (String) values[i + 1])); + } + return result; + } + + static { + FIELD_TYPES = DettPraticaLocalServiceUtil.getDettPraticaFieldsTypes(); + FIELD_TYPES.put("geoConsolidamento", Types.BOOLEAN); + FIELD_TYPES.put("geoEvidenzeGeologiche", Types.BOOLEAN); + FIELD_TYPES.put("geoEvidenzeGeomorfiche", Types.BOOLEAN); + FIELD_TYPES.put("geoOperaRilevante", Types.BOOLEAN); + FIELD_TYPES.put("geoOpereDiSostegno", Types.BOOLEAN); + FIELD_TYPES.put("geoPresenzaPrescrizioni", Types.BOOLEAN); + List uses = new ArrayList<>(); + for (Entry e : DettPraticaLocalServiceUtil.getDestinazioniUso().entrySet()) { + uses.add(new Value(e.getKey(), e.getValue())); + } + FIELD_VALUES.put("destinazione", uses); + FIELD_VALUES.put("geoClasseIndagine", + withLabel("1", "1", "2", "2", "3", "3", "4", "4", "NA", "Non applicabile")); + FIELD_VALUES.put("geoOperaRilevante", withLabel(null, "NULL", true, "Sì", false, "No")); + } +} diff --git a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/css/api/v1/api.css b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/css/api/v1/api.css index 01ba06fc..bc10dc97 100644 --- a/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/css/api/v1/api.css +++ b/liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/css/api/v1/api.css @@ -1,51 +1,10 @@ -/* http://meyerweb.com/eric/tools/css/reset/ - v2.0 | 20110126 - License: none (public domain) */ -/*html, body, div, span, applet, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, big, cite, code, -del, dfn, em, img, ins, kbd, q, s, samp, -small, strike, strong, sub, sup, tt, var, -b, u, i, center, -dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td, -article, aside, canvas, details, embed, -figure, figcaption, footer, header, hgroup, -menu, nav, output, ruby, section, summary, -time, mark, audio, video { - margin: 0; - padding: 0; - border: 0; - font-size: 100%; - font: inherit; - vertical-align: baseline; -} -article, aside, details, figcaption, figure, -footer, header, hgroup, menu, nav, section { - display: block; -} -body { - line-height: 1; -} -ol, ul { - list-style: none; -} -blockquote, q { - quotes: none; -} -blockquote:before, blockquote:after, -q:before, q:after { - content: ''; - content: none; -} -table { - border-collapse: collapse; - border-spacing: 0; -}*/ -/* End reset.css */ - .badge.badge-success[data-type="post"] { background-color: #007bff; } - +pre { + padding: 0.2rem 0.4rem !important; + font-size: 87.5% !important; + color: #fff !important; + background-color: #212529; + border-radius: 0.2rem; +} diff --git a/liferay-plugins-sdk-6.2/webs/portos-kaleo-web/docroot/WEB-INF/src/service.properties b/liferay-plugins-sdk-6.2/webs/portos-kaleo-web/docroot/WEB-INF/src/service.properties index 48f307d4..6b238df9 100644 --- a/liferay-plugins-sdk-6.2/webs/portos-kaleo-web/docroot/WEB-INF/src/service.properties +++ b/liferay-plugins-sdk-6.2/webs/portos-kaleo-web/docroot/WEB-INF/src/service.properties @@ -13,8 +13,8 @@ ## build.namespace=Kaleo - build.number=50 - build.date=1624450810353 + build.number=51 + build.date=1624550499018 build.auto.upgrade=true ##