Salvatore La Manna 3 anni fa
parent
commit
29fc234f95
  1. 20
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/ApiUtil.java
  2. 31
      liferay-plugins-sdk-6.2/portlets/sicilia-sue-connector-portlet/docroot/WEB-INF/src/it/mwg/sicilia/sue/api/v1/command/impl/SetFields.java

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

@ -2,11 +2,14 @@ package it.mwg.sicilia.sue.api.v1;
import it.mwg.sicilia.sue.service.ApiSettingLocalServiceUtil;
import java.io.Serializable;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Map;
import java.util.Map.Entry;
import javax.crypto.Cipher;
@ -56,4 +59,21 @@ public class ApiUtil {
String check = DigestUtils.sha256Hex(hash + secret);
return hash + StringPool.PERIOD + check;
}
@SuppressWarnings("unchecked")
public static Map<String, Serializable> getMapStringSerializable(Object object) {
if (object instanceof Map<?, ?>) {
Map<Object, Object> map = (Map<Object, Object>) object;
if (map.size() > 0) {
Entry<Object, Object> first = map.entrySet().iterator().next();
if ((first.getKey() instanceof String) && (first.getValue() instanceof Serializable)) {
return (Map<String, Serializable>) object;
}
} else {
return (Map<String, Serializable>) object;
}
}
return null;
}
}

31
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,5 +1,6 @@
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;
@ -13,11 +14,10 @@ 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.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -26,7 +26,6 @@ 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;
.portal.kernel.util.MapUtil;
public class SetFields extends Command {
@ -57,34 +56,14 @@ public class SetFields extends Command {
ServletResponseUtil.write(response, Response.get(Status.MALFORMED_REQUEST, additionalInfo));
return;
}
Object mapObj = parameters.get(Parameters.FIELDS);
if (!(mapObj instanceof Map<?, ?>)) {
additionalInfo.add("Formato del parametro " + Parameters.FIELDS + " errato");
Map<String, Serializable> 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));
return;
}
@SuppressWarnings("unchecked")
Map<Object, Object> mapMap = (Map<Object, Object>) mapObj;
if (mapMap.size() > 0) {
Entry<Object, Object> i = mapMap.entrySet().iterator().next();
System.out.println("====== " + i.getValue().getClass().getName());
if (!(i.getKey() instanceof String) || !(i.getValue() instanceof Serializable)) {
System.out.println("****** " + i.getValue().getClass().getName());
}
if (i.getValue() instanceof String) {
System.out.println("String");
}
if (i.getValue() instanceof Date) {
System.out.println("Date");
}
if (i.getValue() instanceof Long) {
System.out.println("Long");
}
System.out.println(i.getValue() + "!!!");
}
long applicationId = MapUtil.getLong(parameters, Parameters.APPLICATION_ID);
IntPratica intPratica = null;
Object obj = parameters.get(Parameters.FIELDS);
try {
intPratica = IntPraticaLocalServiceUtil.getIntPratica(applicationId);
} catch (PortalException | SystemException e) {

Caricamento…
Annulla
Salva