|
|
@ -33,156 +33,162 @@ import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
|
|
public class FirmaServlet extends HttpServlet { |
|
|
|
public class FirmaServlet extends HttpServlet { |
|
|
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L; |
|
|
|
private static final long serialVersionUID = 1L; |
|
|
|
|
|
|
|
|
|
|
|
private static final String GET_CONFIGURATION = "get-configuration"; // get
|
|
|
|
private static final String GET_CONFIGURATION = "get-configuration"; // get
|
|
|
|
private static final String GET_FILE_LIST = "get-file-list"; // post
|
|
|
|
private static final String GET_FILE_LIST = "get-file-list"; // post
|
|
|
|
private static final String GET_FILE = "get-file"; // post
|
|
|
|
private static final String GET_FILE = "get-file"; // post
|
|
|
|
private static final String GET_TYPE = "get-type"; // get
|
|
|
|
private static final String GET_TYPE = "get-type"; // get
|
|
|
|
private static final String GET_TYPE_VERBALE = "get-type-verbale"; // get
|
|
|
|
private static final String GET_TYPE_VERBALE = "get-type-verbale"; // get
|
|
|
|
private static final String LOGIN = "login"; // get
|
|
|
|
private static final String LOGIN = "login"; // get
|
|
|
|
private static final String OPEN_PRATICA = "open-pratica"; // post
|
|
|
|
private static final String OPEN_PRATICA = "open-pratica"; // post
|
|
|
|
private static final String RIFIUTA = "rifiuta"; // post
|
|
|
|
private static final String RIFIUTA = "rifiuta"; // post
|
|
|
|
private static final String SET_FILE = "set-file"; // post
|
|
|
|
private static final String SET_FILE = "set-file"; // post
|
|
|
|
private static final String VERSION = "version"; // get
|
|
|
|
private static final String VERSION = "version"; // get
|
|
|
|
private static final String GET_STILE = "get-stile"; // get
|
|
|
|
private static final String GET_STILE = "get-stile"; // get
|
|
|
|
|
|
|
|
|
|
|
|
private static final Log _log = LogFactoryUtil.getLog(FirmaServlet.class); |
|
|
|
private static final Log _log = LogFactoryUtil.getLog(FirmaServlet.class); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @see HttpServlet#HttpServlet() |
|
|
|
* @see HttpServlet#HttpServlet() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public FirmaServlet() { |
|
|
|
public FirmaServlet() { |
|
|
|
|
|
|
|
|
|
|
|
super(); |
|
|
|
super(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) |
|
|
|
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse |
|
|
|
*/ |
|
|
|
* response) |
|
|
|
@Override |
|
|
|
*/ |
|
|
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
|
|
|
@Override |
|
|
|
|
|
|
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, |
|
|
|
String pathInfo = request.getPathInfo().substring(1); |
|
|
|
IOException { |
|
|
|
String[] pathArray = StringUtil.split(pathInfo, "/"); |
|
|
|
|
|
|
|
FirmaGetUtil firmaGetUtil = new FirmaGetUtil(); |
|
|
|
String pathInfo = request.getPathInfo().substring(1); |
|
|
|
String metodo = pathArray[0]; |
|
|
|
String[] pathArray = StringUtil.split(pathInfo, "/"); |
|
|
|
Risposta<?> risposta = new Risposta<>(); |
|
|
|
FirmaGetUtil firmaGetUtil = new FirmaGetUtil(); |
|
|
|
|
|
|
|
String metodo = pathArray[0]; |
|
|
|
switch (metodo) { |
|
|
|
Risposta<?> risposta = new Risposta<>(); |
|
|
|
case GET_CONFIGURATION: |
|
|
|
|
|
|
|
risposta = firmaGetUtil.getConfiguration(); |
|
|
|
switch (metodo) { |
|
|
|
break; |
|
|
|
case GET_CONFIGURATION: |
|
|
|
|
|
|
|
risposta = firmaGetUtil.getConfiguration(); |
|
|
|
case GET_TYPE: |
|
|
|
break; |
|
|
|
risposta = firmaGetUtil.getType(); |
|
|
|
|
|
|
|
break; |
|
|
|
case GET_TYPE: |
|
|
|
|
|
|
|
risposta = firmaGetUtil.getType(); |
|
|
|
case GET_TYPE_VERBALE: |
|
|
|
break; |
|
|
|
risposta = firmaGetUtil.getTypeVerbale(); |
|
|
|
|
|
|
|
break; |
|
|
|
case GET_TYPE_VERBALE: |
|
|
|
|
|
|
|
risposta = firmaGetUtil.getTypeVerbale(); |
|
|
|
case LOGIN: |
|
|
|
break; |
|
|
|
if (pathArray.length == 2) { |
|
|
|
|
|
|
|
String codiceFiscale = pathArray[1]; |
|
|
|
case LOGIN: |
|
|
|
risposta = firmaGetUtil.loginCodiceFiscale(codiceFiscale); |
|
|
|
if (pathArray.length == 2) { |
|
|
|
} |
|
|
|
String codiceFiscale = pathArray[1]; |
|
|
|
if (pathArray.length == 3) { |
|
|
|
risposta = firmaGetUtil.loginCodiceFiscale(codiceFiscale); |
|
|
|
String nome = pathArray[1]; |
|
|
|
} |
|
|
|
String cognome = pathArray[2]; |
|
|
|
if (pathArray.length == 3) { |
|
|
|
risposta = firmaGetUtil.loginNomeCognome(nome, cognome); |
|
|
|
String nome = pathArray[1]; |
|
|
|
} |
|
|
|
String cognome = pathArray[2]; |
|
|
|
break; |
|
|
|
risposta = firmaGetUtil.loginNomeCognome(nome, cognome); |
|
|
|
|
|
|
|
} |
|
|
|
case VERSION: |
|
|
|
break; |
|
|
|
risposta = firmaGetUtil.version(); |
|
|
|
|
|
|
|
break; |
|
|
|
case VERSION: |
|
|
|
|
|
|
|
risposta = firmaGetUtil.version(); |
|
|
|
case GET_STILE: |
|
|
|
break; |
|
|
|
risposta = firmaGetUtil.getStile(); |
|
|
|
|
|
|
|
break; |
|
|
|
case GET_STILE: |
|
|
|
|
|
|
|
risposta = firmaGetUtil.getStile(); |
|
|
|
} |
|
|
|
break; |
|
|
|
JSONSerializer jsonSerializer = JSONFactoryUtil.createJSONSerializer(); |
|
|
|
|
|
|
|
jsonSerializer.exclude("*.class"); |
|
|
|
} |
|
|
|
String jsonResponse = jsonSerializer.serializeDeep(risposta); |
|
|
|
JSONSerializer jsonSerializer = JSONFactoryUtil.createJSONSerializer(); |
|
|
|
|
|
|
|
jsonSerializer.exclude("*.class"); |
|
|
|
response.setContentType("application/json; charset=UTF-8"); |
|
|
|
String jsonResponse = jsonSerializer.serializeDeep(risposta); |
|
|
|
ServletResponseUtil.write(response, jsonResponse); |
|
|
|
|
|
|
|
|
|
|
|
response.setContentType("application/json; charset=UTF-8"); |
|
|
|
} |
|
|
|
ServletResponseUtil.write(response, jsonResponse); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
} |
|
|
|
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) |
|
|
|
|
|
|
|
*/ |
|
|
|
/** |
|
|
|
@Override |
|
|
|
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse |
|
|
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
|
|
|
* response) |
|
|
|
|
|
|
|
*/ |
|
|
|
String pathInfo = request.getPathInfo().substring(1); |
|
|
|
@Override |
|
|
|
String[] pathArray = StringUtil.split(pathInfo, "/"); |
|
|
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, |
|
|
|
|
|
|
|
IOException { |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
|
|
|
|
StreamUtil.transfer(request.getInputStream(), outputStream); |
|
|
|
String pathInfo = request.getPathInfo().substring(1); |
|
|
|
String token = new String(outputStream.toByteArray(), StandardCharsets.UTF_8); |
|
|
|
String[] pathArray = StringUtil.split(pathInfo, "/"); |
|
|
|
|
|
|
|
|
|
|
|
FirmaPostUtil firmaPostUtil = new FirmaPostUtil(); |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
String metodo = pathArray[0]; |
|
|
|
StreamUtil.transfer(request.getInputStream(), outputStream); |
|
|
|
Risposta<?> risposta = new Risposta<>(); |
|
|
|
String token = new String(outputStream.toByteArray(), StandardCharsets.UTF_8); |
|
|
|
|
|
|
|
|
|
|
|
switch (metodo) { |
|
|
|
FirmaPostUtil firmaPostUtil = new FirmaPostUtil(); |
|
|
|
case GET_FILE: |
|
|
|
String metodo = pathArray[0]; |
|
|
|
if (pathArray.length == 3) { |
|
|
|
Risposta<?> risposta = new Risposta<>(); |
|
|
|
String tipo = pathArray[1]; |
|
|
|
|
|
|
|
String id = pathArray[2]; |
|
|
|
switch (metodo) { |
|
|
|
risposta = firmaPostUtil.getFile(token, tipo, id); |
|
|
|
case GET_FILE: |
|
|
|
} |
|
|
|
if (pathArray.length == 3) { |
|
|
|
break; |
|
|
|
String tipo = pathArray[1]; |
|
|
|
|
|
|
|
String id = pathArray[2]; |
|
|
|
case GET_FILE_LIST: |
|
|
|
risposta = firmaPostUtil.getFile(token, tipo, id); |
|
|
|
risposta = firmaPostUtil.getFileList(token); |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case OPEN_PRATICA: |
|
|
|
case GET_FILE_LIST: |
|
|
|
if (pathArray.length == 2) { |
|
|
|
risposta = firmaPostUtil.getFileList(token); |
|
|
|
String idFile = pathArray[1]; |
|
|
|
break; |
|
|
|
risposta = firmaPostUtil.openPratica(token, idFile); |
|
|
|
|
|
|
|
} |
|
|
|
case OPEN_PRATICA: |
|
|
|
break; |
|
|
|
if (pathArray.length == 2) { |
|
|
|
|
|
|
|
String idFile = pathArray[1]; |
|
|
|
case RIFIUTA: |
|
|
|
risposta = firmaPostUtil.openPratica(token, idFile); |
|
|
|
if (pathArray.length == 5) { |
|
|
|
} |
|
|
|
String idFile = pathArray[1]; |
|
|
|
break; |
|
|
|
String messaggio = pathArray[2]; |
|
|
|
|
|
|
|
String cambiaFase = pathArray[3]; |
|
|
|
case RIFIUTA: |
|
|
|
String assegna = pathArray[4]; |
|
|
|
if (pathArray.length == 5) { |
|
|
|
risposta = firmaPostUtil.rifiuta(token, idFile, messaggio, cambiaFase, assegna); |
|
|
|
String idFile = pathArray[1]; |
|
|
|
} |
|
|
|
String messaggio = pathArray[2]; |
|
|
|
break; |
|
|
|
String cambiaFase = pathArray[3]; |
|
|
|
|
|
|
|
String assegna = pathArray[4]; |
|
|
|
case SET_FILE: |
|
|
|
risposta = firmaPostUtil.rifiuta(token, idFile, messaggio, cambiaFase, assegna); |
|
|
|
if (pathArray.length == 3) { |
|
|
|
} |
|
|
|
String tipo = pathArray[1]; |
|
|
|
break; |
|
|
|
String idFile = pathArray[2]; |
|
|
|
|
|
|
|
JSONDeserializer<Map<String, String>> jsonDeserializer = JSONFactoryUtil.createJSONDeserializer(); |
|
|
|
case SET_FILE: |
|
|
|
Map<String, String> map = jsonDeserializer.deserialize(token); |
|
|
|
if (pathArray.length == 3) { |
|
|
|
|
|
|
|
String tipo = pathArray[1]; |
|
|
|
ServiceContext serviceContext = null; |
|
|
|
String idFile = pathArray[2]; |
|
|
|
try { |
|
|
|
JSONDeserializer<Map<String, String>> jsonDeserializer = JSONFactoryUtil |
|
|
|
serviceContext = ServiceContextFactory.getInstance(request); |
|
|
|
.createJSONDeserializer(); |
|
|
|
} catch (PortalException | SystemException e) { |
|
|
|
Map<String, String> map = jsonDeserializer.deserialize(token); |
|
|
|
_log.error(e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
ServiceContext serviceContext = null; |
|
|
|
|
|
|
|
try { |
|
|
|
risposta = firmaPostUtil.setFile(map.get("token"), map.get("file"), tipo, idFile, serviceContext); |
|
|
|
serviceContext = ServiceContextFactory.getInstance(request); |
|
|
|
} |
|
|
|
} catch (PortalException | SystemException e) { |
|
|
|
break; |
|
|
|
_log.error(e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
JSONSerializer jsonSerializer = JSONFactoryUtil.createJSONSerializer(); |
|
|
|
risposta = firmaPostUtil.setFile(map.get("token"), map.get("file"), tipo, idFile, |
|
|
|
jsonSerializer.exclude("*.class"); |
|
|
|
serviceContext); |
|
|
|
String jsonResponse = jsonSerializer.serialize(risposta); |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
response.setContentType("application/json; charset=UTF-8"); |
|
|
|
} |
|
|
|
ServletResponseUtil.write(response, jsonResponse); |
|
|
|
|
|
|
|
} |
|
|
|
JSONSerializer jsonSerializer = JSONFactoryUtil.createJSONSerializer(); |
|
|
|
|
|
|
|
jsonSerializer.exclude("*.class"); |
|
|
|
|
|
|
|
String jsonResponse = jsonSerializer.serialize(risposta); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
response.setContentType("application/json; charset=UTF-8"); |
|
|
|
|
|
|
|
ServletResponseUtil.write(response, jsonResponse); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|