www in docker support
This commit is contained in:
parent
539a848e95
commit
c227fce036
2145 changed files with 399596 additions and 58 deletions
|
|
@ -0,0 +1,420 @@
|
|||
package it.acxent.newsletter.servlet.admin;
|
||||
|
||||
import it.acxent.db.ApplParmFull;
|
||||
import it.acxent.db.CRAdapter;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.db.ResParm;
|
||||
import it.acxent.newsletter.AllegatoCodaMessaggi;
|
||||
import it.acxent.newsletter.CodaMessaggi;
|
||||
import it.acxent.newsletter.CodaMessaggiCR;
|
||||
import it.acxent.newsletter.TemplateMsg;
|
||||
import it.acxent.servlet.AblServletSvlt;
|
||||
import it.acxent.util.AbMessages;
|
||||
import it.acxent.util.Vectumerator;
|
||||
import java.io.File;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet(urlPatterns = {"/admin/newsletter/CodaMessaggi.abl"})
|
||||
public class CodaMessaggiSvlt extends AblServletSvlt {
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = (CodaMessaggi)beanA;
|
||||
req.setAttribute("listaTemplateMsg", new TemplateMsg(
|
||||
getApFull(req)).findAll(bean.getFlgTipo()));
|
||||
if (bean.getId_templateMsg() > 0L)
|
||||
req.setAttribute("listaAllegatiTemplateMsg", bean.getTemplateMsg()
|
||||
.getAllegati());
|
||||
req.setAttribute("listaAllegati", bean.getAllegati());
|
||||
}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new CodaMessaggi(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new CodaMessaggiCR(getApFull(req));
|
||||
}
|
||||
|
||||
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
req.setAttribute("bean", bean);
|
||||
req.setAttribute("listaTemplateMsg", new TemplateMsg(
|
||||
getApFull(req)).findAll(bean.getFlgTipo()));
|
||||
}
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
System.out.println(getCmd(req));
|
||||
super.otherCommands(req, res);
|
||||
}
|
||||
|
||||
protected String getAttachPath(HttpServletRequest req) {
|
||||
return ((CodaMessaggi)getBean(req)).getPathImg();
|
||||
}
|
||||
|
||||
protected boolean isLoadImageServlet() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected ResParm afterImgFileSave(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = (CodaMessaggi)beanA;
|
||||
String oldImgTmst = bean.getImgTmst();
|
||||
ResParm rp = super.afterImgFileSave(bean, req, res);
|
||||
String temp = bean.getTestoMessaggio();
|
||||
long l_totImgNumber = getRequestLongParameter(req, "totImgNumber");
|
||||
if (l_totImgNumber == 0L)
|
||||
l_totImgNumber = 4L;
|
||||
for (int i = 1; (long)i <= l_totImgNumber; i++)
|
||||
temp = temp.replaceAll(bean.getImgFileName(i, oldImgTmst),
|
||||
bean.getImgFileName(i));
|
||||
bean.setTestoMessaggio(temp);
|
||||
rp.append(bean.save());
|
||||
return rp;
|
||||
}
|
||||
|
||||
protected ResParm creaFileAllegato(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
synchronized (this) {
|
||||
ResParm rp = new ResParm(true, "");
|
||||
CodaMessaggi bean = (CodaMessaggi)beanA;
|
||||
String targetDir = bean.getPathAllegato();
|
||||
File pathDir = new File(targetDir);
|
||||
if (!pathDir.exists())
|
||||
pathDir.mkdirs();
|
||||
String targetFile = targetDir + "/" + targetDir + "_";
|
||||
Vectumerator completeFileNames = (Vectumerator)
|
||||
req.getAttribute("completeAttachName");
|
||||
Vectumerator fileNames = (Vectumerator)
|
||||
req.getAttribute("attachName");
|
||||
if (completeFileNames.hasMoreElements()) {
|
||||
String sourceFile = (String)completeFileNames.nextElement();
|
||||
String fileName = (String)fileNames.elementAt(0);
|
||||
targetFile = targetFile + targetFile;
|
||||
if (isFileExist(sourceFile)) {
|
||||
new File(targetFile).delete();
|
||||
new File(sourceFile).renameTo(new File(targetFile));
|
||||
}
|
||||
}
|
||||
return rp;
|
||||
}
|
||||
}
|
||||
|
||||
public void _inviaMsg(HttpServletRequest req, HttpServletResponse res) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
ResParm rp = new ResParm(true);
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
if (bean.getDBState() == 1) {
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
CR.setId_codaMessaggiS(bean.getId_codaMessaggi());
|
||||
rp = bean.inviaMessaggiAll(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Errore!. Impossibile inviare messaggio nullo");
|
||||
}
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Invio messaggio avvenuto con successo");
|
||||
} else {
|
||||
sendMessage(req, rp.getMsg());
|
||||
}
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
protected void addRows(HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = null;
|
||||
ResParm rp = new ResParm(true, "");
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
bean = new CodaMessaggi(getApFull(req));
|
||||
try {
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
rp = bean.save();
|
||||
l_id = bean.getId_codaMessaggi();
|
||||
req.setAttribute("id_codaMessaggi", String.valueOf(l_id));
|
||||
req.setAttribute("bean", bean);
|
||||
if (rp.getStatus() == true) {
|
||||
if (getAct(req).equals("addAllegato")) {
|
||||
AllegatoCodaMessaggi row = new AllegatoCodaMessaggi(
|
||||
getApFull(req));
|
||||
fillObject(req, row);
|
||||
rp = bean.addAllegato(row);
|
||||
rp.append(creaFileAllegato(bean, req, res));
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
} else if (getAct(req).equals("delAllegato")) {
|
||||
AllegatoCodaMessaggi row = new AllegatoCodaMessaggi(
|
||||
getApFull(req));
|
||||
fillObject(req, row);
|
||||
rp = bean.delAllegato(row);
|
||||
sendMessage(req,
|
||||
|
||||
AbMessages.getMessage(getLocale(req), "SAVE_OK") + ": Allegato Cancellato");
|
||||
showBean(req, res);
|
||||
}
|
||||
} else {
|
||||
req.setAttribute("bean", bean);
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
forceMessage(req,
|
||||
AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void _inviaMsgAll(HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
fillObject(req, CR);
|
||||
ResParm rp = new ResParm(true);
|
||||
rp = bean.inviaMessaggiAll(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
if (getCmd(req).equals("inviaMsgD")) {
|
||||
showBean(req, res);
|
||||
} else {
|
||||
search(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void _delMsgInviati(HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
CR.setFlgStatoInvio(1L);
|
||||
ResParm rp = bean.cancellazioneMassiva(CR);
|
||||
forceMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _delMsgCR(HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
fillObject(req, CR);
|
||||
ResParm rp = bean.cancellazioneMassiva(CR);
|
||||
forceMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _useTemplate(HttpServletRequest req, HttpServletResponse res) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
long l_id_templateMsg = getRequestLongParameter(req, "id_templateMsg");
|
||||
TemplateMsg ts = new TemplateMsg(getApFull(req));
|
||||
ts.findByPrimaryKey(l_id_templateMsg);
|
||||
ResParm rp = bean.useTemplate(ts, true);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Template Messaggio associato correttamente.");
|
||||
} else {
|
||||
sendMessage(req, "ERRORE!. Impossibile associare template: " +
|
||||
rp.getMsg());
|
||||
}
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
req.setAttribute("lastUpdTmst", bean.getLastUpdTmst()
|
||||
.toString());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _msgInCoda(HttpServletRequest req, HttpServletResponse res) {
|
||||
if (getCmd(req).equals("inviaMsgD") || getCmd(req).equals("inviaMsg")) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
ResParm rp = new ResParm(true);
|
||||
if (getCmd(req).equals("inviaMsgD")) {
|
||||
fillObject(req, bean);
|
||||
bean.save();
|
||||
}
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
if (bean.getDBState() == 1) {
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
CR.setId_codaMessaggiS(bean.getId_codaMessaggi());
|
||||
rp = bean.inviaMessaggiAll(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Errore!. Impossibile inviare messaggio nullo");
|
||||
}
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Invio messaggio avvenuto con successo");
|
||||
} else {
|
||||
sendMessage(req, rp.getMsg());
|
||||
}
|
||||
if (getCmd(req).equals("inviaMsgD")) {
|
||||
showBean(req, res);
|
||||
} else {
|
||||
search(req, res);
|
||||
}
|
||||
} else if (getCmd(req).equals("inviaMsgAll")) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
fillObject(req, CR);
|
||||
ResParm rp = new ResParm(true);
|
||||
rp = bean.inviaMessaggiAll(CR);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Messaggi in invio.......... ");
|
||||
} else {
|
||||
sendMessage(req, rp.getMsg());
|
||||
}
|
||||
if (getCmd(req).equals("inviaMsgD")) {
|
||||
showBean(req, res);
|
||||
} else {
|
||||
search(req, res);
|
||||
}
|
||||
} else if (getCmd(req).equals("delMsgInviati")) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
CR.setFlgStatoInvio(1L);
|
||||
ResParm rp = bean.cancellazioneMassiva(CR);
|
||||
forceMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
} else if (getCmd(req).equals("delMsgCR")) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
fillObject(req, CR);
|
||||
ResParm rp = bean.cancellazioneMassiva(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
} else if (getCmd(req).equals("useTemplate")) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
long l_id_templateMsg = getRequestLongParameter(req, "id_templateMsg");
|
||||
TemplateMsg ts = new TemplateMsg(getApFull(req));
|
||||
ts.findByPrimaryKey(l_id_templateMsg);
|
||||
ResParm rp = bean.useTemplate(ts, true);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Template Messaggio associato correttamente.");
|
||||
} else {
|
||||
sendMessage(req, "ERRORE!. Impossibile associare template: " +
|
||||
rp.getMsg());
|
||||
}
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
req.setAttribute("lastUpdTmst", bean.getLastUpdTmst()
|
||||
.toString());
|
||||
showBean(req, res);
|
||||
} else if (getCmd(req).equals("detachTemplate")) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
long imgNum = getRequestLongParameter(req, "imgNum");
|
||||
if (imgNum == 0L)
|
||||
imgNum = 4L;
|
||||
ResParm rp = bean.detachTemplate((int)imgNum);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Template Messaggio disassociato correttamente.");
|
||||
} else {
|
||||
sendMessage(req, "ERRORE!. Impossibile disassociare template: " +
|
||||
rp.getMsg());
|
||||
}
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
showBean(req, res);
|
||||
} else if (getCmd(req).equals("msgInCoda")) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
ResParm rp = bean.updateStatoMessaggi(2L, 0L);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Stati aggiornati correttamente.");
|
||||
} else {
|
||||
sendMessage(req, "ERRORE!. Impossibile aggiornare stato del messaggio: " +
|
||||
|
||||
rp.getMsg());
|
||||
}
|
||||
search(req, res);
|
||||
} else {
|
||||
super.otherCommands(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void _detachTemplate(HttpServletRequest req, HttpServletResponse res) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
long imgNum = getRequestLongParameter(req, "imgNum");
|
||||
if (imgNum == 0L)
|
||||
imgNum = 4L;
|
||||
ResParm rp = bean.detachTemplate((int)imgNum);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Template Messaggio disassociato correttamente.");
|
||||
} else {
|
||||
sendMessage(req, "ERRORE!. Impossibile disassociare template: " +
|
||||
rp.getMsg());
|
||||
}
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _inviaMsgD(HttpServletRequest req, HttpServletResponse res) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
ResParm rp = new ResParm(true);
|
||||
fillObject(req, bean);
|
||||
bean.save();
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
if (bean.getDBState() == 1) {
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
CR.setId_codaMessaggiS(bean.getId_codaMessaggi());
|
||||
rp = bean.inviaMessaggiAll(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Errore!. Impossibile inviare messaggio nullo");
|
||||
}
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Invio messaggio avvenuto con successo");
|
||||
} else {
|
||||
sendMessage(req, rp.getMsg());
|
||||
}
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _addAllegato(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
CodaMessaggi bean = new CodaMessaggi(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
bean.findByPrimaryKey(l_id);
|
||||
String fileName = getRequestParameter(req, "fileNameOnServer_1");
|
||||
String targetDir = bean.getPathAllegato();
|
||||
File pathDir = new File(targetDir);
|
||||
if (!pathDir.exists())
|
||||
pathDir.mkdirs();
|
||||
String targetFile = targetDir + "/" + targetDir + "_" + bean.getId_codaMessaggi();
|
||||
String sourceFile = getPathTmpFull() + getPathTmpFull();
|
||||
if (isFileExist(sourceFile)) {
|
||||
new File(targetFile).delete();
|
||||
new File(sourceFile).renameTo(new File(targetFile));
|
||||
}
|
||||
AllegatoCodaMessaggi row = new AllegatoCodaMessaggi(apFull);
|
||||
fillObject(req, row);
|
||||
row.setNomeFile(fileName);
|
||||
ResParm rp = bean.addAllegato(row);
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _delAllegato(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
CodaMessaggi bean = new CodaMessaggi(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
bean.findByPrimaryKey(l_id);
|
||||
AllegatoCodaMessaggi row = new AllegatoCodaMessaggi(apFull);
|
||||
fillObject(req, row);
|
||||
bean.delAllegato(row);
|
||||
sendMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_OK") + ": Allegato Cancellato");
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
package it.acxent.newsletter.servlet.admin;
|
||||
|
||||
import it.acxent.db.CRAdapter;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.db.ResParm;
|
||||
import it.acxent.newsletter.CodaMessaggi;
|
||||
import it.acxent.newsletter.MailNewsletter;
|
||||
import it.acxent.newsletter.MailNewsletterCR;
|
||||
import it.acxent.newsletter.TemplateMsg;
|
||||
import it.acxent.servlet.AblServletSvlt;
|
||||
import it.acxent.util.AbMessages;
|
||||
import it.acxent.util.Vectumerator;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet(urlPatterns = {"/admin/newsletter/MailNewsletter.abl"})
|
||||
public class MailNewsletterSvlt extends AblServletSvlt {
|
||||
private static final long serialVersionUID = -7017882231079147417L;
|
||||
|
||||
public void _cancGo(HttpServletRequest req, HttpServletResponse res) {
|
||||
MailNewsletter ml = new MailNewsletter(getApFull(req));
|
||||
String indirizzi = getRequestParameter(req, "indirizzi");
|
||||
ml.delIndirizzi(indirizzi);
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter bean, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {
|
||||
req.setAttribute("listaTemplateMsg", new TemplateMsg(getApFull(req))
|
||||
.findAll(1L));
|
||||
}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new MailNewsletter(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new MailNewsletterCR(getApFull(req));
|
||||
}
|
||||
|
||||
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected boolean isSimpleServlet(HttpServletRequest req) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
protected void manageMultipartRequest(HttpServletRequest req, HttpServletResponse res) {
|
||||
int LIMIT = 148000;
|
||||
String[] fileNameTypes = {
|
||||
"txt", "xls", "ods", "mdb", "xml", "pdf", "odt", "doc", "html", "zip",
|
||||
"csv" };
|
||||
String targetDir = getPathTmpFull();
|
||||
String[] fileNameParameters = { "fileName" };
|
||||
try {
|
||||
if (manageMultipartRequestParameters(req, LIMIT, fileNameParameters, null, fileNameTypes, targetDir)) {
|
||||
processNoEncTypeRequest(req, res);
|
||||
} else {
|
||||
sendGrantMessage(req, AbMessages.getMessage(getLocale(req), "MR_FILE_ERROR"));
|
||||
search(req, res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addRows(HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
public void _delNewsletter(HttpServletRequest req, HttpServletResponse res) {
|
||||
MailNewsletter ml = new MailNewsletter(getApFull(req));
|
||||
String indirizzo = getRequestParameter(req, "ind");
|
||||
ml.delIndirizzi(indirizzo);
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _impUtenti(HttpServletRequest req, HttpServletResponse res) {
|
||||
MailNewsletter ml = new MailNewsletter(getApFull(req));
|
||||
ml.impUtenti();
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _impGo(HttpServletRequest req, HttpServletResponse res) {
|
||||
if (!MailNewsletter.threadAddMailsFromFile) {
|
||||
MailNewsletter ml = new MailNewsletter(getApFull(req));
|
||||
Vectumerator fn = (Vectumerator)
|
||||
req.getAttribute("completeAttachName");
|
||||
String fileName = (String)fn.nextElement();
|
||||
ResParm rp = ml.addIndirizzi(fileName);
|
||||
forceMessage(req, rp.getMsg());
|
||||
} else {
|
||||
forceMessage(req, "ATTENZIONE!! Thread inserimento indirizzi ancora in esecuzione!!!");
|
||||
}
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _creaCodaMail(HttpServletRequest req, HttpServletResponse res) {
|
||||
MailNewsletter ml = new MailNewsletter(getApFull(req));
|
||||
MailNewsletterCR CR = new MailNewsletterCR(getApFull(req));
|
||||
fillObject(req, CR);
|
||||
ResParm rp = new CodaMessaggi(getApFull(req)).creaCodaMessaggi(CR,
|
||||
getRequestLongParameter(req, "id_templateMsg"));
|
||||
forceMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
package it.acxent.newsletter.servlet.admin;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import it.acxent.common.JsonUploadFileResponse;
|
||||
import it.acxent.common.Users;
|
||||
import it.acxent.db.ApplParmFull;
|
||||
import it.acxent.db.CRAdapter;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.jsp.Ab;
|
||||
import it.acxent.newsletter.NoMlist;
|
||||
import it.acxent.newsletter.NoMlistCR;
|
||||
import it.acxent.servlet.AblServletSvlt;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet(urlPatterns = {"/admin/newsletter//NoMlist.abl"})
|
||||
public class NoMlistSvlt extends AblServletSvlt {
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new NoMlist(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new NoMlistCR(getApFull(req));
|
||||
}
|
||||
|
||||
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
super.otherCommands(req, res);
|
||||
}
|
||||
|
||||
public void _saveFile(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Users utente = new Users(apFull);
|
||||
long l_id_users = getLoginUserId(req);
|
||||
utente.findByPrimaryKey(l_id_users);
|
||||
if (utente.getId_users() > 0L) {
|
||||
HashMap<String, String> uploadedImages = (HashMap<String, String>)req.getAttribute("_UFN");
|
||||
String currentFullFileName = "", currentFileName = "";
|
||||
if (!uploadedImages.isEmpty()) {
|
||||
Iterator<Map.Entry<String, String>> iterator = uploadedImages.entrySet().iterator();
|
||||
if (iterator.hasNext()) {
|
||||
Map.Entry<String, String> entry = iterator.next();
|
||||
currentFullFileName = entry.getValue();
|
||||
currentFileName = entry.getKey();
|
||||
}
|
||||
}
|
||||
if (!currentFullFileName.isEmpty())
|
||||
synchronized (this) {
|
||||
String targetDir = getPathTmpFull();
|
||||
String newFileName = "" + utente.getId_users() + "_" + utente.getId_users() + "_" + getTimeNameForFileUpload();
|
||||
File cfn = new File(currentFullFileName);
|
||||
File newFile = new File(targetDir + targetDir);
|
||||
cfn.renameTo(newFile);
|
||||
cfn = null;
|
||||
newFile = null;
|
||||
Gson gson = new Gson();
|
||||
if (newFileName.endsWith(".txt")) {
|
||||
String fileElaborato = new NoMlist(apFull).elaboraEPulisci(targetDir + targetDir);
|
||||
String fileElaboratoName = fileElaborato.replace(targetDir, "");
|
||||
sendHtmlMsgResponse(req, res, "[" +
|
||||
gson.toJson(new JsonUploadFileResponse(true,
|
||||
Ab.formatBeanMsg("File " + currentFileName + " Elaborato correttamente", ""), fileElaboratoName, "../../" +
|
||||
|
||||
getPathImg(req) + fileElaboratoName)) + "]");
|
||||
} else {
|
||||
sendHtmlMsgResponse(req, res, "[" +
|
||||
|
||||
gson.toJson(new JsonUploadFileResponse(true,
|
||||
Ab.formatBeanMsg("Mandami un txt bischero", ""), "", "to")) + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void search(HttpServletRequest req, HttpServletResponse res) {
|
||||
callJsp(req, res);
|
||||
}
|
||||
|
||||
public void _elaboraMlist(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
long id_clifor = getRequestLongParameter(req, "id_clifor");
|
||||
if (id_clifor == 0L)
|
||||
sendMessage(req, "ERRORE! Cliente non impostato");
|
||||
search(req, res);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,205 @@
|
|||
package it.acxent.newsletter.servlet.admin;
|
||||
|
||||
import it.acxent.db.ApplParmFull;
|
||||
import it.acxent.db.CRAdapter;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.db.ResParm;
|
||||
import it.acxent.newsletter.AllegatoTemplateMsg;
|
||||
import it.acxent.newsletter.CodaMessaggi;
|
||||
import it.acxent.newsletter.TemplateMsg;
|
||||
import it.acxent.newsletter.TemplateMsgCR;
|
||||
import it.acxent.servlet.AblServletSvlt;
|
||||
import it.acxent.util.AbMessages;
|
||||
import it.acxent.util.Vectumerator;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet(urlPatterns = {"/admin/newsletter/TemplateMsg.abl"})
|
||||
public class TemplateMsgSvlt extends AblServletSvlt {
|
||||
protected void addRows(HttpServletRequest req, HttpServletResponse res) {
|
||||
TemplateMsg bean = null;
|
||||
ResParm rp = new ResParm(true, "");
|
||||
long l_id = getRequestLongParameter(req, "id_templateMsg");
|
||||
bean = new TemplateMsg(getApFull(req));
|
||||
try {
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
rp = bean.save();
|
||||
l_id = bean.getId_templateMsg();
|
||||
req.setAttribute("id_templateMsg", String.valueOf(l_id));
|
||||
req.setAttribute("bean", bean);
|
||||
if (rp.getStatus() == true) {
|
||||
if (getAct(req).equals("addAllegato")) {
|
||||
AllegatoTemplateMsg row = new AllegatoTemplateMsg(getApFull(req));
|
||||
fillObject(req, row);
|
||||
rp = bean.addAllegato(row);
|
||||
rp.append(creaFileAllegato(bean, req, res));
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
} else if (getAct(req).equals("delAllegato")) {
|
||||
AllegatoTemplateMsg row = new AllegatoTemplateMsg(getApFull(req));
|
||||
fillObject(req, row);
|
||||
rp = bean.delAllegato(row);
|
||||
sendMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_OK") + ": Allegato Cancellato");
|
||||
showBean(req, res);
|
||||
}
|
||||
} else {
|
||||
req.setAttribute("bean", bean);
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
TemplateMsg bean = (TemplateMsg)beanA;
|
||||
req.setAttribute("listaAllegati", bean.getAllegati());
|
||||
}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new TemplateMsg(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new TemplateMsgCR(getApFull(req));
|
||||
}
|
||||
|
||||
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {
|
||||
TemplateMsg bean = new TemplateMsg(getApFull(req));
|
||||
bean.setFlgTipo(1L);
|
||||
req.setAttribute("bean", bean);
|
||||
}
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
super.otherCommands(req, res);
|
||||
}
|
||||
|
||||
protected boolean isLoadImageServlet() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected String getAttachPath(HttpServletRequest req) {
|
||||
return ((TemplateMsg)getBean(req)).getPathImg();
|
||||
}
|
||||
|
||||
protected ResParm afterImgFileSave(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
TemplateMsg bean = (TemplateMsg)beanA;
|
||||
String oldImgTmst = bean.getImgTmst();
|
||||
ResParm rp = super.afterImgFileSave(bean, req, res);
|
||||
String temp = bean.getTestoMessaggio();
|
||||
long l_totImgNumber = getRequestLongParameter(req, "totImgNumber");
|
||||
if (l_totImgNumber == 0L)
|
||||
l_totImgNumber = 4L;
|
||||
for (int i = 1; (long)i <= l_totImgNumber; i++)
|
||||
temp = temp.replaceAll(bean.getImgFileName(i, oldImgTmst), bean.getImgFileName(i));
|
||||
bean.setTestoMessaggio(temp);
|
||||
rp.append(bean.save());
|
||||
return rp;
|
||||
}
|
||||
|
||||
public void _creaCodaMsg(HttpServletRequest req, HttpServletResponse res) {
|
||||
long l_id_templateMsg = getRequestLongParameter(req, "id_templateMsg");
|
||||
TemplateMsg ts = new TemplateMsg(getApFull(req));
|
||||
ts.findByPrimaryKey(l_id_templateMsg);
|
||||
String targetDir = getPathTmpFull();
|
||||
String targetFile = targetDir + "creaCodaMsg_" + targetDir + "_" + getTimeNameForFileUpload() + ".txt";
|
||||
HashMap<String, String> uploadedFiles = (HashMap<String, String>)req.getAttribute("_UFN");
|
||||
if (!uploadedFiles.isEmpty()) {
|
||||
Iterator<Map.Entry<String, String>> iterator = uploadedFiles.entrySet().iterator();
|
||||
if (iterator.hasNext()) {
|
||||
Map.Entry<String, String> entry = iterator.next();
|
||||
String sourceFile = entry.getValue();
|
||||
if (isFileExist(sourceFile)) {
|
||||
new File(targetFile).delete();
|
||||
new File(sourceFile).renameTo(new File(targetFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
CodaMessaggi cm = new CodaMessaggi(getApFull(req));
|
||||
ResParm rp = cm.creaCodaMessaggi(ts, targetFile);
|
||||
forceMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
protected ResParm creaFileAllegato(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
synchronized (this) {
|
||||
ResParm rp = new ResParm(true, "");
|
||||
TemplateMsg bean = (TemplateMsg)beanA;
|
||||
String targetDir = bean.getPathAllegato();
|
||||
File pathDir = new File(targetDir);
|
||||
if (!pathDir.exists())
|
||||
pathDir.mkdirs();
|
||||
String targetFile = targetDir + "/" + targetDir + "_";
|
||||
Vectumerator completeFileNames = (Vectumerator)req.getAttribute("completeAttachName");
|
||||
Vectumerator fileNames = (Vectumerator)req.getAttribute("attachName");
|
||||
if (completeFileNames.hasMoreElements()) {
|
||||
String sourceFile = (String)completeFileNames.nextElement();
|
||||
String fileName = (String)fileNames.elementAt(0);
|
||||
targetFile = targetFile + targetFile;
|
||||
if (isFileExist(sourceFile)) {
|
||||
new File(targetFile).delete();
|
||||
new File(sourceFile).renameTo(new File(targetFile));
|
||||
}
|
||||
}
|
||||
return rp;
|
||||
}
|
||||
}
|
||||
|
||||
public void _addAllegato(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
TemplateMsg bean = new TemplateMsg(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_templateMsg");
|
||||
bean.findByPrimaryKey(l_id);
|
||||
String fileName = getRequestParameter(req, "fileNameOnServer_1");
|
||||
String targetDir = bean.getPathAllegato();
|
||||
File pathDir = new File(targetDir);
|
||||
if (!pathDir.exists())
|
||||
pathDir.mkdirs();
|
||||
String targetFile = targetDir + "/" + targetDir + "_" + bean.getId_templateMsg();
|
||||
String sourceFile = getPathTmpFull() + getPathTmpFull();
|
||||
if (isFileExist(sourceFile)) {
|
||||
new File(targetFile).delete();
|
||||
new File(sourceFile).renameTo(new File(targetFile));
|
||||
}
|
||||
AllegatoTemplateMsg row = new AllegatoTemplateMsg(apFull);
|
||||
fillObject(req, row);
|
||||
row.setNomeFile(fileName);
|
||||
ResParm rp = bean.addAllegato(row);
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _delAllegato(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
TemplateMsg bean = new TemplateMsg(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_templateMsg");
|
||||
bean.findByPrimaryKey(l_id);
|
||||
AllegatoTemplateMsg row = new AllegatoTemplateMsg(apFull);
|
||||
fillObject(req, row);
|
||||
bean.delAllegato(row);
|
||||
sendMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_OK") + ": Allegato Cancellato");
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _creaCodaMsgLte(HttpServletRequest req, HttpServletResponse res) {
|
||||
long l_id_templateMsg = getRequestLongParameter(req, "id_templateMsg");
|
||||
TemplateMsg ts = new TemplateMsg(getApFull(req));
|
||||
ts.findByPrimaryKey(l_id_templateMsg);
|
||||
String fileName = getRequestParameter(req, "fileNameOnServer_99");
|
||||
String fullMlFIle = getPathTmpFull() + getPathTmpFull();
|
||||
CodaMessaggi cm = new CodaMessaggi(getApFull(req));
|
||||
ResParm rp = cm.creaCodaMessaggi(ts, fullMlFIle);
|
||||
forceMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue