New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aiuto AlboPOP Altopascio #253

Open
mauriziotallarico opened this Issue Mar 20, 2017 · 2 comments

Comments

Projects
None yet
1 participant
@mauriziotallarico

mauriziotallarico commented Mar 20, 2017

Ciao,
avrei bisogno di una mano per capire un problema sull'albo pretorio di Altopascio che sto provando ad importare.
URL Albo pretorio: http://159.213.69.82:8080/publishing/AP/index.do

Ho seguito i passi elencati qui : https://github.com/aborruso/albo-pop/tree/master/code/GDriveGeneric/tutorial_ita

Quindi sono riuscito ad estrarre i dati salienti con GDRIVE, ho importato lo script di @mfortini e ho generato il fedd RSS qui : https://script.google.com/macros/s/AKfycbxqnEtLmejSzkzdezdEuN5Wr-5QEIvSS75jK6xFrhww24WsuQ/exec

L'aggiornamento sia del google sheet che del RSS avviene correttamente (testato oggi con le aggiunte in Albo pretorio)

Il mio unico problema è che i link agli oggetti dell'albo non funzionano .
Ho provato varie soluzioni ma il risultato è sempre lo stesso . La prima volta che clicco su uno dei link del feed vengo ridirezionato su una pagina di errore il cui dettaglio è:

java.lang.NullPointerException
at it.saga.publishing.web.util.Util.getDocumentOutFromCollection(Util.java:34)
at it.saga.publishing.web.action.ap.DocDetailAction.execute(DocDetailAction.java:31)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
at it.saga.publishing.web.servlet.PublishingActionServlet.doGet(PublishingActionServlet.java:203)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
at it.saga.publishing.web.servlet.PublishingActionServlet.service(PublishingActionServlet.java:198)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at it.saga.publishing.web.filter.EncodingFilter.doFilter(EncodingFilter.java:26)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)

L'errore non si verifica se accedo ad un qualunque link di dettaglio dell'albo precedentemente, come se se si dovesse inizializzare qualche "ID" o "cookie". Perdonate l'ignoranza sono un novizio.

POtete aiutarmi per favore ? sono vicino alla meta ma senza link il feed è inutile.
Grazie.
CIao
Maurizio

PS: il feed è valido W3C https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fscript.google.com%2Fmacros%2Fs%2FAKfycbxqnEtLmejSzkzdezdEuN5Wr-5QEIvSS75jK6xFrhww24WsuQ%2Fexec ma ho dovuto apportare una piccola modifica allo script di @mfortini per bypassare il "replace" e la modifica della data. niente di particolare, spero di aver fatto bene ma senza tale modifica la PUBDATE veniva non valida (certo per colpa del formato della data proveniente dall'estrazione). Magari questo in un altro issue :)

@mauriziotallarico

This comment has been minimized.

Show comment
Hide comment
@mauriziotallarico

mauriziotallarico Mar 22, 2017

UPDATE: modificando lo script , sono riuscito a generare un cookie (JSESSIONID) facendo un accesso alla pagina. Attacco il cookie all'URL e .... nulla mi da lo stesso errore .
Posto il codice dello script (scusate per ora è abbastanza grezzo):

Aiutoooo !

`/**

  • A Google Apps Script to generate an RSS from a correctly formatted GDrive spreadsheet
  • @author Matteo Fortini
  • Copyright 2016 Matteo Fortini
  • This program is free software: you can redistribute it and/or modify
  • it under the terms of the GNU Lesser General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version.
  • This program is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU Lesser General Public License for more details.
  • You should have received a copy of the GNU Lesser General Public License
  • along with this program. If not, see http://www.gnu.org/licenses/.
    */

/* This script assumes to use a spreadsheet with this form:
*

    • A sheet named "clean" in which there are three columns, with a header in row 1:
    • TITLE: the title of the record
    • PUBDATE: the publication date in a format parseable by JavaScript's Date() function
    • HREF: the link to the news
    • A sheet named "meta" in which:
    • cell G1 will be used as the RSS feed title
    • cell G2 will be used as the RSS feed URL
    • cell G3 will be used as the RSS feed description
  • The ID for the spreadsheet is a code that can be extracted from GDrive URL, e.g.
  • for the URL https://docs.google.com/spreadsheets/d/1VgASeOEyGKvpvMa8yWHBWsobgQw4hUK42xtMQvlO7Po/edit
  • the ID is 1VgASeOEyGKvpvMa8yWHBWsobgQw4hUK42xtMQvlO7Po
    */

ID_SPREADSHEET="1SGoe6dTaQrn5lDoohn6Q3LlSRwDfnevHDfM1qXJ_b7U";

I_TITLE=0;
I_PUBDATE=1;
I_HREF=2;

var makeRss = function(){
var ch = XmlService.createElement('channel');
var root = XmlService.createElement('rss')
.setAttribute('version', '2.0')
.setAttribute('xmlnsatom', "http://www.w3.org/2005/Atom")
.addContent(ch);

    var title = '';
    var link = '';
    var description = '';
    var language = '';
    var atomlink = '';
    var items = {};

    var createElement = function(element, text){
            return XmlService.createElement(element).setText(text);
    };


    return {
            setTitle: function(value){ title = value; },
            setLink: function(value){ link = value; },
            setDescription: function(value){ description = value; },
            setLanguage: function(value){ language = value; },
            setAtomlink: function(value){ atomlink = value; },

            addItem: function(args){
                    args.timezone = "GMT"; 

                    var item = {
                            title: args.title,
                            link: args.link,
                            description: args.description,
                            pubDate: Utilities.formatDate(args.pubDate, args.timezone, "EEE, dd MMM yyyy HH:mm:ss Z"),
                            guid: args.guid
                    }

                    items[item.guid] = item;
            },

            toString: function(){
                    ch.addContent(XmlService.createElement("atomlink")
                                    .setAttribute('href', atomlink)
                                    .setAttribute('rel', 'self')
                                    .setAttribute('type', 'application/rss+xml')
                                    );

                    ch.addContent(createElement('title', title));
                    ch.addContent(createElement('link', link));
                    ch.addContent(createElement('description', description));
                    ch.addContent(createElement('language', language));


                    ch.addContent(XmlService.createElement("xhtmlmeta")
                                    .setAttribute('xmlnsxhtml','http://www.w3.org/1999/xhtml')
                                    .setAttribute('name','robots')
                                    .setAttribute('content','noindex')
                                    );

                    for (var i in items) {
                            ch.addContent(
                                            XmlService
                                            .createElement('item')
                                            .addContent(createElement('title', items[i].title))
                                            .addContent(createElement('link', items[i].link))
                                            .addContent(createElement('description', items[i].description))
                                            .addContent(createElement('pubDate', items[i].pubDate))
                                            .addContent(createElement('guid', items[i].guid))
                                            );
                    }

                    var document = XmlService.createDocument(root);
                    var xml = XmlService.getPrettyFormat().format(document)
                            var result = xml.replace('xmlnsatom', 'xmlns:atom')
                            .replace('<atomlink href=','<atom:link href=')
                            .replace('xhtmlmeta','xhtml:meta')
                            .replace('xmlnsxhtml','xmlns:xhtml');

                    return result;
            }
    };

};

function doGet() {
var ss = SpreadsheetApp.openById(ID_SPREADSHEET);

var metaSheet = ss.getSheetByName('meta');

var RSSFeedTitle = metaSheet.getRange('G1').getValue();
var RSSFeedURL = decodeURIComponent(metaSheet.getRange('G2').getValue().trim());
var RSSFeedDesc = metaSheet.getRange('G3').getValue();

var response = UrlFetchApp.fetch("http://159.213.69.82:8080/publishing/AP/index.do");

var cookie = response.getAllHeaders()['Set-Cookie'];
var header = {'Cookie':cookie};

var opt2 = {"headers":header};

var pagedata = UrlFetchApp.fetch("http://159.213.69.82:8080/publishing/AP/docDetail.do",opt2);

var dataSheet = ss.getSheetByName('clean');

var rss=makeRss();

rss.setTitle(RSSFeedTitle);
rss.setLink(RSSFeedURL);
rss.setDescription(RSSFeedDesc);
rss.setLanguage('it');
rss.setAtomlink(RSSFeedURL);

for (var i=2; i < 1000; i++) {
var riga=dataSheet.getRange(i,1,1,3).getValues();
var myguid=riga[0][I_HREF];
var titolo=riga[0][I_TITLE];
var pDate=riga[0][I_PUBDATE];

var tmpstr3 = myguid.slice(53,80);
var tmpstr1 = myguid.slice(0,52);
var tmpstr4 = cookie.slice(0,43);

var tmpstr2 = tmpstr1 + ';' + tmpstr4 + '?' + tmpstr3;

//http://159.213.69.82:8080/publishing/AP/errorPage.jsp;jsessionid=12AF2042EFB0F7EBB453FD172E5E8356?showDetail=true

//Logger.log('Riga ' + i + ' myguid ' + myguid);
if (myguid.length == 0) {
  break;
}

var pattern = /(\d{2})\/(\d{2})\/(\d{4})/;
//var pDateFix=pDate.replace(pattern,'$2/$1/$3')
var pDateFix=pDate;

var pubDateDate = new Date(pDateFix + " 12:00:00");    
rss.addItem({title: titolo,
             //guid:myguid,
             guid:tmpstr2,
             //link: myguid,
             link: tmpstr2,
             description: titolo,
             pubDate: pDateFix
                         });
    }

var rssStr=rss.toString();

//Logger.log(rssStr)

return ContentService.createTextOutput(rssStr).setMimeType(ContentService.MimeType.RSS);
}
`

mauriziotallarico commented Mar 22, 2017

UPDATE: modificando lo script , sono riuscito a generare un cookie (JSESSIONID) facendo un accesso alla pagina. Attacco il cookie all'URL e .... nulla mi da lo stesso errore .
Posto il codice dello script (scusate per ora è abbastanza grezzo):

Aiutoooo !

`/**

  • A Google Apps Script to generate an RSS from a correctly formatted GDrive spreadsheet
  • @author Matteo Fortini
  • Copyright 2016 Matteo Fortini
  • This program is free software: you can redistribute it and/or modify
  • it under the terms of the GNU Lesser General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version.
  • This program is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU Lesser General Public License for more details.
  • You should have received a copy of the GNU Lesser General Public License
  • along with this program. If not, see http://www.gnu.org/licenses/.
    */

/* This script assumes to use a spreadsheet with this form:
*

    • A sheet named "clean" in which there are three columns, with a header in row 1:
    • TITLE: the title of the record
    • PUBDATE: the publication date in a format parseable by JavaScript's Date() function
    • HREF: the link to the news
    • A sheet named "meta" in which:
    • cell G1 will be used as the RSS feed title
    • cell G2 will be used as the RSS feed URL
    • cell G3 will be used as the RSS feed description
  • The ID for the spreadsheet is a code that can be extracted from GDrive URL, e.g.
  • for the URL https://docs.google.com/spreadsheets/d/1VgASeOEyGKvpvMa8yWHBWsobgQw4hUK42xtMQvlO7Po/edit
  • the ID is 1VgASeOEyGKvpvMa8yWHBWsobgQw4hUK42xtMQvlO7Po
    */

ID_SPREADSHEET="1SGoe6dTaQrn5lDoohn6Q3LlSRwDfnevHDfM1qXJ_b7U";

I_TITLE=0;
I_PUBDATE=1;
I_HREF=2;

var makeRss = function(){
var ch = XmlService.createElement('channel');
var root = XmlService.createElement('rss')
.setAttribute('version', '2.0')
.setAttribute('xmlnsatom', "http://www.w3.org/2005/Atom")
.addContent(ch);

    var title = '';
    var link = '';
    var description = '';
    var language = '';
    var atomlink = '';
    var items = {};

    var createElement = function(element, text){
            return XmlService.createElement(element).setText(text);
    };


    return {
            setTitle: function(value){ title = value; },
            setLink: function(value){ link = value; },
            setDescription: function(value){ description = value; },
            setLanguage: function(value){ language = value; },
            setAtomlink: function(value){ atomlink = value; },

            addItem: function(args){
                    args.timezone = "GMT"; 

                    var item = {
                            title: args.title,
                            link: args.link,
                            description: args.description,
                            pubDate: Utilities.formatDate(args.pubDate, args.timezone, "EEE, dd MMM yyyy HH:mm:ss Z"),
                            guid: args.guid
                    }

                    items[item.guid] = item;
            },

            toString: function(){
                    ch.addContent(XmlService.createElement("atomlink")
                                    .setAttribute('href', atomlink)
                                    .setAttribute('rel', 'self')
                                    .setAttribute('type', 'application/rss+xml')
                                    );

                    ch.addContent(createElement('title', title));
                    ch.addContent(createElement('link', link));
                    ch.addContent(createElement('description', description));
                    ch.addContent(createElement('language', language));


                    ch.addContent(XmlService.createElement("xhtmlmeta")
                                    .setAttribute('xmlnsxhtml','http://www.w3.org/1999/xhtml')
                                    .setAttribute('name','robots')
                                    .setAttribute('content','noindex')
                                    );

                    for (var i in items) {
                            ch.addContent(
                                            XmlService
                                            .createElement('item')
                                            .addContent(createElement('title', items[i].title))
                                            .addContent(createElement('link', items[i].link))
                                            .addContent(createElement('description', items[i].description))
                                            .addContent(createElement('pubDate', items[i].pubDate))
                                            .addContent(createElement('guid', items[i].guid))
                                            );
                    }

                    var document = XmlService.createDocument(root);
                    var xml = XmlService.getPrettyFormat().format(document)
                            var result = xml.replace('xmlnsatom', 'xmlns:atom')
                            .replace('<atomlink href=','<atom:link href=')
                            .replace('xhtmlmeta','xhtml:meta')
                            .replace('xmlnsxhtml','xmlns:xhtml');

                    return result;
            }
    };

};

function doGet() {
var ss = SpreadsheetApp.openById(ID_SPREADSHEET);

var metaSheet = ss.getSheetByName('meta');

var RSSFeedTitle = metaSheet.getRange('G1').getValue();
var RSSFeedURL = decodeURIComponent(metaSheet.getRange('G2').getValue().trim());
var RSSFeedDesc = metaSheet.getRange('G3').getValue();

var response = UrlFetchApp.fetch("http://159.213.69.82:8080/publishing/AP/index.do");

var cookie = response.getAllHeaders()['Set-Cookie'];
var header = {'Cookie':cookie};

var opt2 = {"headers":header};

var pagedata = UrlFetchApp.fetch("http://159.213.69.82:8080/publishing/AP/docDetail.do",opt2);

var dataSheet = ss.getSheetByName('clean');

var rss=makeRss();

rss.setTitle(RSSFeedTitle);
rss.setLink(RSSFeedURL);
rss.setDescription(RSSFeedDesc);
rss.setLanguage('it');
rss.setAtomlink(RSSFeedURL);

for (var i=2; i < 1000; i++) {
var riga=dataSheet.getRange(i,1,1,3).getValues();
var myguid=riga[0][I_HREF];
var titolo=riga[0][I_TITLE];
var pDate=riga[0][I_PUBDATE];

var tmpstr3 = myguid.slice(53,80);
var tmpstr1 = myguid.slice(0,52);
var tmpstr4 = cookie.slice(0,43);

var tmpstr2 = tmpstr1 + ';' + tmpstr4 + '?' + tmpstr3;

//http://159.213.69.82:8080/publishing/AP/errorPage.jsp;jsessionid=12AF2042EFB0F7EBB453FD172E5E8356?showDetail=true

//Logger.log('Riga ' + i + ' myguid ' + myguid);
if (myguid.length == 0) {
  break;
}

var pattern = /(\d{2})\/(\d{2})\/(\d{4})/;
//var pDateFix=pDate.replace(pattern,'$2/$1/$3')
var pDateFix=pDate;

var pubDateDate = new Date(pDateFix + " 12:00:00");    
rss.addItem({title: titolo,
             //guid:myguid,
             guid:tmpstr2,
             //link: myguid,
             link: tmpstr2,
             description: titolo,
             pubDate: pDateFix
                         });
    }

var rssStr=rss.toString();

//Logger.log(rssStr)

return ContentService.createTextOutput(rssStr).setMimeType(ContentService.MimeType.RSS);
}
`

@mauriziotallarico

This comment has been minimized.

Show comment
Hide comment
@mauriziotallarico

mauriziotallarico Mar 22, 2017

Scusate lo spamming : vedo che il problema è simile a #61 .
Quindi senza una "pagina ponte" non è possibile risolvere il problema dei cookie di sessione ?
Grazie !

mauriziotallarico commented Mar 22, 2017

Scusate lo spamming : vedo che il problema è simile a #61 .
Quindi senza una "pagina ponte" non è possibile risolvere il problema dei cookie di sessione ?
Grazie !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment