Skip to content

Commit

Permalink
Merge branch 'b4.1.1' of https://github.com/TerraMA2/terrama2 into b4…
Browse files Browse the repository at this point in the history
….1.1
  • Loading branch information
juan0101 committed Aug 25, 2020
2 parents 809409c + 7ecd60e commit 195dc7e
Show file tree
Hide file tree
Showing 16 changed files with 155 additions and 132 deletions.
19 changes: 10 additions & 9 deletions install/release-install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/bash
#!/bin/bash

wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
sudo sh -c "echo 'deb https://deb.nodesource.com/node_8.x xenial main' > /etc/apt/sources.list.d/nodesource.list"
Expand All @@ -9,34 +9,35 @@ sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main'
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

sudo apt-get update
sudo apt-get install -y cmake git libquazip-dev unzip screen openssh-server doxygen supervisor locales libgsasl7 postgresql-11-postgis-2.5 postgresql-server-dev-11 nodejs python-psycopg2 gdal-bin openjdk-8-jdk
sudo apt-get install -y cmake libquazip-dev zip unzip screen openssh-server doxygen supervisor locales libgsasl7 postgresql-11-postgis-2.5 postgresql-server-dev-11 nodejs python-psycopg2 gdal-bin openjdk-8-jdk

mkdir $HOME/.ssh
ssh-keygen -t rsa -b 4096 -C "terrama2-team@dpi.inpe.br" -N "" -f $HOME/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -C "terrama2-team@dpi.inpe.br" -N "" -f $HOME/.ssh/id_rsa <<< y

mkdir terralib-installer
cd terralib-installer
if ! [ test -f "terralib-5.4.5-ubuntu-16.04_2019-12-13_15-45-5.4.5.tar.gz" ]
if [ ! -f "terralib-5.4.5-ubuntu-16.04.tar.gz" ]
then
wget -q http://www.dpi.inpe.br/jenkins-data/terrama2/3rdparty/terralib-5.4.5-ubuntu-16.04.tar.gz
fi

tar xf terralib-5.4.5-ubuntu-16.04_2019-12-13_15-45-5.4.5.tar.gz
tar xf terralib-5.4.5-ubuntu-16.04.tar.gz
./install.sh

cd ..

mkdir terrama2-deb

cd terrama2-deb

if ! [ test -f "TerraMA2-4.1.1-release-linux-x64-Ubuntu-16.04.deb" ]
if [ ! -f "TerraMA2-4.1.1-release-linux-x64-Ubuntu-16.04.deb" ]
then
wget -q http://www.dpi.inpe.br/jenkins-data/terrama2/installers/linux/final/TerraMA2-4.1.1-release-linux-x64-Ubuntu-16.04.deb
fi

sudo dpkg -i TerraMA2-4.1.1-release-linux-x64-Ubuntu-16.04.deb

if ! [ test -f "terrama2-doc-4.1.1.deb" ]
sudo apt install -y -f

if [ ! -f "terrama2-doc-4.1.1.deb" ]
then
wget -q http://www.dpi.inpe.br/jenkins-data/terrama2/installers/linux/final/terrama2-doc-4.1.1.deb
fi
Expand Down
3 changes: 0 additions & 3 deletions webapp/config/settings.json.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"basePath": "/",
"geoserverHost": "localhost",
"geoserverBasePath": "/geoserver",
"geoserverPort": 8080,
"port": 36000,
"defaultFilePathList": [
"/home/<USER>/terrama2"
Expand Down
3 changes: 1 addition & 2 deletions webapp/seeders/20190501115200-service-instance-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const view = {
module.exports = {
up: async function (queryInterface, /*Sequelize*/) {
const settings = Application.getContextConfig();
const { geoserverHost, geoserverPort, geoserverBasePath } = settings;
const db = settings.db;
const { database, host, password, username, port } = db;

Expand All @@ -41,7 +40,7 @@ module.exports = {
const metadata = {
key: 'maps_server',
service_instance_id: id,
value: `http://admin:geoserver@${geoserverHost}:${geoserverPort}${geoserverBasePath}`
value: `http://admin:geoserver@localhost:8080/geoserver`
}

return queryInterface.bulkInsert({ schema: 'terrama2', tableName: 'service_metadata' }, [metadata]);
Expand Down
4 changes: 3 additions & 1 deletion webmonitor/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var load = require('express-load');
var io = require('socket.io')();
var Application = require('./core/Application');
var cors = require('cors')
const common = require('./utils/common');

var app = express();

Expand All @@ -24,7 +25,8 @@ var webMonitorSession = session({ secret: KEY, name: "TerraMA2WebMonitor_" + (pr
var config = Application.getContextConfig();

app.locals.BASE_URL = config.webmonitor.basePath;
app.locals.ADMIN_URL = config.webadmin.protocol + config.webadmin.host + (config.webadmin.port != "" ? ":" + config.webadmin.port : "") + config.webadmin.basePath;
app.locals.ADMIN_URL = common.urlResolve(config.webadmin.public_uri, '/');
app.locals.INTERNAL_ADMIN_URL = config.webadmin.internal_uri;

// view engine setup
var customSwig = new swig.Swig({varControls: ["{[", "]}"]});
Expand Down
3 changes: 2 additions & 1 deletion webmonitor/config/Passport.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var request = require('request');
const common = require('./../utils/common');

var setupPassport = function(app) {
app.use(passport.initialize());
Expand All @@ -25,7 +26,7 @@ var setupPassport = function(app) {
},
function(username, password, done) {
var options = {
url: app.locals.ADMIN_URL + 'login/remote',
url: common.urlResolve(app.locals.INTERNAL_ADMIN_URL, '/login/remote'),
form: {
username: username,
password: password
Expand Down
9 changes: 3 additions & 6 deletions webmonitor/config/sample_instances/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"port": 36001
},
"webadmin": {
"protocol": "http://",
"basePath": "/",
"port": 36000,
"host": "127.0.0.1"
},
"ssl": false
"internal_uri": "http://127.0.0.1:36000",
"public_uri": "http://127.0.0.1:36000"
}
}
30 changes: 15 additions & 15 deletions webmonitor/controllers/CheckGridController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@
* @author Jean Souza [jean.souza@funcate.org.br]
*
* @property {object} memberHttp - 'http' module.
* @property {object} memberHttps - 'https' module.
* @property {object} memberFs - 'fs' module.
* @property {object} memberPath - 'path' module.
* @property {object} memberAdminHostInfo - WebAdmin host info.
*/
var CheckGridController = function(app) {

// 'http' module
var memberHttp = require('http');
// 'fs' module
var memberFs = require('fs');
// 'path' module
var memberPath = require('path');

var Application = require('./../core/Application');
// WebAdmin host info
var memberAdminHostInfo = Application.getContextConfig().webadmin;

var isSSL = Application.getContextConfig().ssl;

// 'http' module
var memberHttp = require('http');
// 'https' module
var memberHttps = require('https');
const common = require('./../utils/common');

/**
* Processes the request and returns a response.
Expand All @@ -33,13 +36,12 @@ var CheckGridController = function(app) {
* @inner
*/
var checkGridFile = function(request, response) {
const http = isSSL ? memberHttps : memberHttp;
var url = memberAdminHostInfo.protocol + memberAdminHostInfo.host + ":" + memberAdminHostInfo.port + memberAdminHostInfo.basePath + "check-grid?dpi=" + request.body.dpi + "&mask=" + request.body.mask + "&file=" + request.body.file;
var url = common.urlResolve(app.locals.INTERNAL_ADMIN_URL, "check-grid?dpi=" + request.body.dpi + "&mask=" + request.body.mask + "&file=" + request.body.file);

if(request.body.date !== undefined)
url += "." + request.body.date + "&date=" + request.body.date;

http.get(url, function(resp) {
memberHttp.get(url, function(resp) {
var body = '';

resp.on('data', function(chunk) {
Expand All @@ -62,7 +64,7 @@ var CheckGridController = function(app) {
});
};

/**
/**
* Processes the request and returns a response.
* @param {json} request - JSON containing the request data
* @param {json} response - JSON containing the response data
Expand All @@ -72,11 +74,9 @@ var CheckGridController = function(app) {
* @inner
*/
var checkGridFolder = function(request, response) {
const http = isSSL ? memberHttps : memberHttp;

var url = memberAdminHostInfo.protocol + memberAdminHostInfo.host + ":" + memberAdminHostInfo.port + memberAdminHostInfo.basePath + "check-grid-folder?dpi=" + request.body.dpi;
var url = common.urlResolve(app.locals.INTERNAL_ADMIN_URL, "check-grid-folder?dpi=" + request.body.dpi);

http.get(url, function(resp) {
memberHttp.get(url, function(resp) {
var body = '';

resp.on('data', function(chunk) {
Expand Down
102 changes: 46 additions & 56 deletions webmonitor/controllers/GetAttributesTableController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,16 @@
* @author Jean Souza [jean.souza@funcate.org.br]
*
* @property {object} memberHttp - 'http' module.
* * @property {object} memberHttps - 'https' module.
* @property {string} memberDescribeFeatureTypeTemplateURL - Url template for the GeoServer 'DescribeFeatureType' request.
* @property {string} memberGetFeatureTemplateURL - Url template for the GeoServer 'GetFeature' request.
* @property {string} memberGetLegendGraphicTemplateURL - Url template for the GeoServer 'GetLegendGraphic' request.
* @property {object} memberCurrentLayer - Object responsible for keeping the current layer data.
*/
var GetAttributesTableController = function(app) {

var Application = require('./../core/Application');

var isSSL = Application.getContextConfig().ssl;

// 'http' module
var memberHttp = require('http');

// 'http' module
var memberHttps = require('https');
const common = require('./../utils/common');
// Url template for the GeoServer 'DescribeFeatureType' request
var memberDescribeFeatureTypeTemplateURL = "/wms?service=WFS&version=1.0.0&request=DescribeFeatureType&outputFormat=application/json&typename={{LAYER_NAME}}";
// Url template for the GeoServer 'GetFeature' request
Expand Down Expand Up @@ -52,36 +45,35 @@ var GetAttributesTableController = function(app) {
* @inner
*/
var getValidProperties = function(layer, geoserverUri, callback) {
const http = isSSL ? memberHttps : memberHttp;

http.get(geoserverUri + memberDescribeFeatureTypeTemplateURL.replace('{{LAYER_NAME}}', layer),
function(resp) {
var body = '';
var fields = [];
common.getHttpHandler(geoserverUri).get(geoserverUri + memberDescribeFeatureTypeTemplateURL.replace('{{LAYER_NAME}}', layer), function(resp) {

resp.on('data', function(chunk) {
body += chunk;
});
var body = '';
var fields = [];

resp.on('end', function() {
try {
body = JSON.parse(body);
resp.on('data', function(chunk) {
body += chunk;
});

for(var i = 0, propertiesLength = body.featureTypes[0].properties.length; i < propertiesLength; i++) {
fields.push({
name: body.featureTypes[0].properties[i].name,
string: (body.featureTypes[0].properties[i].localType === "string" ? true : false),
dateTime: (body.featureTypes[0].properties[i].localType === "date-time" ? true : false),
date: (body.featureTypes[0].properties[i].localType === "date" ? true : false)
});
}
resp.on('end', function() {
try {
body = JSON.parse(body);

} catch(ex) {
body = {};
}
callback(fields);
});
}).on("error", function(e) {
for(var i = 0, propertiesLength = body.featureTypes[0].properties.length; i < propertiesLength; i++) {
fields.push({
name: body.featureTypes[0].properties[i].name,
string: (body.featureTypes[0].properties[i].localType === "string" ? true : false),
dateTime: (body.featureTypes[0].properties[i].localType === "date-time" ? true : false),
date: (body.featureTypes[0].properties[i].localType === "date" ? true : false)
});
}

} catch(ex) {
body = {};
}
callback(fields);
});
}).on("error", function(e) {
console.error(e.message);
callback([]);
});
Expand All @@ -98,7 +90,6 @@ var GetAttributesTableController = function(app) {
*/
var getAttributesTable = function(request, response) {
getValidProperties(request.body.layer, request.body.geoserverUri, function(fields) {
const http = isSSL ? memberHttps : memberHttp;
var properties = "";
var search = (request.body['search[value]'] !== "" ? "&cql_filter=(" : "");
var dateTimeField = null;
Expand Down Expand Up @@ -150,7 +141,7 @@ var GetAttributesTableController = function(app) {
url += "&cql_filter=(execution_date='" + request.body.analysisTime + "')";
}

http.get(url, function(resp) {
common.getHttpHandler(url).get(url, function(resp) {
var body = '';
var fields = [];

Expand Down Expand Up @@ -218,12 +209,12 @@ var GetAttributesTableController = function(app) {
}

if(
memberCurrentLayer.id !== request.body.layer ||
memberCurrentLayer.search !== request.body['search[value]'] ||
parseInt(memberCurrentLayer.numberOfFeatures) < parseInt(body.totalFeatures) ||
memberCurrentLayer.timeStart !== request.body.timeStart ||
memberCurrentLayer.timeEnd !== request.body.timeEnd ||
memberCurrentLayer.analysisTime !== request.body.analysisTime
memberCurrentLayer.id !== request.body.layer ||
memberCurrentLayer.search !== request.body['search[value]'] ||
parseInt(memberCurrentLayer.numberOfFeatures) < parseInt(body.totalFeatures) ||
memberCurrentLayer.timeStart !== request.body.timeStart ||
memberCurrentLayer.timeEnd !== request.body.timeEnd ||
memberCurrentLayer.analysisTime !== request.body.analysisTime
) {
memberCurrentLayer.id = request.body.layer;
memberCurrentLayer.numberOfFeatures = body.totalFeatures;
Expand Down Expand Up @@ -291,28 +282,27 @@ var GetAttributesTableController = function(app) {
* @inner
*/
var getLegend = function(request, response) {
const http = isSSL ? memberHttps : memberHttp;
http.get(request.query.geoserverUri + memberGetLegendGraphicTemplateURL.replace('{{LAYER_NAME}}', request.query.layer).replace('{{STYLE_NAME}}', request.query.layer+'_style'),
function(resp) {
const uri = request.query.geoserverUri;

common.getHttpHandler(uri).get(uri + memberGetLegendGraphicTemplateURL.replace('{{LAYER_NAME}}', request.query.layer).replace('{{STYLE_NAME}}', request.query.layer+'_style'), function(resp) {
if(resp.headers['content-type'].startsWith('image')) {
resp.pipe(response, {
end: true
});
} else {
common.getHttpHandler(uri).get(request.query.geoserverUri + memberGetLegendGraphicTemplateURL.replace('{{LAYER_NAME}}', request.query.layer).replace('{{STYLE_NAME}}', request.query.layer+'_style_legend'), function(resp) {
if(resp.headers['content-type'].startsWith('image')) {
resp.pipe(response, {
end: true
});
} else {
http.get(request.query.geoserverUri + memberGetLegendGraphicTemplateURL.replace('{{LAYER_NAME}}', request.query.layer).replace('{{STYLE_NAME}}', request.query.layer+'_style_legend'),
function(resp) {
if(resp.headers['content-type'].startsWith('image')) {
resp.pipe(response, {
end: true
});
} else {
console.error('Error retriving legend.');
}
}).on("error", function(e) {
console.error(e.message);
});
console.error('Error retriving legend.');
}
}).on("error", function(e) {
console.error(e.message);
});
}
}).on("error", function(e) {
console.error(e.message);
});
};
Expand Down
Loading

0 comments on commit 195dc7e

Please sign in to comment.