Salvatore La Manna 4 anni fa
parent
commit
1fee548a91
  1. 2
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/edit_modal_fascicolo.jsp
  2. BIN
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/lib/sicilia-sue-connector-portlet-service.jar
  3. 4
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/service/it/mwg/sicilia/sue/model/Sportello.java
  4. 19
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/service/it/mwg/sicilia/sue/model/SportelloClp.java
  5. 7
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/service/it/mwg/sicilia/sue/model/SportelloWrapper.java
  6. 7
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Parameters.java
  7. 26
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Response.java
  8. 12
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Status.java
  9. 27
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Application.java
  10. 26
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/ApplicationType.java
  11. 3
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Document.java
  12. 48
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/Command.java
  13. 28
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/CommandList.java
  14. 186
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/AddApplication.java
  15. 18
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Applications.java
  16. 11
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Documents.java
  17. 75
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListApplications.java
  18. 11
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Login.java
  19. 4
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Manual.java
  20. 8
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ManualHtml.java
  21. 11
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Nop.java
  22. 2
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/parameter/Parameter.java
  23. 2
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/model/impl/SportelloImpl.java
  24. 4
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/service.properties

2
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/edit_modal_fascicolo.jsp

@ -1,5 +1,5 @@
<%@page import="it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil"%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil"%>
<%@ include file="/html/fascicolofe/init.jsp" %>
<% String formName = ParamUtil.getString(request, "formName","fm"); %>
<div class="container-fluid add-new-project">

BIN
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/lib/sicilia-sue-connector-portlet-service.jar

File binario non mostrato.

4
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/service/it/mwg/sicilia/sue/model/Sportello.java

@ -49,4 +49,8 @@ public interface Sportello extends SportelloModel, PersistedModel {
public java.lang.String getNomeProvincia()
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException;
public it.tref.liferay.portos.bo.model.Comune getComune()
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException;
}

19
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/service/it/mwg/sicilia/sue/model/SportelloClp.java

@ -712,6 +712,25 @@ public class SportelloClp extends BaseModelImpl<Sportello> implements Sportello
}
}
@Override
public it.tref.liferay.portos.bo.model.Comune getComune() {
try {
String methodName = "getComune";
Class<?>[] parameterTypes = new Class<?>[] { };
Object[] parameterValues = new Object[] { };
it.tref.liferay.portos.bo.model.Comune returnObj = (it.tref.liferay.portos.bo.model.Comune)invokeOnRemoteModel(methodName,
parameterTypes, parameterValues);
return returnObj;
}
catch (Exception e) {
throw new UnsupportedOperationException(e);
}
}
@Override
public boolean checkPassword(java.lang.String password) {
try {

7
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/service/it/mwg/sicilia/sue/model/SportelloWrapper.java

@ -756,6 +756,13 @@ public class SportelloWrapper implements Sportello, ModelWrapper<Sportello> {
return _sportello.getNomeProvincia();
}
@Override
public it.tref.liferay.portos.bo.model.Comune getComune()
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException {
return _sportello.getComune();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {

7
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Parameters.java

@ -2,15 +2,22 @@ package it.mwg.sicilia.sue.api.v1;
public class Parameters {
public static final String ADDITIONAL_INFO = "additionalInfo";
public static final String APPLICATION = "application";
public static final String APPLICATION_ID = "applicationId";
public static final String APPLICATIONS = "applications";
public static final String CODE = "code";
public static final String DESCRIPTION = "description";
public static final String DOCUMENTS = "documents";
public static final String FIRST_NAME = "firstName";
public static final String LAST_NAME = "lastName";
public static final String PASSWORD = "password";
public static final String STATUS_CODE = "statusCode";
public static final String STATUS_MESSAGE = "statusMessage";
public static final String SUE_ID = "sueId";
public static final String TOKEN = "token";
public static final String TYPE = "type";
public static final String USERNAME = "username";
public static final String VAT_ID = "vatId";
public static final String X_AUTH_TOKEN = "X-Auth-Token";
}

26
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Response.java

@ -3,21 +3,20 @@ package it.mwg.sicilia.sue.api.v1;
import java.io.IOException;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
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.util.StringPool;
public class Response {
private static final JSONSerializer serializer = JSONFactoryUtil.createJSONSerializer().exclude("*.class");
public static String get(int statusCode) throws IOException {
return get(statusCode, null);
}
public static String get(int statusCode, Map<String, Serializable> extraData) {
public static String get(int statusCode, Map<String, Serializable> extraData, List<String> additionalInfo) {
Map<String, Serializable> map = new LinkedHashMap<>();
map.put(Parameters.STATUS_CODE, statusCode);
@ -25,6 +24,21 @@ public class Response {
if (null != extraData) {
map.putAll(extraData);
}
if (null != additionalInfo) {
map.put(Parameters.ADDITIONAL_INFO, StringUtils.join(additionalInfo, StringPool.NEW_LINE));
}
return serializer.serializeDeep(map);
}
public static String get(int statusCode) throws IOException {
return get(statusCode, null, null);
}
public static String get(int statusCode, Map<String, Serializable> extraData) {
return get(statusCode, extraData, null);
}
public static String get(int statusCode, List<String> additionalInfo) {
return get(statusCode, null, additionalInfo);
}
}

12
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/Status.java

@ -17,12 +17,12 @@ public class Status {
private static final Map<Integer, String> messages = new HashMap<Integer, String>() {
{
put(OK, "OK");
put(EXPIRED_TOKEN, "This token has expired");
put(INACTIVE_USER, "Inactive user");
put(INVALID_TOKEN, "Invalid token");
put(MALFORMED_REQUEST, "Malformed request");
put(SERVER_ERROR, "Internal server error");
put(WRONG_USERNAME_OR_PASSWORD, "Wrong user name or password");
put(EXPIRED_TOKEN, "Questo token è scaduto");
put(INACTIVE_USER, "L'utente non è attivo");
put(INVALID_TOKEN, "Token non valido");
put(MALFORMED_REQUEST, "Richiesta non corretta");
put(SERVER_ERROR, "Errore interno del server");
put(WRONG_USERNAME_OR_PASSWORD, "Nome utente o password errati");
}
};

27
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Application.java

@ -2,26 +2,29 @@ package it.mwg.sicilia.sue.api.v1.bean;
import java.io.Serializable;
@SuppressWarnings("serial")
public class Application implements Serializable {
private static final long serialVersionUID = -5683688958577468949L;
private long applicationId;
private String type;
private String vatId;
private String code;
private String description;
public Application(long applicationId, String type, String vatId) {
public Application(String code, String description) {
this.code = code;
this.description = description;
this.applicationId = applicationId;
this.type = type;
this.vatId = vatId;
}
public String getCode() {
return code;
public long getApplicationId() {
return applicationId;
}
public String getDescription() {
public String getType() {
return type;
}
return description;
public String getVatId() {
return vatId;
}
}

26
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/ApplicationType.java

@ -0,0 +1,26 @@
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;
}
}

3
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/bean/Document.java

@ -2,10 +2,9 @@ package it.mwg.sicilia.sue.api.v1.bean;
import java.io.Serializable;
@SuppressWarnings("serial")
public class Document implements Serializable {
private static final long serialVersionUID = -5986191295042945520L;
private String code;
private String description;

48
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/Command.java

@ -1,13 +1,14 @@
package it.mwg.sicilia.sue.api.v1.command;
import it.mwg.sicilia.sue.ExpiredTokenException;
import it.mwg.sicilia.sue.InactiveSportelloException;
import it.mwg.sicilia.sue.InvalidTokenException;
import it.mwg.sicilia.sue.api.v1.AccessToken;
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.parameter.Parameter;
import it.mwg.sicilia.sue.model.Sportello;
import it.mwg.sicilia.sue.service.SportelloLocalServiceUtil;
import java.io.IOException;
import java.io.InputStreamReader;
@ -21,6 +22,8 @@ import java.util.Map;
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.json.JSONDeserializer;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.log.Log;
@ -35,20 +38,29 @@ public abstract class Command {
protected static final Log _log = LogFactoryUtil.getLog(Command.class);
protected static final List<Parameter> EMPTY_PARAMETERS = new ArrayList<>();
@SuppressWarnings("serial")
protected static final List<Parameter> BASE_OUTPUT_PARAMETERS = new ArrayList<Parameter>() {
{
add(new Parameter(Parameters.STATUS_CODE, Parameter.TYPES.INTEGER, "Codice di stato"));
add(new Parameter(Parameters.STATUS_MESSAGE, Parameter.TYPES.STRING, "Breve descrizione dello stato"));
}
};
protected Map<String, Serializable> parameters = null;
protected Sportello sportello = null;
private String verb;
private List<String> methods;
private String description;
private AccessToken accessToken;
private static final String[] defaultMethods = { HttpMethods.POST };
private static final JSONDeserializer<Map<String, Serializable>> deserializer = JSONFactoryUtil
.createJSONDeserializer();
public Command(String verb, String description, String... methods) {
public Command(String description, String... methods) {
this.verb = verb;
this.verb = getCommandName();
this.methods = Arrays.asList(methods.length > 0 ? methods : defaultMethods);
this.description = description;
}
@ -66,7 +78,9 @@ public abstract class Command {
}
public abstract void run(HttpServletRequest request, HttpServletResponse response) throws Exception;
public abstract List<Parameter> getInputParameters();
public abstract List<Parameter> getOutputParameters();
public boolean isSecure() {
@ -90,6 +104,18 @@ public abstract class Command {
return parameters;
}
protected String getCommandName() {
return getCommandName(getClass().getSimpleName());
}
protected static String getCommandName(Class<?> clazz) {
return getCommandName(clazz.getSimpleName());
}
protected static String getCommandName(String simpleName) {
return simpleName.replaceAll("([A-Z])", "_$1").substring(1).toLowerCase();
}
protected void setJson(HttpServletResponse response) {
response.setContentType(ContentTypes.APPLICATION_JSON);
@ -114,12 +140,13 @@ public abstract class Command {
} else {
try {
try {
new AccessToken(token);
accessToken = new AccessToken(token);
sportello = SportelloLocalServiceUtil.getSportello(accessToken.getSportelloId());
} catch (InvalidTokenException e) {
ServletResponseUtil.write(response, Response.get(Status.INVALID_TOKEN));
} catch (ExpiredTokenException e) {
ServletResponseUtil.write(response, Response.get(Status.EXPIRED_TOKEN));
} catch (InactiveSportelloException e) {
} catch (PortalException | SystemException e) {
ServletResponseUtil.write(response, Response.get(Status.INACTIVE_USER));
} catch (Exception e) {
ServletResponseUtil.write(response, Response.get(Status.SERVER_ERROR));
@ -130,4 +157,15 @@ public abstract class Command {
}
return false;
}
protected Sportello getSportello() {
if (null == sportello) {
try {
sportello = SportelloLocalServiceUtil.getSportello(accessToken.getSportelloId());
} catch (PortalException | SystemException e) {
}
}
return sportello;
}
}

28
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/CommandList.java

@ -1,7 +1,9 @@
package it.mwg.sicilia.sue.api.v1.command;
import it.mwg.sicilia.sue.api.v1.command.impl.AddApplication;
import it.mwg.sicilia.sue.api.v1.command.impl.Applications;
import it.mwg.sicilia.sue.api.v1.command.impl.Documents;
import it.mwg.sicilia.sue.api.v1.command.impl.ListApplications;
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;
@ -12,26 +14,24 @@ import java.util.LinkedHashMap;
import java.util.Map;
import com.liferay.portal.kernel.servlet.HttpMethods;
import com.liferay.portal.kernel.util.StringPool;
public class CommandList {
private static final Map<String, Command> commands = new LinkedHashMap<>();
static {
addCommand(new Manual("manual", "Restituisce la documentazione dell'API generata automaticamente",
HttpMethods.GET, HttpMethods.POST));
addCommand(new ManualHtml("manual_html",
"Restituisce la documentazione dell'API generata automaticamente in versione HTML", HttpMethods.GET,
HttpMethods.POST));
addCommand(new Login("login", "Esegue l'accesso con nome email e password e restituisce un token di accesso"));
addCommand(new Applications("applications",
"Riceve l'elenco delle istanze valide contenenti codice e descrizione", HttpMethods.GET,
HttpMethods.POST));
addCommand(new Documents("documents",
"Riceve l'elenco dei documenti riconosciuti dal portale con codice e descrizione", HttpMethods.GET,
HttpMethods.POST));
addCommand(new Nop(StringPool.BLANK, "NOP verifica la connettività senza eseguire operazioni", HttpMethods.GET,
addCommand(new Manual("Restituisce la documentazione dell'API generata automaticamente", HttpMethods.GET,
HttpMethods.POST));
addCommand(new ManualHtml("Restituisce la documentazione dell'API generata automaticamente in versione HTML",
HttpMethods.GET, HttpMethods.POST));
addCommand(new Login("Esegue l'accesso con nome email e password e restituisce un token di accesso"));
addCommand(new Applications("Riceve l'elenco delle istanze valide contenenti codice e descrizione",
HttpMethods.GET, HttpMethods.POST));
addCommand(new AddApplication(
"(IN SVILUPPO) Crea una nuova istanza di endoprocedimento, crea l'utente se non esiste ancora sul portale"));
addCommand(new ListApplications("Elenca le istanze inserite da questo SUE", HttpMethods.GET, HttpMethods.POST));
addCommand(new Documents("Riceve l'elenco dei documenti riconosciuti dal portale con codice e descrizione",
HttpMethods.GET, HttpMethods.POST));
addCommand(new Nop("NOP verifica la connettività senza eseguire operazioni", HttpMethods.GET, HttpMethods.POST));
}
private static void addCommand(Command command) {

186
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/AddApplication.java

@ -0,0 +1,186 @@
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.tref.liferay.portos.bo.model.Comune;
import it.tref.liferay.portos.bo.model.DettPratica;
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.io.Serializable;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
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;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.User;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.UserLocalServiceUtil;
public class AddApplication extends Command {
@SuppressWarnings("serial")
private static final List<Parameter> INPUT_PARAMETERS = new ArrayList<Parameter>() {
{
add(new Parameter(Parameters.VAT_ID, Parameter.TYPES.STRING, "Codice fiscale del titolare digitale"));
add(new Parameter(Parameters.FIRST_NAME, Parameter.TYPES.STRING, "Nome del titolare digitale", false));
add(new Parameter(Parameters.LAST_NAME, Parameter.TYPES.STRING, "Cognome del titolare digitale", false));
add(new Parameter(Parameters.TYPE, Parameter.TYPES.STRING,
"Codice del tipo di istanza, come restituito da /" + getCommandName(Applications.class)));
add(new Parameter(Parameters.SUE_ID, Parameter.TYPES.STRING, "Estremi pratica SUE/SUAP", false));
}
};
@SuppressWarnings("serial")
private static final List<Parameter> OUTPUT_PARAMETERS = new ArrayList<Parameter>() {
{
addAll(BASE_OUTPUT_PARAMETERS);
add(new Parameter(Parameters.APPLICATION_ID, Parameter.TYPES.INTEGER,
"Identificatore del procedimento creato, da utilizzare nelle successive operazioni"));
add(new Parameter(Parameters.ADDITIONAL_INFO, Parameter.TYPES.STRING,
"Eventuali informazioni aggiuntive sull'operazione o sugli errori incontrati"));
}
};
public AddApplication(String description, String... methods) {
super(description, methods);
}
@Override
public void run(HttpServletRequest request, HttpServletResponse response) throws Exception {
if (verifyAccessToken(request, response)) {
List<String> additionalInfo = new ArrayList<>();
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));
return;
}
String tipoProcedura = MapUtil.getString(parameters, Parameters.TYPE);
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));
return;
}
String lastName = MapUtil.getString(parameters, Parameters.LAST_NAME, screenName);
String firstName = MapUtil.getString(parameters, Parameters.FIRST_NAME, lastName);
Comune comune = null;
Territorio territorio = null;
try {
comune = sportello.getComune();
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));
return;
}
Date date = new Date();
long companyId = comune.getCompanyId();
User user = null;
try {
user = UserLocalServiceUtil.fetchUserByScreenName(companyId, screenName);
if (Validator.isNull(user)) {
long creatorUserId = UserLocalServiceUtil.getDefaultUserId(companyId);
boolean autoPassword = true;
String password = randomPassword(24);
boolean autoScreenName = false;
String emailAddress = screenName + "@no-email.regione.sicilia.it";
long facebookId = 0;
String openId = StringPool.BLANK;
Locale locale = Locale.ITALY;
String middleName = StringPool.BLANK;
int prefixId = 0;
int suffixId = 0;
boolean male = true;
int birthdayMonth = 0;
int birthdayDay = 1;
int birthdayYear = 1970;
String jobTitle = StringPool.BLANK;
long[] groupIds = null;
long[] organizationIds = null;
long[] roleIds = null;
long[] userGroupIds = null;
boolean sendEmail = false;
ServiceContext serviceContext = new ServiceContext();
user = UserLocalServiceUtil.addUser(creatorUserId, companyId, autoPassword, password, password,
autoScreenName, screenName, emailAddress, facebookId, openId, locale, firstName,
middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear,
jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext);
user.setPasswordModified(true);
user.setPasswordModifiedDate(date);
user.setPasswordReset(false);
UserLocalServiceUtil.updateUser(user);
additionalInfo.add("L'utente " + screenName + " è stato creato");
} else {
additionalInfo.add("L'utente " + screenName + " esiste");
}
} catch (PortalException | SystemException e) {
additionalInfo.add("Errore durante la creazione dell'utente " + screenName);
ServletResponseUtil.write(response, Response.get(Status.SERVER_ERROR, additionalInfo));
return;
}
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(sportello.getCompanyId());
serviceContext.setScopeGroupId(sportello.getGroupId());
serviceContext.setUserId(user.getUserId());
serviceContext.setCreateDate(date);
serviceContext.setModifiedDate(date);
DettPratica dettPratica = null;
try {
dettPratica = DettPraticaLocalServiceUtil.addDettPratica(territorio.getTerritorioId(), tipoProcedura,
serviceContext);
String sueId = MapUtil.getString(parameters, Parameters.SUE_ID);
if (Validator.isNotNull(sueId)) {
dettPratica.setEstremiPratCom(sueId);
DettPraticaLocalServiceUtil.updateDettPratica(dettPratica);
}
} catch (PortalException | SystemException e) {
additionalInfo.add("Errore durante la creazione dell'istanza");
ServletResponseUtil.write(response, Response.get(Status.SERVER_ERROR, additionalInfo));
return;
}
Map<String, Serializable> result = new HashMap<>();
result.put(Parameters.APPLICATION_ID, dettPratica.getIntPraticaId());
ServletResponseUtil.write(response, Response.get(Status.OK, result, additionalInfo));
}
}
private String randomPassword(int length) {
SecureRandom rnd = new SecureRandom();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < length; i++) {
sb.append((char) (32 + rnd.nextInt(95)));
}
return sb.toString();
}
@Override
public List<Parameter> getInputParameters() {
return INPUT_PARAMETERS;
}
@Override
public List<Parameter> getOutputParameters() {
return OUTPUT_PARAMETERS;
}
}

18
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Applications.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.Application;
import it.mwg.sicilia.sue.api.v1.bean.ApplicationType;
import it.mwg.sicilia.sue.api.v1.command.Command;
import it.mwg.sicilia.sue.api.v1.parameter.Parameter;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
@ -25,15 +25,15 @@ public class Applications extends Command {
private static final List<Parameter> OUTPUT_PARAMETERS = new ArrayList<Parameter>();
static {
Parameter p = new Parameter(Parameters.DOCUMENTS, Parameter.TYPES.ARRAY, "elenco di istanze presentabili");
p.addSubParameter(new Parameter(Parameters.CODE, Parameter.TYPES.STRING, "codice dell'istanza"));
p.addSubParameter(new Parameter(Parameters.DESCRIPTION, Parameter.TYPES.STRING, "descrizione dell'istanza"));
OUTPUT_PARAMETERS.addAll(BASE_OUTPUT_PARAMETERS);
Parameter p = new Parameter(Parameters.DOCUMENTS, Parameter.TYPES.ARRAY, "Elenco di istanze presentabili");
p.addSubParameter(new Parameter(Parameters.CODE, Parameter.TYPES.STRING, "Codice dell'istanza"));
p.addSubParameter(new Parameter(Parameters.DESCRIPTION, Parameter.TYPES.STRING, "Descrizione dell'istanza"));
OUTPUT_PARAMETERS.add(p);
};
public Applications(String verb, String description, String... methods) {
super(verb, description, methods);
public Applications(String description, String... methods) {
super(description, methods);
}
@Override
@ -41,9 +41,9 @@ public class Applications extends Command {
if (verifyAccessToken(request, response)) {
Map<String, String> procedure = IntPraticaLocalServiceUtil.getTipiProcedure();
List<Application> list = new ArrayList<>(procedure.size());
List<ApplicationType> list = new ArrayList<>(procedure.size());
for (Entry<String, String> entry : procedure.entrySet()) {
list.add(new Application(entry.getKey(), entry.getValue().replaceAll("^[0-9\\.]+\\)\\s*",
list.add(new ApplicationType(entry.getKey(), entry.getValue().replaceAll("^[0-9\\.]+\\)\\s*",
StringPool.BLANK)));
}
Map<String, Serializable> result = new HashMap<>();

11
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Documents.java

@ -25,14 +25,15 @@ public class Documents extends Command {
private static final List<Parameter> OUTPUT_PARAMETERS = new ArrayList<Parameter>();
static {
Parameter p = new Parameter(Parameters.DOCUMENTS, Parameter.TYPES.ARRAY, "elenco di documenti");
p.addSubParameter(new Parameter(Parameters.CODE, Parameter.TYPES.STRING, "codice del documento"));
p.addSubParameter(new Parameter(Parameters.DESCRIPTION, Parameter.TYPES.STRING, "descrizione del documento"));
OUTPUT_PARAMETERS.addAll(BASE_OUTPUT_PARAMETERS);
Parameter p = new Parameter(Parameters.DOCUMENTS, Parameter.TYPES.ARRAY, "Elenco di documenti");
p.addSubParameter(new Parameter(Parameters.CODE, Parameter.TYPES.STRING, "Codice del documento"));
p.addSubParameter(new Parameter(Parameters.DESCRIPTION, Parameter.TYPES.STRING, "Descrizione del documento"));
OUTPUT_PARAMETERS.add(p);
};
public Documents(String verb, String description, String... methods) {
super(verb, description, methods);
public Documents(String description, String... methods) {
super(description, methods);
}
@Override

75
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ListApplications.java

@ -0,0 +1,75 @@
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.Application;
import it.mwg.sicilia.sue.api.v1.command.Command;
import it.mwg.sicilia.sue.api.v1.parameter.Parameter;
import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Territorio;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
import com.liferay.portal.model.User;
import com.liferay.portal.service.UserLocalServiceUtil;
public class ListApplications extends Command {
private static final List<Parameter> OUTPUT_PARAMETERS = new ArrayList<Parameter>();
static {
OUTPUT_PARAMETERS.addAll(BASE_OUTPUT_PARAMETERS);
Parameter p = new Parameter(Parameters.APPLICATIONS, Parameter.TYPES.ARRAY, "Elenco di istanze presentate");
p.addSubParameter(new Parameter(Parameters.APPLICATION_ID, Parameter.TYPES.INTEGER,
"Identificatore dell'istanza"));
p.addSubParameter(new Parameter(Parameters.TYPE, Parameter.TYPES.STRING, "Tipo dell'istanza"));
p.addSubParameter(new Parameter(Parameters.VAT_ID, Parameter.TYPES.STRING,
"Codice fiscale del titolare digitale"));
OUTPUT_PARAMETERS.add(p);
};
public ListApplications(String description, String... methods) {
super(description, methods);
}
@Override
public void run(HttpServletRequest request, HttpServletResponse response) throws Exception {
if (verifyAccessToken(request, response)) {
List<Application> applications = new ArrayList<>();
for (Territorio territorio : TerritorioLocalServiceUtil.findByComuneId(sportello.getComuneId(),
QueryUtil.ALL_POS, QueryUtil.ALL_POS)) {
for (IntPratica intPratica : IntPraticaLocalServiceUtil
.findByTerritorioId(territorio.getTerritorioId())) {
User user = UserLocalServiceUtil.getUser(intPratica.getUserId());
applications.add(new Application(intPratica.getIntPraticaId(), intPratica.getTipoProcedura(), user
.getScreenName()));
}
}
Map<String, Serializable> result = new HashMap<>();
result.put(Parameters.APPLICATIONS, (Serializable) applications);
ServletResponseUtil.write(response, Response.get(Status.OK, result));
}
}
@Override
public List<Parameter> getInputParameters() {
return EMPTY_PARAMETERS;
}
@Override
public List<Parameter> getOutputParameters() {
return OUTPUT_PARAMETERS;
}
}

11
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Login.java

@ -28,19 +28,20 @@ public class Login extends Command {
@SuppressWarnings("serial")
private static final List<Parameter> INPUT_PARAMETERS = new ArrayList<Parameter>() {
{
add(new Parameter(Parameters.USERNAME, Parameter.TYPES.STRING, "nome utente"));
add(new Parameter(Parameters.PASSWORD, Parameter.TYPES.STRING, "password"));
add(new Parameter(Parameters.USERNAME, Parameter.TYPES.STRING, "Nome utente"));
add(new Parameter(Parameters.PASSWORD, Parameter.TYPES.STRING, "Password"));
}
};
@SuppressWarnings("serial")
private static final List<Parameter> OUTPUT_PARAMETERS = new ArrayList<Parameter>() {
{
add(new Parameter(Parameters.TOKEN, Parameter.TYPES.STRING, "token di autorizzazione"));
addAll(BASE_OUTPUT_PARAMETERS);
add(new Parameter(Parameters.TOKEN, Parameter.TYPES.STRING, "Token di autorizzazione"));
}
};
public Login(String verb, String description, String... methods) {
super(verb, description, methods);
public Login(String description, String... methods) {
super(description, methods);
}
@Override

4
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Manual.java

@ -37,8 +37,8 @@ public class Manual extends Command {
private static final JSONSerializer serializer = JSONFactoryUtil.createJSONSerializer();
public Manual(String verb, String description, String... methods) {
super(verb, description, methods);
public Manual(String description, String... methods) {
super(description, methods);
}
@Override

8
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/ManualHtml.java

@ -37,8 +37,8 @@ public class ManualHtml extends Command {
private static final JSONSerializer serializer = JSONFactoryUtil.createJSONSerializer();
public ManualHtml(String verb, String description, String... methods) {
super(verb, description, methods);
public ManualHtml(String description, String... methods) {
super(description, methods);
}
@Override
@ -57,7 +57,7 @@ public class ManualHtml extends Command {
if (command.isSecure()) {
result.append(" [T]");
}
result.append("<div class=\"description\">").append(command.getDescription()).append("</div>");
result.append("<div class=\"description\">").append(command.getDescription()).append(".</div>");
result.append("<div class=\"methods\">Metodi: ")
.append(StringUtils.join(command.getMethods(), StringPool.COMMA_AND_SPACE)).append("</div>");
result.append("<div class=\"parameters\">Parametri:");
@ -90,8 +90,8 @@ public class ManualHtml extends Command {
}
result.append("</div>");
}
}
result.append("</div>");
}
result.append("<div class=\"example\">Esempio:<pre>").append(getCurlExample(command, getBaseUrl(request)))
.append("</pre></div>");
result.append("</div>"); // class="command"

11
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/Nop.java

@ -11,12 +11,17 @@ 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 {
public Nop(String verb, String description, String... methods) {
public Nop(String description, String... methods) {
super(description, methods);
}
super(verb, description, methods);
@Override
protected String getCommandName() {
return StringPool.BLANK;
}
@Override
@ -34,6 +39,6 @@ public class Nop extends Command {
@Override
public List<Parameter> getOutputParameters() {
return EMPTY_PARAMETERS;
return BASE_OUTPUT_PARAMETERS;
}
}

2
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/parameter/Parameter.java

@ -56,6 +56,6 @@ public class Parameter {
}
public static enum TYPES {
ARRAY, BOOLEAN, STRING, TEXT_HTML, TEXT_PLAIN
ARRAY, BOOLEAN, INTEGER, STRING, TEXT_HTML, TEXT_PLAIN
}
}

2
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/model/impl/SportelloImpl.java

@ -106,7 +106,7 @@ public class SportelloImpl extends SportelloBaseImpl {
return getProvincia().getProvincia();
}
private synchronized Comune getComune() throws PortalException, SystemException {
public synchronized Comune getComune() throws PortalException, SystemException {
if (Validator.isNull(comune)) {
comune = ComuneLocalServiceUtil.getComune(getComuneId());

4
liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/service.properties

@ -13,8 +13,8 @@
##
build.namespace=sicilia_sue
build.number=61
build.date=1623771128700
build.number=62
build.date=1624370773646
build.auto.upgrade=true
##

Caricamento…
Annulla
Salva