Commit ca123807 authored by Armand PUCCETTI's avatar Armand PUCCETTI
Browse files

bug correction

parents 3dd5cd31 781f56b8
Pipeline #19958 failed with stages
in 7 minutes and 5 seconds
......@@ -1267,6 +1267,12 @@ paths:
required: true
schema:
type: string
- name: abbrev
description: toggle abbreviated response (without content)/full response, useful for lowering response footprint
in: query
schema:
type: boolean
default: false
- $ref: '#/components/parameters/keyParam'
responses:
200:
......@@ -3001,6 +3007,12 @@ paths:
required: true
schema:
type: string
- name: abbrev
description: toggle abbreviated response (without content)/full response, useful for lowering response footprint
in: query
schema:
type: boolean
default: false
- $ref: '#/components/parameters/keyParam'
responses:
200:
......@@ -9490,6 +9502,12 @@ paths:
required: true
schema:
type: string
- name: abbrev
description: toggle abbreviated response (without content)/full response, useful for lowering response footprint
in: query
schema:
type: boolean
default: false
- $ref: '#/components/parameters/keyParam'
responses:
200:
......@@ -10860,6 +10878,12 @@ paths:
required: true
schema:
type: string
- name: abbrev
description: toggle abbreviated response (without content)/full response, useful for lowering response footprint
in: query
schema:
type: boolean
default: false
- $ref: '#/components/parameters/keyParam'
responses:
200:
......@@ -14115,6 +14139,12 @@ paths:
required: true
schema:
type: string
- name: abbrev
description: toggle abbreviated response (without messages, warnings, errors, and details properties)/full response, useful for lowering response footprint
in: query
schema:
type: boolean
default: false
- name: skip
description: number of elements to skip, useful for lowering response footprint
in: query
......@@ -14275,6 +14305,12 @@ paths:
required: true
schema:
type: string
- name: abbrev
description: toggle abbreviated response (without messages, warnings, errors, and details properties)/full response, useful for lowering response footprint
in: query
schema:
type: boolean
default: false
- $ref: '#/components/parameters/keyParam'
responses:
200:
......@@ -15195,6 +15231,12 @@ paths:
required: true
schema:
type: string
- name: abbrev
description: toggle abbreviated response (without content)/full response, useful for lowering response footprint
in: query
schema:
type: boolean
default: false
- $ref: '#/components/parameters/keyParam'
responses:
200:
......@@ -17649,6 +17691,12 @@ paths:
required: true
schema:
type: string
- name: abbrev
description: toggle abbreviated response (with only project name and members)/full response, useful for lowering response footprint
in: query
schema:
type: boolean
default: false
- $ref: '#/components/parameters/keyParam'
responses:
200:
......@@ -17715,6 +17763,12 @@ paths:
required: true
schema:
type: string
- name: abbrev
description: toggle abbreviated response (with only project name and members)/full response, useful for lowering response footprint
in: query
schema:
type: boolean
default: false
- $ref: '#/components/parameters/keyParam'
responses:
200:
......@@ -18057,6 +18111,12 @@ paths:
operationId: getProjects
description: Get all projects
parameters:
- name: abbrev
description: toggle abbreviated response (with only project name and members)/full response, useful for lowering response footprint
in: query
schema:
type: boolean
default: false
- $ref: '#/components/parameters/keyParam'
responses:
200:
......@@ -18131,6 +18191,12 @@ paths:
required: true
schema:
type: string
- name: abbrev
description: toggle abbreviated response (with only project name and members)/full response, useful for lowering response footprint
in: query
schema:
type: boolean
default: false
- $ref: '#/components/parameters/keyParam'
responses:
200:
......
......@@ -15,6 +15,9 @@
"toolID": {
"type": "string"
},
"minutesToStuck": {
"type": "integer"
},
"toolName": {
"type": "string"
},
......
......@@ -43,7 +43,7 @@ function help()
console.log("");
console.log("Examples:");
console.log("");
console.log("get_users");
console.log("get_users --user=admin");
console.log("");
console.log("Report bugs to <" + PKM.info.contact.email + ">");
console.log("");
......
......@@ -33,7 +33,8 @@ function create_all_collections(dbName)
var create_collection_promises = [];
this.get_collection_names().forEach((collection_name) =>
{
create_collection_promises.push(this.create_collection(dbName, collection_name));
const collection_info = this.get_collection_info(collection_name);
create_collection_promises.push(this.create_collection(dbName, collection_name, collection_info));
});
Promise.all(create_collection_promises).then(() =>
......
......@@ -23,11 +23,12 @@
* @instance
* @param {string} dbName - database name
* @param {string} collection_name - collection name
* @param {Object} [collection_info] - collection info
*
* @return {Promise} a promise
*/
function create_collection(dbName, collection_name)
function create_collection(dbName, collection_name, collection_info)
{
return new Promise(function(resolve, reject)
{
......@@ -55,7 +56,20 @@ function create_collection(dbName, collection_name)
{
db.createCollection(collection_name).then((collection) =>
{
resolve(collection);
if((collection_info === undefined) || (collection_info.index === undefined))
{
resolve(collection);
}
else
{
collection.createIndex(collection_info.index.key, collection_info.index.options).then(() =>
{
resolve(collection);
}).catch((err) =>
{
reject(this.Error(err));
});
}
}).catch((err) =>
{
reject(this.Error(err));
......
......@@ -16,16 +16,22 @@
* along with PKM. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* @typedef {Object} GetProjectOptions
* @property {boolean} [abbrev] - enable/disable project metadata
*/
/**
* Get a project
*
* @memberof PKM
* @instance
* @param {string} project_name - project name
* @param {GetProjectOptions} [options] - options
*
* @return {Promise.<PkmProject>} a promise
*/
function get_project(project_name)
function get_project(project_name, options = {})
{
return new Promise(function(resolve, reject)
{
......@@ -39,7 +45,7 @@ function get_project(project_name)
this.get_documents(this.config.pkm_db, 'Projects', { name : project_name }).then(() =>
{
// retrieve project informations
this.get_documents(project_name, 'Project').then((documents) =>
(options.abbrev ? Promise.resolve([ { name : project_name } ]) : this.get_documents(project_name, 'Project')).then((documents) =>
{
if(documents.length)
{
......@@ -86,35 +92,38 @@ function get_project(project_name)
{
let promises = [];
// get some project metadata from collections
let project_metadata = Object.keys(this.config.project);
project_metadata.forEach((metadata) =>
if(!options.abbrev)
{
const get = this.config.project[metadata].get;
if((typeof get === 'string') && (typeof this[get] === 'function'))
// get some project metadata from collections
let project_metadata = Object.keys(this.config.project);
project_metadata.forEach((metadata) =>
{
promises.push(new Promise((resolve, reject) =>
const get = this.config.project[metadata].get;
if((typeof get === 'string') && (typeof this[get] === 'function'))
{
this[get](project.name).then((metadata_value) =>
{
// add metadata to the project
project[metadata] = metadata_value;
resolve();
}).catch((err) =>
promises.push(new Promise((resolve, reject) =>
{
const error = require('./error');
if(err instanceof error.PKM_NotFound)
this[get](project.name).then((metadata_value) =>
{
// add metadata to the project
project[metadata] = metadata_value;
resolve();
}
else
}).catch((err) =>
{
reject(this.Error(err));
}
});
}));
}
});
const error = require('./error');
if(err instanceof error.PKM_NotFound)
{
resolve();
}
else
{
reject(this.Error(err));
}
});
}));
}
});
}
return Promise.all(promises);
}).then(() =>
......
......@@ -16,15 +16,22 @@
* along with PKM. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* @typedef {Object} GetProjectsOptions
* @property {boolean} [abbrev] - enable/disable project metadata
*/
/**
* Get projects
*
* @memberof PKM
* @instance
*
* @param {GetProjectsOptions} [options] - options
*
* @return {Promise.<Array.<PkmProject>>} a promise
*/
function get_projects()
function get_projects(options = {})
{
return new Promise(function(resolve, reject)
{
......@@ -47,7 +54,7 @@ function get_projects()
if(user.has_role(project_name) || user.is_admin())
{
// user has a role in the project or it is an administrator: retrieve the project information
this.get_project(project_name).then((project) =>
this.get_project(project_name, options).then((project) =>
{
resolve(project);
}).catch((err) =>
......
......@@ -16,23 +16,29 @@
* along with PKM. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* @typedef {Object} GetUserProjectsOptions
* @property {string} [project_name] - project name
* @property {boolean} [abbrev] - enable/disable project metadata
*/
/**
* Get user's projects
*
* @memberof PKM
* @instance
* @param {PkmUser} user - a user
* @param {string} [project_name] - project name
* @param {GetUserProjectsOptions} [options] - options
*
* @return {Promise.<Array.<PkmProject>>} a promise
*/
function get_user_projects(user, project_name)
function get_user_projects(user, options = {})
{
return new Promise(function(resolve, reject)
{
const debug = this.debug;
if(project_name === undefined)
if(options.project_name === undefined)
{
// get all user's projects
......@@ -52,10 +58,10 @@ function get_user_projects(user, project_name)
}
else
{
if(user.has_role(project_name))
if(user.has_role(options.project_name))
{
// get project
this.get_project(project_name).then((project) =>
this.get_project(options.project_name).then((project) =>
{
resolve([ project ]);
}).catch((err) =>
......
<
......@@ -406,40 +406,40 @@ class PKM
git_max_parallel_write_files : 1,
git_remote_timeout : 10 * 60 * 1000, // 10 minutes timeout for Git remote operations (clone, fetch, pull and push) to avoid blocking server on a required authentication
server_request_body_limit: '256MB', // maximum size of request body: 256MB ought to be enough for anybody
collection_names :
[
'Annotations',
'RawSourcecode',
'RawUML',
'sourcecodeC',
'sourcecodeCPP',
'sourcecodeJava',
'annotationsACSL',
'annotationsACSLPP',
'annotationsJML',
'commentsC',
'commentsCPP',
'commentsjava',
'RawDocumentation',
'Documentation',
'GraphicalDocumentation',
'UMLClasses',
'UMLStateMachines',
'TESTARStateModels',
'TESTARTestResults',
'Logs',
'TraceabilityMatrix',
'Project',
'CompileCommands',
'CVEList',
'RawBinaries',
'GitWorkingTrees',
'Tools',
'Invocations',
'TESTARSettings',
'MethodologyStatus',
'Reviews'
],
collections :
{
Annotations: { index: { key : { path : 1, access : 1 }, options : { unique : true } } },
RawSourcecode: { index: { key : { filename : 1, chunkId : 1 }, options : { unique : true } } },
RawUML: { index: { key : { filename : 1, chunkId : 1 }, options : { unique : true } } },
sourcecodeC: { index: { key : { sourceFile : 1 }, options : { unique : false } } },
sourcecodeCPP: { index: { key : { sourceFile : 1 }, options : { unique : false } } },
sourcecodeJava: { index: { key : { sourceFile : 1 }, options : { unique : true } } },
annotationsACSL: { index: { key : { sourceFile : 1 }, options : { unique : false } } },
annotationsACSLPP: { index: { key : { sourceFile : 1 }, options : { unique : false } } },
annotationsJML: { index: { key : { sourceFile : 1 }, options : { unique : true } } },
commentsC: { index: { key : { sourceFile : 1 }, options : { unique : false } } },
commentsCPP: { index: { key : { sourceFile : 1 }, options : { unique : false } } },
commentsjava: { index: { key : { sourceFile : 1 }, options : { unique : true } } },
RawDocumentation: { index: { key : { filename : 1, chunkId : 1 }, options : { unique : true } } },
Documentation: { index: { key : { name : 1 }, options : { unique : true } } },
GraphicalDocumentation: { index: { key : { 'class' : 1, 'object': 1 }, options : { unique : true } } },
UMLClasses: { index: { key : { name : 1 }, options : { unique : true } } },
UMLStateMachines: { index: { key : { name : 1 }, options : { unique : true } } },
TESTARStateModels: {},
TESTARTestResults: {},
Logs: { index: { key : { id : 1, chunkId : 1 }, options : { unique : true } } },
TraceabilityMatrix: {},
Project: { index: { key : { name : 1 }, options : { unique : true } } },
CompileCommands: { index: { key : { file : 1 }, options : { unique : true } } },
CVEList: { index: { key : { 'CVE_data_meta.ID': 1 }, options : { unique : true } } },
RawBinaries: { index: { key : { filename : 1, chunkId : 1 }, options : { unique : true } } },
GitWorkingTrees: { index: { key : { directory : 1 }, options : { unique : true } } },
Tools: { index: { key : { toolID : 1 }, options : { unique : true } } },
Invocations: { index: { key : { invocationID : 1 }, options : { unique : true } } },
TESTARSettings: {},
MethodologyStatus: { index: { key : { id : 1 }, options : { unique : true } } },
Reviews: { index: { key : { key : 1 }, options : { unique : true } } }
},
file_collection_names :
[
'RawSourcecode',
......@@ -477,6 +477,7 @@ class PKM
'tools_specs/NER.json',
'tools_specs/openjml.json',
'tools_specs/semparser.json',
'tools_specs/rawtext_semparser.json',
'tools_specs/SRLChunk.json',
'tools_specs/testar.json',
'tools_specs/TraceRecovery.json',
......@@ -864,10 +865,10 @@ class PKM
{ suffixes : [ '.jsp' ], format : 'text', mime_types : [ 'text/x-jsp' ], collection : 'RawSourcecode' },
{ suffixes : [ '.l' ], format : 'text', mime_types : [ 'text/x-lex' ], collection : 'RawSourcecode' },
{ suffixes : [ '.lua' ], format : 'text', mime_types : [ 'text/x-lua' ], collection : 'RawSourcecode' },
{ format : 'text', mime_types : [ 'text/x-matlab' ], collection : 'RawSourcecode' },
{ suffixes : [ '.ml' ], format : 'text', mime_types : [ 'text/x-ml' ], collection : 'RawSourcecode' },
{ suffixes : [ '.m3', '.i3', '.mg', '.ig' ], format : 'text', mime_types : [ 'text/x-modula' ], collection : 'RawSourcecode' },
{ suffixes : [ '.m' ], format : 'text', mime_types : [ 'text/x-objcsrc' ], collection : 'RawSourcecode' },
{ suffixes : [ '.m' ], format : 'text', mime_types : [ 'text/x-matlab' ], collection : 'RawSourcecode' },
{ suffixes : [ '.ocaml', '.mli' ], format : 'text', mime_types : [ 'text/x-ocaml' ], collection : 'RawSourcecode' },
{ suffixes : [ '.rexx' ], format : 'text', mime_types : [ 'text/x-rexx' ], collection : 'RawSourcecode' },
{ suffixes : [ '.r' ], format : 'text', mime_types : [ 'text/x-rsrc' ], collection : 'RawSourcecode' },
......@@ -884,6 +885,11 @@ class PKM
{ suffixes : [ '.v' ], format : 'text', mime_types : [ 'text/x-verilog' ], collection : 'RawSourcecode' },
{ suffixes : [ '.vhd', '.vhdl' ], format : 'text', mime_types : [ 'text/x-vhdl' ], collection : 'RawSourcecode' },
{ suffixes : [ '.y' ], format : 'text', mime_types : [ 'text/x-yacc' ], collection : 'RawSourcecode' },
{ suffixes : [ '.css' ], format : 'text', mime_types : [ 'text/css' ], collection : 'RawSourcecode' },
{ suffixes : [ '.html', '.htm', '.shtml' ], format : 'text', mime_types : [ 'text/html' ], collection : 'RawSourcecode' },
{ suffixes : [ '.jade' ], format : 'text', mime_types : [ 'text/jade' ], collection : 'RawSourcecode' },
{ suffixes : [ '.jsx' ], format : 'text', mime_types : [ 'text/jsx' ], collection : 'RawSourcecode' },
{ suffixes : [ '.less' ], format : 'text', mime_types : [ 'text/less' ], collection : 'RawSourcecode' },
// UML
{ suffixes : [ '.uml' ], format : 'text', collection : 'RawUML' },
......@@ -891,7 +897,7 @@ class PKM
// Documentation
{ suffixes : [ '.pdf' ], format : 'binary', mime_types : [ 'application/pdf' ], collection : 'RawDocumentation' },
{ suffixes : [ '.gdoc' ], format : 'binary', mime_types : [ 'application/vnd.google-apps.document' ], collection : 'RawDocumentation' },
{ suffixes : [ '.docm' ], format : 'binary', mime_types : [ 'application/vnd.ms-word.document.macroenabled.12' ], collection : 'RawDocumentation' },
{ suffixes : [ '.docm', '.dotm' ], format : 'binary', mime_types : [ 'application/vnd.ms-word.document.macroenabled.12' ], collection : 'RawDocumentation' },
{ suffixes : [ '.xps' ], format : 'binary', mime_types : [ 'application/vnd.ms-xpsdocument' ], collection : 'RawDocumentation' },
{ suffixes : [ '.odc' ], format : 'binary', mime_types : [ 'application/vnd.oasis.opendocument.chart' ], collection : 'RawDocumentation' },
{ suffixes : [ '.otc' ], format : 'binary', mime_types : [ 'application/vnd.oasis.opendocument.chart-template' ], collection : 'RawDocumentation' },
......@@ -910,14 +916,23 @@ class PKM
{ suffixes : [ '.odm' ], format : 'binary', mime_types : [ 'application/vnd.oasis.opendocument.text-master' ], collection : 'RawDocumentation' },
{ suffixes : [ '.ott' ], format : 'binary', mime_types : [ 'application/vnd.oasis.opendocument.text-template' ], collection : 'RawDocumentation' },
{ suffixes : [ '.oth' ], format : 'binary', mime_types : [ 'application/vnd.oasis.opendocument.text-web' ], collection : 'RawDocumentation' },
{ suffixes : [ '.ppt', '.pps' ], format : 'binary', mime_types : [ 'application/vnd.ms-powerpoint' ], collection : 'RawDocumentation' },
{ suffixes : [ '.ppsm' ], format : 'binary', mime_types : [ 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' ], collection : 'RawDocumentation' },
{ suffixes : [ '.pptm' ], format : 'binary', mime_types : [ 'application/vnd.ms-powerpoint.presentation.macroEnabled.12' ], collection : 'RawDocumentation' },
{ suffixes : [ '.pptx' ], format : 'binary', mime_types : [ 'application/vnd.openxmlformats-officedocument.presentationml.presentation' ], collection : 'RawDocumentation' },
{ suffixes : [ '.sldx' ], format : 'binary', mime_types : [ 'application/vnd.openxmlformats-officedocument.presentationml.slide' ], collection : 'RawDocumentation' },
{ suffixes : [ '.ppsx' ], format : 'binary', mime_types : [ 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' ], collection : 'RawDocumentation' },
{ suffixes : [ '.pot' ], format : 'binary', mime_types : [ 'application/vnd.ms-powerpoint' ], collection : 'RawDocumentation' },
{ suffixes : [ '.potm' ], format : 'binary', mime_types : [ 'application/vnd.ms-powerpoint.template.macroEnabled.12' ], collection : 'RawDocumentation' },
{ suffixes : [ '.potx' ], format : 'binary', mime_types : [ 'application/vnd.openxmlformats-officedocument.presentationml.template' ], collection : 'RawDocumentation' },
{ suffixes : [ '.xls' ], format : 'binary', mime_types : [ 'application/vnd.ms-excel' ], collection : 'RawDocumentation' },
{ suffixes : [ '.xlsx' ], format : 'binary', mime_types : [ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ], collection : 'RawDocumentation' },
{ suffixes : [ '.xltx' ], format : 'binary', mime_types : [ 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' ], collection : 'RawDocumentation' },
{ suffixes : [ '.doc', '.dot' ], format : 'binary', mime_types : [ 'application/msword' ], collection : 'RawDocumentation' },
{ suffixes : [ '.docx' ], format : 'binary', mime_types : [ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ], collection : 'RawDocumentation' },
{ suffixes : [ '.dotx' ], format : 'binary', mime_types : [ 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' ], collection : 'RawDocumentation' },
{ suffixes : [ '.wps' ], format : 'binary', mime_types : [ 'application/vnd.ms-works' ], collection : 'RawDocumentation' },
{ suffixes : [ '.thmx' ], format : 'binary', mime_types : [ 'application/vnd.ms-officetheme' ], collection : 'RawDocumentation' },
{ suffixes : [ '.3gpp' ], format : 'binary', mime_types : [ 'audio/3gpp' ], collection : 'RawDocumentation' },
{ suffixes : [ '.adp' ], format : 'binary', mime_types : [ 'audio/adpcm' ], collection : 'RawDocumentation' },
{ suffixes : [ '.amr' ], format : 'binary', mime_types : [ 'audio/amr' ], collection : 'RawDocumentation' },
......@@ -1045,12 +1060,7 @@ class PKM
{ suffixes : [ '.xwd' ], format : 'binary', mime_types : [ 'image/x-xwindowdump' ], collection : 'RawDocumentation' },
{ suffixes : [ '.appcache', '.manifest' ], format : 'text', mime_types : [ 'text/cache-manifest' ], collection : 'RawDocumentation' },
{ suffixes : [ '.ics', '.ifb' ], format : 'text', mime_types : [ 'text/calendar' ], collection : 'RawDocumentation' },
{ suffixes : [ '.css' ], format : 'text', mime_types : [ 'text/css' ], collection : 'RawDocumentation' },
{ suffixes : [ '.csv' ], format : 'text', mime_types : [ 'text/csv' ], collection : 'RawDocumentation' },
{ suffixes : [ '.html', '.htm', '.shtml' ], format : 'text', mime_types : [ 'text/html' ], collection : 'RawDocumentation' },
{ suffixes : [ '.jade' ], format : 'text', mime_types : [ 'text/jade' ], collection : 'RawDocumentation' },
{ suffixes : [ '.jsx' ], format : 'text', mime_types : [ 'text/jsx' ], collection : 'RawDocumentation' },
{ suffixes : [ '.less' ], format : 'text', mime_types : [ 'text/less' ], collection : 'RawDocumentation' },
{ suffixes : [ '.markdown', '.md', '.mdtext', '.mkd' ], format : 'text', mime_types : [ 'text/markdown', 'text/x-web-markdown' ], collection : 'RawDocumentation' },
{ suffixes : [ '.mml' ], format : 'text', mime_types : [ 'text/mathml' ], collection : 'RawDocumentation' },
{ suffixes : [ '.mdx' ], format : 'text', mime_types : [ 'text/mdx' ], collection : 'RawDocumentation' },
......@@ -1191,7 +1201,8 @@ class PKM
if(custom_config.hasOwnProperty('schemas'))
{
global_config.collection_names.forEach((collection_name) =>
const collection_names = Object.keys(global_config.collections);
collection_names.forEach((collection_name) =>
{
if(custom_config.schemas.hasOwnProperty(collection_name))
{
......@@ -1283,7 +1294,7 @@ class PKM
// configuration file is missing: create a configuration file with the built-in PKM configuration
let custom_config = deep_copy(global_config);
delete custom_config.secret;
delete custom_config.collection_names;
delete custom_config.collections;
delete custom_config.file_collection_names;
delete custom_config.roles;
const project_metadata = Object.keys(custom_config.project);
......@@ -1476,7 +1487,8 @@ class PKM
*/
static get_collection_names()
{
return PKM.global_config.collection_names;
const collection_names = Object.keys(PKM.global_config.collections);
return collection_names;
}
/** Get predefined collection names of PKM instance
......@@ -1488,6 +1500,24 @@ class PKM
return PKM.get_collection_names();
}
/** Get predefined collection info
*
* @return Array.<string>
*/
static get_collection_info(collection_name)
{
return PKM.global_config.collections[collection_name];