Sfoglia il codice sorgente

Sorgenti pubblici e correzione del controllo firme obbligatorie per varianti e integrazioni

master
Salvatore La Manna 4 anni fa
parent
commit
02d0ba3b4d
  1. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/.classpath
  2. 1
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/.settings/org.eclipse.wst.common.component
  3. BIN
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar
  4. 33
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ValidazionePraticaUtil.java
  5. 157
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/startup/CompanyExpandoStartupAction.java
  6. 4
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties
  7. 199
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/mwg/sismica/fe/servlet/SorgentiServlet.java
  8. 4
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/sorgenti/footer.jsp
  9. 16
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/sorgenti/form.jsp
  10. 12
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/sorgenti/header.jsp
  11. 10
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/sorgenti/invio_ko.jsp
  12. 10
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/sorgenti/invio_ok.jsp
  13. 4
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/service.properties
  14. 2
      liferay-plugins-sdk-6.2/shared/portos-bo-shared/src/it/tref/liferay/portos/bo/shared/util/Constants.java

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/.classpath

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="docroot/WEB-INF/src"/>
<classpathentry kind="src" path="docroot/WEB-INF/service"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_79">
<attributes>
<attribute name="owner.project.facets" value="java"/>

1
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/.settings/org.eclipse.wst.common.component

@ -2,6 +2,7 @@
<wb-module deploy-name="portos-bo-portlet">
<wb-resource deploy-path="/" source-path="/docroot" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/docroot/WEB-INF/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/docroot/WEB-INF/service"/>
<dependent-module archiveName="hms-taglib-hook-service.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/hms-taglib-hook/docroot/WEB-INF/lib/hms-taglib-hook-service.jar">
<dependency-type>uses</dependency-type>
</dependent-module>

BIN
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar

File binario non mostrato.

33
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ValidazionePraticaUtil.java

@ -31,7 +31,6 @@ import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil;
import it.tref.liferay.portos.bo.shared.util.Constants;
import it.tref.liferay.portos.bo.util.AsseverazioniUtil;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@ -1734,6 +1733,7 @@ public class ValidazionePraticaUtil {
}
List<String> firmeTotali = new ArrayList<>();
boolean contieneDocumenti = false;
for (String codiceDoc : tipologiaAllegati) {
if (DocumentiPraticaUtil.getDocObbligatoriDomandaPortos1().contains(codiceDoc)) {
@ -1763,6 +1763,7 @@ public class ValidazionePraticaUtil {
continue;
}
contieneDocumenti = true;
FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari());
List<String> signatures = firme.allSignatures();
GenericUtils.addAllIfnotExist(firmeTotali, signatures);
@ -1825,24 +1826,26 @@ public class ValidazionePraticaUtil {
// Ogni progettista e direttore dei lavori deve avere apposto almeno una
// firma sulla totalità degli allegati
List<Soggetto> progettisti = SoggettoLocalServiceUtil.getValidTmpByIntPratica_TipologiaSoggetto(
intPraticaId, TipoSoggettoUtil.PROGETTISTA);
for (Soggetto progettista : progettisti) {
if (progettista.getDettPraticaId() == dettPraticaId) {
if (!firmeTotali.contains(progettista.getCodiceFiscale().toLowerCase())) {
return false;
if (contieneDocumenti) {
List<Soggetto> progettisti = SoggettoLocalServiceUtil.getValidTmpByIntPratica_TipologiaSoggetto(
intPraticaId, TipoSoggettoUtil.PROGETTISTA);
for (Soggetto progettista : progettisti) {
if (progettista.getDettPraticaId() == dettPraticaId) {
if (!firmeTotali.contains(progettista.getCodiceFiscale().toLowerCase())) {
return false;
}
}
}
}
List<Soggetto> direttoriLavori = SoggettoLocalServiceUtil.getValidTmpByIntPratica_TipologiaSoggetto(
intPraticaId, TipoSoggettoUtil.DIRETTORE_LAVORI);
for (Soggetto direttore : direttoriLavori) {
if (direttore.getDettPraticaId() == dettPraticaId) {
if (!firmeTotali.contains(direttore.getCodiceFiscale().toLowerCase())) {
return false;
List<Soggetto> direttoriLavori = SoggettoLocalServiceUtil
.getValidTmpByIntPratica_TipologiaSoggetto(intPraticaId,
TipoSoggettoUtil.DIRETTORE_LAVORI);
for (Soggetto direttore : direttoriLavori) {
if (direttore.getDettPraticaId() == dettPraticaId) {
if (!firmeTotali.contains(direttore.getCodiceFiscale().toLowerCase())) {
return false;
}
}
}
}
return true;

157
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/startup/CompanyExpandoStartupAction.java

@ -1,5 +1,7 @@
package it.tref.liferay.portos.bo.startup;
import java.util.Date;
import it.tref.liferay.portos.bo.shared.util.Constants;
import com.liferay.portal.kernel.events.ActionException;
@ -26,8 +28,7 @@ import com.liferay.portlet.expando.service.ExpandoTableLocalServiceUtil;
public class CompanyExpandoStartupAction extends SimpleAction {
private static final Log _log = LogFactoryUtil
.getLog(CompanyExpandoStartupAction.class);
private static final Log _log = LogFactoryUtil.getLog(CompanyExpandoStartupAction.class);
@Override
public void run(String[] companyIds) throws ActionException {
@ -40,116 +41,92 @@ public class CompanyExpandoStartupAction extends SimpleAction {
for (String companyIdStr : companyIds) {
long companyId = Long.valueOf(companyIdStr);
initExpandoColumnCompany(companyId, defaultActions,
guestActions);
initExpandoColumnCompany(companyId, defaultActions, guestActions);
}
} catch (Exception e) {
_log.error(
"Errore nella procedura automatizzata di configurazione", e);
_log.error("Errore nella procedura automatizzata di configurazione", e);
}
}
private void initExpandoColumnCompany(long companyId,
String[] defaultActions, String[] guestActions)
private void initExpandoColumnCompany(long companyId, String[] defaultActions, String[] guestActions)
throws NumberFormatException, SystemException {
String className = Company.class.getName();
addExpandoColumnIfNotExists(companyId, className,
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_CHANGES,
ExpandoColumnConstants.STRING,
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_CHANGES_URL,
addExpandoColumnIfNotExists(companyId, className, Constants.COMPANY_CUSTOM_FIELD_VERSIONING_CHANGES,
ExpandoColumnConstants.STRING, Constants.COMPANY_CUSTOM_FIELD_VERSIONING_CHANGES_URL,
defaultActions, guestActions);
addExpandoColumnIfNotExists(companyId, className,
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS,
ExpandoColumnConstants.STRING,
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS_URL,
defaultActions, guestActions);
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS, ExpandoColumnConstants.STRING,
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS_URL, defaultActions, guestActions);
addExpandoColumnIfNotExists(companyId, className,
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS_COUNT,
ExpandoColumnConstants.STRING,
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS_COUNT_URL,
defaultActions, guestActions);
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS_COUNT, ExpandoColumnConstants.STRING,
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS_COUNT_URL, defaultActions, guestActions);
addExpandoColumnIfNotExists(companyId, className,
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_COMMIT,
ExpandoColumnConstants.STRING,
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_COMMIT_URL,
addExpandoColumnIfNotExists(companyId, className, Constants.COMPANY_CUSTOM_FIELD_VERSIONING_COMMIT,
ExpandoColumnConstants.STRING, Constants.COMPANY_CUSTOM_FIELD_VERSIONING_COMMIT_URL,
defaultActions, guestActions);
addExpandoColumnIfNotExists(
companyId,
className,
addExpandoColumnIfNotExists(companyId, className,
Constants.COMPANY_CUSTOM_FIELD_PROTOCOLLO_CODICE_INIZIALE_LABEL,
ExpandoColumnConstants.STRING,
Constants.COMPANY_CUSTOM_FIELD_PROTOCOLLO_CODICE_INIZIALE_VALUE,
defaultActions, guestActions);
Constants.COMPANY_CUSTOM_FIELD_PROTOCOLLO_CODICE_INIZIALE_VALUE, defaultActions, guestActions);
addExpandoColumnIfNotExists(
companyId,
className,
addExpandoColumnIfNotExists(companyId, className,
Constants.COMPANY_CUSTOM_FIELD_PROTOCOLLO_CODICE_SEGUENTE_LABEL,
ExpandoColumnConstants.STRING,
Constants.COMPANY_CUSTOM_FIELD_PROTOCOLLO_CODICE_SEGUENTE_VALUE,
defaultActions, guestActions);
Constants.COMPANY_CUSTOM_FIELD_PROTOCOLLO_CODICE_SEGUENTE_VALUE, defaultActions, guestActions);
addExpandoColumnIfNotExists(companyId, className,
Constants.ORG_CUSTOM_FIELD_PO, ExpandoColumnConstants.STRING,
StringPool.BLANK, defaultActions, guestActions);
addExpandoColumnIfNotExists(companyId, className, Constants.ORG_CUSTOM_FIELD_PO,
ExpandoColumnConstants.STRING, StringPool.BLANK, defaultActions, guestActions);
addExpandoColumnIfNotExists(companyId, className,
Constants.GESTIONE_PRATICA_URL_FE,
ExpandoColumnConstants.STRING, StringPool.BLANK,
defaultActions, guestActions);
addExpandoColumnIfNotExists(companyId, className, Constants.GESTIONE_PRATICA_URL_FE,
ExpandoColumnConstants.STRING, StringPool.BLANK, defaultActions, guestActions);
addExpandoColumnIfNotExists(companyId, className,
Constants.GESTIONE_PRATICA_URL_BO,
ExpandoColumnConstants.STRING, StringPool.BLANK,
defaultActions, guestActions);
addExpandoColumnIfNotExists(companyId, className, Constants.GESTIONE_PRATICA_URL_BO,
ExpandoColumnConstants.STRING, StringPool.BLANK, defaultActions, guestActions);
addExpandoColumnIfNotExists(companyId, className,
Constants.CF_ORGANIZATION_MEMBERSHIP,
ExpandoColumnConstants.STRING, StringPool.BLANK,
defaultActions, guestActions);
addExpandoColumnIfNotExists(companyId, className, Constants.CF_ORGANIZATION_MEMBERSHIP,
ExpandoColumnConstants.STRING, StringPool.BLANK, defaultActions, guestActions);
// Manifattura Web Group, mofidica per rendere la dimensione massima
// degli allegati configurabile da pannello di controllo. In origine era
// hardcoded a 20971520 byte.
addExpandoColumnIfNotExists(
companyId,
className,
addExpandoColumnIfNotExists(companyId, className,
Constants.COMPANY_CUSTOM_FIELD_DIMENSIONE_MASSIMA_ALLEGATI_IN_MIB,
ExpandoColumnConstants.SHORT,
Constants.COMPANY_CUSTOM_FIELD_DIMENSIONE_MASSIMA_ALLEGATI_DEFAULT,
defaultActions, guestActions);
Constants.COMPANY_CUSTOM_FIELD_DIMENSIONE_MASSIMA_ALLEGATI_DEFAULT, defaultActions,
guestActions);
addExpandoColumnIfNotExists(companyId, className, Constants.COMPANY_CUSTOM_FIELD_LINK_SEED,
ExpandoColumnConstants.STRING, String.valueOf(new Date().getTime()), defaultActions,
guestActions);
}
private ExpandoColumn addExpandoColumnIfNotExists(long companyId,
String className, String name, int type, String defaultData,
String[] defaultActions, String[] guestActions)
private ExpandoColumn addExpandoColumnIfNotExists(long companyId, String className, String name,
int type, String defaultData, String[] defaultActions, String[] guestActions)
throws SystemException {
long classNameId = PortalUtil.getClassNameId(className);
ExpandoTable expandoTable = null;
try {
expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId,
classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME);
expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, classNameId,
ExpandoTableConstants.DEFAULT_TABLE_NAME);
} catch (PortalException e) {
try {
expandoTable = ExpandoTableLocalServiceUtil.addTable(companyId,
classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME);
expandoTable = ExpandoTableLocalServiceUtil.addTable(companyId, classNameId,
ExpandoTableConstants.DEFAULT_TABLE_NAME);
} catch (PortalException e1) {
}
}
ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(
expandoTable.getTableId(), name);
ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil
.getColumn(expandoTable.getTableId(), name);
if (expandoColumn == null) {
@ -158,23 +135,20 @@ public class CompanyExpandoStartupAction extends SimpleAction {
// creazione di campi personalizzati di tipo intero
switch (type) {
case ExpandoColumnConstants.INTEGER:
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(
expandoTable.getTableId(), name, type,
Integer.valueOf(defaultData));
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), name,
type, Integer.valueOf(defaultData));
break;
case ExpandoColumnConstants.LONG:
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(
expandoTable.getTableId(), name, type,
Long.valueOf(defaultData));
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), name,
type, Long.valueOf(defaultData));
break;
case ExpandoColumnConstants.SHORT:
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(
expandoTable.getTableId(), name, type,
Short.valueOf(defaultData));
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), name,
type, Short.valueOf(defaultData));
break;
default:
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(
expandoTable.getTableId(), name, type, defaultData);
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), name,
type, defaultData);
}
} catch (PortalException e) {
@ -183,28 +157,19 @@ public class CompanyExpandoStartupAction extends SimpleAction {
try {
Role roleGuest = RoleLocalServiceUtil.getRole(companyId,
RoleConstants.GUEST);
Role rolePowerUser = RoleLocalServiceUtil.getRole(companyId,
RoleConstants.POWER_USER);
Role roleUser = RoleLocalServiceUtil.getRole(companyId,
RoleConstants.USER);
ResourcePermissionLocalServiceUtil.setResourcePermissions(
companyId, ExpandoColumn.class.getName(),
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(expandoColumn.getColumnId()),
roleGuest.getRoleId(), guestActions);
ResourcePermissionLocalServiceUtil.setResourcePermissions(
companyId, ExpandoColumn.class.getName(),
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(expandoColumn.getColumnId()),
rolePowerUser.getRoleId(), defaultActions);
ResourcePermissionLocalServiceUtil.setResourcePermissions(
companyId, ExpandoColumn.class.getName(),
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(expandoColumn.getColumnId()),
roleUser.getRoleId(), defaultActions);
Role roleGuest = RoleLocalServiceUtil.getRole(companyId, RoleConstants.GUEST);
Role rolePowerUser = RoleLocalServiceUtil.getRole(companyId, RoleConstants.POWER_USER);
Role roleUser = RoleLocalServiceUtil.getRole(companyId, RoleConstants.USER);
ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId,
ExpandoColumn.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(expandoColumn.getColumnId()), roleGuest.getRoleId(), guestActions);
ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId,
ExpandoColumn.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(expandoColumn.getColumnId()), rolePowerUser.getRoleId(), defaultActions);
ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId,
ExpandoColumn.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(expandoColumn.getColumnId()), roleUser.getRoleId(), defaultActions);
} catch (PortalException e) {
}

4
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=2329
build.date=1592572451837
build.number=2343
build.date=1593005074944
build.auto.upgrade=true
##

199
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/mwg/sismica/fe/servlet/SorgentiServlet.java

@ -1,27 +1,224 @@
package it.mwg.sismica.fe.servlet;
import it.tref.liferay.portos.bo.shared.util.Constants;
import it.tref.liferay.portos.mailmanager.shared.messaging.util.DestinationNames;
import it.tref.liferay.portos.mailmanager.shared.util.MailManagerConstants;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.mail.MailMessage;
import com.liferay.portal.kernel.messaging.Message;
import com.liferay.portal.kernel.messaging.MessageBusUtil;
import com.liferay.portal.kernel.util.DigesterUtil;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.Company;
import com.liferay.portal.model.Role;
import com.liferay.portal.model.RoleConstants;
import com.liferay.portal.model.User;
import com.liferay.portal.service.RoleLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.ServiceContextFactory;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.util.PortalUtil;
public class SorgentiServlet extends HttpServlet {
private static final long serialVersionUID = 5549374841236285035L;
private static final Log _log = LogFactoryUtil.getLog(SorgentiServlet.class);
private static final int validita = 3;
private static final String folder = "condivisi";
private static final String uri = "/portos-fe-portlet/sorgenti-sismica/";
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
String pathInfo = request.getPathInfo();
_log.info(pathInfo);
if (Validator.isNull(pathInfo) || pathInfo.equals("/")) {
request.getRequestDispatcher("/html/sorgenti/form.jsp").forward(request, response);
} else {
String[] parti = StringUtil.split(pathInfo, '/');
if (parti.length == 4) {
registra(request, "Scaricamento - " + parti[1] + "/" + parti[2] + "/" + parti[3]);
String path = parti[1];
File file = new File(PropsUtil.get("liferay.home") + "/" + folder + "/" + parti[3]);
if (file.exists() && !file.isDirectory() && pathValido(request, path)) {
String contentType = probeContentType(file);
response.setContentType(contentType);
response.setContentLength((int) file.length());
response.setHeader("Content-Disposition", "attachment; filename=" + file.getName());
FileUtils.copyFile(file, response.getOutputStream());
} else {
response.sendError(HttpServletResponse.SC_NOT_FOUND, request.getRequestURI());
}
} else {
response.sendError(HttpServletResponse.SC_NOT_FOUND, request.getRequestURI());
}
}
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
String pathInfo = request.getPathInfo();
if (Validator.isNotNull(pathInfo) && pathInfo.equals("/richiedi")) {
try {
if (inviaMail(request, response)) {
request.getRequestDispatcher("/html/sorgenti/invio_ok.jsp").forward(request, response);
} else {
request.getRequestDispatcher("/html/sorgenti/invio_ko.jsp").forward(request, response);
}
} catch (AddressException | PortalException | SystemException e) {
request.getRequestDispatcher("/html/sorgenti/invio_ko.jsp").forward(request, response);
e.printStackTrace();
}
} else {
response.sendError(HttpServletResponse.SC_NOT_FOUND, request.getRequestURI());
}
}
private static boolean pathValido(HttpServletRequest request, String path) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
for (int i = 0; i <= validita; i++) {
if (path.equals(getLink(request, calendar.getTime()))) {
return true;
}
calendar.add(Calendar.DAY_OF_MONTH, -1);
}
return false;
}
private static String getSeed(HttpServletRequest request) {
String seed = null;
try {
Company company = PortalUtil.getCompany(request);
seed = (String) company.getExpandoBridge().getAttribute(Constants.COMPANY_CUSTOM_FIELD_LINK_SEED,
false);
} catch (PortalException | SystemException e) {
}
return seed;
}
private static boolean inviaMail(HttpServletRequest request, HttpServletResponse response)
throws AddressException, PortalException, SystemException, IOException {
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, validita);
String nome = ParamUtil.getString(request, "nome");
String cognome = ParamUtil.getString(request, "cognome");
String email = ParamUtil.getString(request, "email");
String link = getLink(request, date);
String digest = digest(request, email);
String scadenza = new SimpleDateFormat("dd/MM/yyyy").format(calendar.getTime());
String testo = "Gentile " + nome + " " + cognome
+ ".<br/><br/>Puoi scaricare i sorgenti di Sismica Sicilia da qui:<br>";
File[] lista = new File(PropsUtil.get("liferay.home") + "/" + folder).listFiles();
Arrays.sort(lista, new Comparator<File>() {
@Override
public int compare(File f1, File f2) {
return f1.getName().compareTo(f2.getName());
}
});
for (File file : lista) {
testo += "<a href=\"" + PortalUtil.getPortalURL(request) + uri + link + "/" + digest + "/"
+ file.getName() + "\">" + file.getName() + "</a>.<br>";
}
if (lista.length > 1) {
testo += "<br>I link saranno validi";
} else {
testo += "<br>Il link sarà valido";
}
testo += " fino a tutto il giorno " + scadenza
+ ".<br><br>È possibile in ogni momento richiedere un nuovo link da questa <a href=\""
+ PortalUtil.getPortalURL(request) + uri + "\">pagina</a>.";
InternetAddress from = new InternetAddress("noreply-Sismica@lavoripubblici.sicilia.it", true);
InternetAddress[] to = { new InternetAddress(email, true) };
MailMessage mail = new MailMessage(from, "Sorgenti del portale Sismica Sicilia", testo, true);
mail.setTo(to);
ServiceContext serviceContext = ServiceContextFactory.getInstance(request);
Role role = RoleLocalServiceUtil.getRole(serviceContext.getCompanyId(), RoleConstants.ADMINISTRATOR);
User user = UserLocalServiceUtil.getRoleUsers(role.getRoleId(), 0, 1).get(0);
serviceContext.setUserId(user.getUserId());
Message message = new Message();
message.put("serviceContext", serviceContext);
message.put("mode", MailManagerConstants.MESSAGING_SEND_MODE_ASYNC);
message.setPayload(mail);
MessageBusUtil.sendMessage(DestinationNames.SEND_MAIL, message);
registra(request, "Richiesta - nome: " + nome + ", cognome: " + cognome + ", email: " + email
+ ", cartella: " + link + "/" + digest);
return true;
}
private static String getLink(HttpServletRequest request, Date date) {
return digest(request, new SimpleDateFormat("dd/MM/yyyy").format(date));
}
private static String digest(HttpServletRequest request, String text) {
return DigesterUtil.digestHex("md5", getSeed(request) + text);
}
private static void registra(HttpServletRequest request, String text) throws IOException {
FileWriter writer = new FileWriter(PropsUtil.get("liferay.home") + "/logs/sorgenti.log", true);
writer.write(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()) + " ["
+ request.getRemoteAddr() + "] " + text + "\n");
writer.close();
}
// La macchina di produzione non ha il supporto per mime, aggiriamo per i
// casi che ci interessano
private static String probeContentType(File file) {
try {
String extension = FilenameUtils.getExtension(file.getName()).toLowerCase();
switch (extension) {
case "pdf":
return "application/pdf";
case "zip":
return "application/zip";
default:
return Files.probeContentType(file.toPath());
}
} catch (IOException e) {
return "application/octet-stream";
}
}
}

4
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/sorgenti/footer.jsp

@ -1,6 +1,6 @@
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>
</html>

16
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/sorgenti/form.jsp

@ -8,22 +8,22 @@
</div>
<div class="row">
<div class="col-xs-12">
<form action="/sorgenti-sismica/richiedi" method="get">
<form action="/portos-fe-portlet/sorgenti-sismica/richiedi" method="post">
<table>
<tr>
<td>Nome</td>
<td><input required type="text" name="nome" /></label></td>
<td class="col-xs-6">Nome</td>
<td class="col-xs-6"><input required type="text" name="nome" /></label></td>
</tr>
<tr>
<td>Cognome</td>
<td><input required type="text" name="cognome" /></td>
<td class="col-xs-6">Cognome</td>
<td class="col-xs-6"><input required type="text" name="cognome" /></td>
</tr>
<tr>
<td>E-mail</td>
<td><input required type="email" name="email" /></td>
<td class="col-xs-6">E-mail</td>
<td class="col-xs-6"><input required type="email" name="email" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Invia" /></td>
<td class="col-xs-12" colspan="2"><input type="submit" value="Invia" /></td>
</tr>
</table>
</form>

12
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/sorgenti/header.jsp

@ -1,18 +1,22 @@
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.liferay.portal.kernel.util.ParamUtil" %>
<!DOCTPYE html>
<html>
<head>
<title>Sorgenti del portale Sismica Sicilia</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-6">
<img src="/portos-public-theme/images/logo-rs-testo.png" alt="Regione Siciliana" />
<img style="height: 60px" src="/portos-public-theme/images/logo-rs-testo.png" alt="Regione Siciliana" />
</div>
<div class="col-xs-6 text-right"></div>
<div class="col-xs-6 text-right">
<img style="height: 60px" src="/portos-public-theme/images/etoscana-dark-text.png" />
</div>
<hr />
</div>

10
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/sorgenti/invio_ko.jsp

@ -0,0 +1,10 @@
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/html/sorgenti/header.jsp"%>
<div class="row">
<div class="col-xs-12">
Si è verificato un errore durante l'inzio di una mail all'indirizzo
<%=ParamUtil.getString(request, "email")%><br><br>
Ti invitiamo a riprovare tra qualche minuto.
</div>
</div>
<%@ include file="/html/sorgenti/footer.jsp"%>

10
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/sorgenti/invio_ok.jsp

@ -0,0 +1,10 @@
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/html/sorgenti/header.jsp"%>
<div class="row">
<div class="col-xs-12">
È stata inviata una mail all'indirizzo
<%=ParamUtil.getString(request, "email")%>
contente l'indirizzo per scaricare i sorgenti del portale Sismica di Regione Siciliana
</div>
</div>
<%@ include file="/html/sorgenti/footer.jsp"%>

4
liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/service.properties

@ -13,8 +13,8 @@
##
build.namespace=portos_Mail
build.number=73
build.date=1573736257340
build.number=75
build.date=1592823810355
build.auto.upgrade=true
##

2
liferay-plugins-sdk-6.2/shared/portos-bo-shared/src/it/tref/liferay/portos/bo/shared/util/Constants.java

@ -91,6 +91,8 @@ public class Constants implements com.liferay.portal.kernel.util.Constants {
public static final String COMPANY_CUSTOM_FIELD_DIMENSIONE_MASSIMA_ALLEGATI_IN_MIB = "DIMENSIONE MASSIMA ALLEGATI IN MIB";
public static final String COMPANY_CUSTOM_FIELD_DIMENSIONE_MASSIMA_ALLEGATI_DEFAULT = "100";
public static final String COMPANY_CUSTOM_FIELD_LINK_SEED = "SEED PER LINK DINAMICI";
public static final int DETTPRATICA_VERSION_IMPL = 1;
public static final String COMPANY_CUSTOM_FIELD_PROTOCOLLO_CODICE_INIZIALE_LABEL = "CODICE PROTOCOLLAZIONE INZIALE";

Caricamento…
Annulla
Salva