diff --git a/deposit/depositResult.component.ts b/deposit/depositResult.component.ts index 26523c00..2b8c40a7 100644 --- a/deposit/depositResult.component.ts +++ b/deposit/depositResult.component.ts @@ -380,6 +380,7 @@ export class DepositResultComponent { }, err => { //console.log(err) + this.handleError("Error getting organization name and url for id: "+this.organizationId, err); this.fetchDataproviders.searchUtils.status = this.errorCodes.NONE; if(err.status == '404') { @@ -433,4 +434,8 @@ export class DepositResultComponent { private updateUrl(url:string){ this._meta.updateTag({content:url},"property='og:url'"); } + + private handleError(message: string, error) { + console.error("Deposit Result Page: "+message, error); + } } diff --git a/landingPages/dataProvider/dataProvider.component.ts b/landingPages/dataProvider/dataProvider.component.ts index 54e91a79..a49e11a4 100644 --- a/landingPages/dataProvider/dataProvider.component.ts +++ b/landingPages/dataProvider/dataProvider.component.ts @@ -140,8 +140,6 @@ export class DataProviderComponent { this.datasourceId = data['datasourceId']; if(this.datasourceId){ this.getDataProviderInfo(this.datasourceId); - }else{ - // console.info("Content Provider id not found"); } if (typeof document !== 'undefined') { @@ -198,8 +196,8 @@ export class DataProviderComponent { } }, err => { - console.log(err); - // console.info("error"); + //console.log(err); + this.handleError("Error getting content provider for id: "+this.datasourceId, err); this.errorMessage = 'No dataProvider found'; this.showLoading = false; } @@ -213,7 +211,8 @@ export class DataProviderComponent { this.dataProviderInfo.aggregationStatus = data; }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting content provider aggregation status for id: "+this.datasourceId, err); } ); } @@ -497,4 +496,8 @@ export class DataProviderComponent { this.totalDownloads = $event.totalDownloads; this.pageViews = $event.pageViews; } + + private handleError(message: string, error) { + console.error("Content Provider Landing Page: "+message, error); + } } diff --git a/landingPages/dataset/dataset.component.ts b/landingPages/dataset/dataset.component.ts index 2d13da85..b2ff9ecf 100644 --- a/landingPages/dataset/dataset.component.ts +++ b/landingPages/dataset/dataset.component.ts @@ -152,7 +152,8 @@ export class DatasetComponent { this.showLoading = false; }, err => { - console.log(err) + //console.log(err) + this.handleError("Error getting research data for id: "+this.datasetId, err); this.errorMessage = 'No research data found'; this.showLoading = false; @@ -195,4 +196,8 @@ export class DatasetComponent { public getKeys( map) { return Array.from(map.keys()); } + + private handleError(message: string, error) { + console.error("Research Data Landing Page: "+message, error); + } } diff --git a/landingPages/htmlProjectReport/htmlProjectReport.component.ts b/landingPages/htmlProjectReport/htmlProjectReport.component.ts index 2211b660..7f284fce 100644 --- a/landingPages/htmlProjectReport/htmlProjectReport.component.ts +++ b/landingPages/htmlProjectReport/htmlProjectReport.component.ts @@ -153,7 +153,8 @@ export class HtmlProjectReportComponent{ } }, err => { - console.log(err); + this.handleError("Error getting html information for project id: "+this.projectId, err); + //console.log(err); this.createClipboard(); } ); @@ -202,7 +203,9 @@ export class HtmlProjectReportComponent{ this.showLoading = false; }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting html for id: "+this.projectId, err); + this.errorMessage = 'Service not available'; this.showLoading = false; } @@ -268,4 +271,8 @@ export class HtmlProjectReportComponent{ private updateUrl(url:string){ this._meta.updateTag({content:url},"property='og:url'"); } + + private handleError(message: string, error) { + console.error("Html Project Report Page: "+message, error); + } } diff --git a/landingPages/organization/organization.component.ts b/landingPages/organization/organization.component.ts index 8cbe0da1..070d7013 100644 --- a/landingPages/organization/organization.component.ts +++ b/landingPages/organization/organization.component.ts @@ -232,7 +232,8 @@ export class OrganizationComponent { } }, err => { - console.log(err) + //console.log(err) + this.handleError("Error getting organization for id: "+this.organizationId, err); this.errorMessage = 'No organization found'; this.showLoading = false; @@ -339,11 +340,14 @@ export class OrganizationComponent { } }, err => { - console.log("Error downloading the file."); + //console.log("Error downloading the file."); + this.handleError("Error downloading file: "+filename+".csv", err); + this.closeLoading(); this.confirmOpenCsvError(); - });/*, - () => console.log('Completed file download.'));*/ + }/*, + () => console.log('Completed file download.')*/ + ); } private downloadPublicationsFile(funder: string, funderId:string, count:number){ @@ -373,7 +377,6 @@ export class OrganizationComponent { if(!title) { //url = this.downloadURLAPI+"projects/"+projects[index].id+"?type=publications&format=csv-special";//&size="+data; url = this.downloadURLAPI+"?format=csv-special&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact '"+projects[index].id+"'))" - //console.info(url); } else { //url = this.downloadURLAPI+"projects/"+projects[index].id+"/publications?format=csv-special-notitle";//&size="+data; url = this.downloadURLAPI+"?format=csv-special-notitle&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact '"+projects[index].id+"'))" @@ -439,7 +442,9 @@ export class OrganizationComponent { } }, err => { - console.log("Error downloading the file."); + //console.log("Error downloading the file."); + this.handleError("Error downloading file: "+filename, err); + this.closeLoading(); this.confirmOpenCsvError(); }/*, @@ -447,12 +452,17 @@ export class OrganizationComponent { ); } }, - err => console.log("Error getting number of publications for project.")); + err => { + //console.log("Error getting number of publications for project.") + this.handleError("Error getting number of publications for project with id: "+projects[index].id, err); + }); }//); }, - err => { - console.log("Error getting projects project."); + err => { + //console.log("Error getting projects project."); + this.handleError("Error getting projects for organization with id: "+this.organizationId, err); + this.closeLoading(); this.confirmOpenCsvError(); } @@ -553,4 +563,8 @@ export class OrganizationComponent { encodeURI(input: string): string { return StringUtils.URIEncode(input); } + + private handleError(message: string, error) { + console.error("Organizaton Landing Page: "+message, error); + } } diff --git a/landingPages/orp/orp.component.ts b/landingPages/orp/orp.component.ts index 73fd8ae5..f6aead56 100644 --- a/landingPages/orp/orp.component.ts +++ b/landingPages/orp/orp.component.ts @@ -142,7 +142,8 @@ export class OrpComponent { this.showLoading = false; }, err => { - console.log(err) + //console.log(err) + this.handleError("Error getting other research product for id: "+this.orpId, err); this.errorMessage = 'No research product found'; this.showLoading = false; @@ -181,4 +182,8 @@ export class OrpComponent { public getKeys( map) { return Array.from(map.keys()); } + + private handleError(message: string, error) { + console.error("Other Research Product Landing Page: "+message, error); + } } diff --git a/landingPages/project/project.component.ts b/landingPages/project/project.component.ts index d4d8cb7f..56c9fdec 100644 --- a/landingPages/project/project.component.ts +++ b/landingPages/project/project.component.ts @@ -318,7 +318,9 @@ actionsAfterLoadId(){ this.actionsAfterGettingProjectInfo(); }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting project for id: "+this.projectId, err); + this.errorMessage = 'No project found'; this.showLoading = false; } @@ -341,9 +343,11 @@ actionsAfterLoadId(){ this.actionsAfterLoadId(); }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting project for grant id: "+grantId+" and funder: "+funder, err); + this.errorMessage = 'No project found'; - this.showLoading = false; + this.showLoading = false; } ); } @@ -395,7 +399,9 @@ actionsAfterGettingProjectInfo(){ } }, error => { - console.log("Error downloading the file."); + //console.log("Error downloading the file."); + this.handleError("Error downloading file: "+filename, error); + this.closeLoading(); this.confirmOpenCsvError(); }/*, @@ -484,4 +490,8 @@ actionsAfterGettingProjectInfo(){ this.alertCsvError.okButtonText = "OK"; this.alertCsvError.open(); } + + private handleError(message: string, error) { + console.error("Project Landing Page: "+message, error); + } } diff --git a/landingPages/publication/publication.component.ts b/landingPages/publication/publication.component.ts index af0ff6f1..1825a729 100644 --- a/landingPages/publication/publication.component.ts +++ b/landingPages/publication/publication.component.ts @@ -135,7 +135,8 @@ export class PublicationComponent { this.publicationInfo.openCitations = data[1]; }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting open citation for publication with id: "+this.articleId, err); } ); } @@ -212,7 +213,8 @@ export class PublicationComponent { } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting publication for id: "+this.articleId, err); this.errorMessage = 'No publication found'; this.showLoading = false; @@ -351,4 +353,7 @@ export class PublicationComponent { } */ + private handleError(message: string, error) { + console.error("Publication Landing Page: "+message, error); + } } diff --git a/landingPages/software/software.component.ts b/landingPages/software/software.component.ts index 0dd18fd6..a04d05b9 100644 --- a/landingPages/software/software.component.ts +++ b/landingPages/software/software.component.ts @@ -149,7 +149,8 @@ export class SoftwareComponent { this.showLoading = false; }, err => { - console.log(err) + //console.log(err) + this.handleError("Error getting software for id: "+this.softwareId, err); this.errorMessage = 'No software found'; this.showLoading = false; @@ -192,4 +193,8 @@ export class SoftwareComponent { public getKeys( map) { return Array.from(map.keys()); } + + private handleError(message: string, error) { + console.error("Software Landing Page: "+message, error); + } } diff --git a/searchPages/advanced/advancedSearchDataProviders.component.ts b/searchPages/advanced/advancedSearchDataProviders.component.ts index 77e58156..c7204e5a 100644 --- a/searchPages/advanced/advancedSearchDataProviders.component.ts +++ b/searchPages/advanced/advancedSearchDataProviders.component.ts @@ -5,6 +5,7 @@ import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.cl import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -33,6 +34,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; export class AdvancedSearchDataProvidersComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; @Input() piwikSiteId = null; public results =[]; public filters =[]; @@ -56,6 +58,7 @@ export class AdvancedSearchDataProvidersComponent { constructor (private route: ActivatedRoute, private _searchDataProvidersService: SearchDataprovidersService ) { this.results =[]; this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; //console.info("Con -base url:"+this.searchUtils.baseUrl ); @@ -143,20 +146,23 @@ export class AdvancedSearchDataProvidersComponent { } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting content providers", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = errorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; } @@ -173,5 +179,7 @@ export class AdvancedSearchDataProvidersComponent { } - + private handleError(message: string, error) { + console.error("Content Providers advanced Search Page: "+message, error); + } } diff --git a/searchPages/advanced/advancedSearchDatasets.component.ts b/searchPages/advanced/advancedSearchDatasets.component.ts index e158d856..afd245af 100644 --- a/searchPages/advanced/advancedSearchDatasets.component.ts +++ b/searchPages/advanced/advancedSearchDatasets.component.ts @@ -5,6 +5,7 @@ import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.cl import {SearchDatasetsService} from '../../services/searchDatasets.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -33,6 +34,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; export class AdvancedSearchDatasetsComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; properties:EnvProperties; @Input() piwikSiteId = null; @Input() connectCommunityId: string; @@ -58,6 +60,7 @@ export class AdvancedSearchDatasetsComponent { constructor (private route: ActivatedRoute, private _searchDatasetsService: SearchDatasetsService ) { this.results =[]; this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; @@ -151,20 +154,23 @@ export class AdvancedSearchDatasetsComponent { } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting research data", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = errorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -185,5 +191,7 @@ export class AdvancedSearchDatasetsComponent { } - + private handleError(message: string, error) { + console.error("Research Data advanced Search Page: "+message, error); + } } diff --git a/searchPages/advanced/advancedSearchOrganizations.component.ts b/searchPages/advanced/advancedSearchOrganizations.component.ts index 9af4e27d..9eca6cf0 100644 --- a/searchPages/advanced/advancedSearchOrganizations.component.ts +++ b/searchPages/advanced/advancedSearchOrganizations.component.ts @@ -5,6 +5,7 @@ import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.cl import {SearchOrganizationsService} from '../../services/searchOrganizations.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -32,6 +33,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; export class AdvancedSearchOrganizationsComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; properties:EnvProperties; @Input() piwikSiteId = null; public results =[]; @@ -55,6 +57,7 @@ public resourcesQuery = "(oaftype exact organization)"; constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService ) { this.results =[]; this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; @@ -144,20 +147,23 @@ public resourcesQuery = "(oaftype exact organization)"; } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting organizations", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = errorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -178,5 +184,7 @@ public resourcesQuery = "(oaftype exact organization)"; } - + private handleError(message: string, error) { + console.error("Organizations advanced Search Page: "+message, error); + } } diff --git a/searchPages/advanced/advancedSearchOrps.component.ts b/searchPages/advanced/advancedSearchOrps.component.ts index c5ef2ff0..1e54b342 100644 --- a/searchPages/advanced/advancedSearchOrps.component.ts +++ b/searchPages/advanced/advancedSearchOrps.component.ts @@ -5,6 +5,7 @@ import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.cl import {SearchOrpsService} from '../../services/searchOrps.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -33,6 +34,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; export class AdvancedSearchOrpsComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; properties:EnvProperties; @Input() piwikSiteId = null; @Input() connectCommunityId: string; @@ -58,6 +60,7 @@ export class AdvancedSearchOrpsComponent { constructor (private route: ActivatedRoute, private _searchOrpsService: SearchOrpsService ) { this.results =[]; this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; @@ -148,15 +151,18 @@ export class AdvancedSearchOrpsComponent { } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting other research products", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ this.disableForms = false; } @@ -176,5 +182,7 @@ export class AdvancedSearchOrpsComponent { } - + private handleError(message: string, error) { + console.error("Other Research Products advanced Search Page: "+message, error); + } } diff --git a/searchPages/advanced/advancedSearchProjects.component.ts b/searchPages/advanced/advancedSearchProjects.component.ts index ef76bb19..5f316b0f 100644 --- a/searchPages/advanced/advancedSearchProjects.component.ts +++ b/searchPages/advanced/advancedSearchProjects.component.ts @@ -5,6 +5,7 @@ import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.cl import {SearchProjectsService} from '../../services/searchProjects.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -31,6 +32,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; export class AdvancedSearchProjectsComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; @Input() piwikSiteId = null; public results =[]; public filters =[]; @@ -56,6 +58,7 @@ export class AdvancedSearchProjectsComponent { this.results =[]; this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; @@ -145,20 +148,23 @@ export class AdvancedSearchProjectsComponent { } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting projects", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = errorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -180,5 +186,7 @@ export class AdvancedSearchProjectsComponent { } - + private handleError(message: string, error) { + console.error("Projects advanced Search Page: "+message, error); + } } diff --git a/searchPages/advanced/advancedSearchPublications.component.ts b/searchPages/advanced/advancedSearchPublications.component.ts index 022b848c..5b87c066 100644 --- a/searchPages/advanced/advancedSearchPublications.component.ts +++ b/searchPages/advanced/advancedSearchPublications.component.ts @@ -5,6 +5,7 @@ import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.cl import {SearchPublicationsService} from '../../services/searchPublications.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -34,6 +35,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; export class AdvancedSearchPublicationsComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; @Input() piwikSiteId = null; public results =[]; public filters =[]; @@ -63,6 +65,7 @@ export class AdvancedSearchPublicationsComponent { this.results =[]; this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; @@ -155,20 +158,23 @@ export class AdvancedSearchPublicationsComponent { } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting publications", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -187,5 +193,7 @@ export class AdvancedSearchPublicationsComponent { } - + private handleError(message: string, error) { + console.error("Publications advanced Search Page: "+message, error); + } } diff --git a/searchPages/advanced/advancedSearchSoftware.component.ts b/searchPages/advanced/advancedSearchSoftware.component.ts index 812459a4..ca9482b0 100644 --- a/searchPages/advanced/advancedSearchSoftware.component.ts +++ b/searchPages/advanced/advancedSearchSoftware.component.ts @@ -5,6 +5,7 @@ import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.cl import {SearchSoftwareService} from '../../services/searchSoftware.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -33,6 +34,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; export class AdvancedSearchSoftwareComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; @Input() piwikSiteId = null; @Input() connectCommunityId: string; public results =[]; @@ -59,6 +61,7 @@ export class AdvancedSearchSoftwareComponent { constructor (private route: ActivatedRoute, private _searchSoftwareService: SearchSoftwareService ) { this.results =[]; this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; @@ -152,20 +155,23 @@ export class AdvancedSearchSoftwareComponent { } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting software", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = errorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -186,5 +192,7 @@ export class AdvancedSearchSoftwareComponent { } - + private handleError(message: string, error) { + console.error("Software advanced Search Page: "+message, error); + } } diff --git a/searchPages/dataProviders/compatibleDataProviders.component.ts b/searchPages/dataProviders/compatibleDataProviders.component.ts index 6b1a375d..1414e0cf 100644 --- a/searchPages/dataProviders/compatibleDataProviders.component.ts +++ b/searchPages/dataProviders/compatibleDataProviders.component.ts @@ -5,6 +5,7 @@ import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchPageComponent } from '../searchUtils/searchPage.component'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -33,6 +34,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; }) export class SearchCompatibleDataprovidersComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; public results =[]; public filters =[]; public baseUrl:string; @@ -59,6 +61,7 @@ properties:EnvProperties; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; for(var i = 0; i < this._prefixQueryFields.length; i++ ){ for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ @@ -130,20 +133,23 @@ properties:EnvProperties; }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting compatible content providers", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -202,4 +208,8 @@ properties:EnvProperties; } return filters; } + + private handleError(message: string, error) { + console.error("Compatible Content Providers (Repositories) Search Page: "+message, error); + } } diff --git a/searchPages/dataProviders/compatibleDataProvidersTable.component.ts b/searchPages/dataProviders/compatibleDataProvidersTable.component.ts index 44c24b98..67cd1dcb 100644 --- a/searchPages/dataProviders/compatibleDataProvidersTable.component.ts +++ b/searchPages/dataProviders/compatibleDataProvidersTable.component.ts @@ -5,6 +5,7 @@ import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchPageTableViewComponent } from '../searchUtils/searchPageTableView.component'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -31,7 +32,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; }) export class SearchCompatibleDataprovidersTableComponent { private errorCodes: ErrorCodes; - + private errorMessages: ErrorMessagesComponent; public results =[]; public filters =[]; public columnNames = ["Name", "Type", "Country", "Institution", "Compatibility"]; @@ -57,6 +58,7 @@ properties:EnvProperties; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; } @@ -121,20 +123,23 @@ properties:EnvProperties; this.enableSearchView = true; }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting compatible content providers", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ this.enableSearchView = true; } ); @@ -147,20 +152,23 @@ properties:EnvProperties; } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting compatible content providers (size=0)", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ this.enableSearchView = true; } ); @@ -215,7 +223,7 @@ properties:EnvProperties; var value_name = []; var value_original_id = []; let i, j; - //console.info(data); + for(i=0; i { - console.log(err); + //console.log(err); + this.handleError("Error getting entity registries", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -193,4 +198,8 @@ properties:EnvProperties; } return filters; } + + private handleError(message: string, error) { + console.error("Entity Registries Search Page: "+message, error); + } } diff --git a/searchPages/dataProviders/entityRegistriesTable.component.ts b/searchPages/dataProviders/entityRegistriesTable.component.ts index 20b11124..821eb75c 100644 --- a/searchPages/dataProviders/entityRegistriesTable.component.ts +++ b/searchPages/dataProviders/entityRegistriesTable.component.ts @@ -4,6 +4,7 @@ import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchPageTableViewComponent } from '../searchUtils/searchPageTableView.component'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -31,7 +32,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; }) export class SearchEntityRegistriesTableComponent { private errorCodes: ErrorCodes; - + private errorMessages: ErrorMessagesComponent; public results =[]; public filters =[]; public columnNames = ["Name", "Type", "Country", "Institution", "Compatibility"]; @@ -49,6 +50,7 @@ properties:EnvProperties; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; } @@ -111,20 +113,23 @@ properties:EnvProperties; this.enableSearchView = true; }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting entity registries", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ this.enableSearchView = true; } ); @@ -137,20 +142,23 @@ properties:EnvProperties; } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting entity registries (size=0)", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ this.enableSearchView = true; } ); @@ -220,7 +228,7 @@ properties:EnvProperties; var value_name = []; var value_original_id = []; let i, j; - //console.info(data); + for(i=0; i { - console.log(err); + //console.log(err); + this.handleError("Error getting journals", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -196,4 +201,8 @@ properties:EnvProperties; } return filters; } + + private handleError(message: string, error) { + console.error("Journals Search Page: "+message, error); + } } diff --git a/searchPages/dataProviders/journalsTable.component.ts b/searchPages/dataProviders/journalsTable.component.ts index 7d1359d8..98e621da 100644 --- a/searchPages/dataProviders/journalsTable.component.ts +++ b/searchPages/dataProviders/journalsTable.component.ts @@ -6,6 +6,7 @@ import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchPageTableViewComponent } from '../searchUtils/searchPageTableView.component'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -32,7 +33,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; }) export class SearchJournalsTableComponent { private errorCodes: ErrorCodes; - + private errorMessages: ErrorMessagesComponent; public results =[]; public filters =[]; public columnNames = ["Name", "Type", "Country", "Institution", "Compatibility"]; @@ -58,6 +59,7 @@ properties:EnvProperties; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; } @@ -120,20 +122,23 @@ properties:EnvProperties; this.enableSearchView = true; }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting journals", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ this.enableSearchView = true; } @@ -147,20 +152,23 @@ properties:EnvProperties; } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting journals (size=0)", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ this.enableSearchView = true; } ); @@ -207,4 +215,8 @@ properties:EnvProperties; } return filters; } + + private handleError(message: string, error) { + console.error("Journals Search Page - Table view: "+message, error); + } } diff --git a/searchPages/find/search.component.ts b/searchPages/find/search.component.ts index bca8e980..d2e398b2 100644 --- a/searchPages/find/search.component.ts +++ b/searchPages/find/search.component.ts @@ -369,7 +369,8 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting number of Publications", err); this.fetchPublications.searchUtils.status = this.errorCodes.ERROR; } ); @@ -386,7 +387,8 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting number of Research Data", err); this.fetchDatasets.searchUtils.status = this.errorCodes.ERROR; } ); @@ -403,15 +405,16 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj } }, err => { - console.log(err); + this.handleError("Error getting number of Software", err); + /*console.log(err); if(err.status == '404') { this.fetchSoftware.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.fetchSoftware.searchUtils.status = this.errorCodes.ERROR; } else { this.fetchSoftware.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } - //this.fetchSoftware.searchUtils.status = this.errorCodes.ERROR; + }*/ + this.fetchSoftware.searchUtils.status = this.errorCodes.ERROR; } ); } @@ -427,7 +430,8 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting number of Other Research Products", err); this.fetchOrps.searchUtils.status = this.errorCodes.ERROR; } ); @@ -444,7 +448,8 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting number of Projects", err); this.fetchProjects.searchUtils.status = this.errorCodes.ERROR; } ); @@ -465,7 +470,8 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting number of Organizations", err); this.fetchOrganizations.searchUtils.status = this.errorCodes.ERROR; } @@ -492,6 +498,7 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj this.fetchOrps.searchUtils.status = null; } - - + private handleError(message: string, error) { + console.error("General Search Page: "+message, error); + } } diff --git a/searchPages/searchUtils/browseEntities.component.ts b/searchPages/searchUtils/browseEntities.component.ts index 83d79f78..d2e394a5 100644 --- a/searchPages/searchUtils/browseEntities.component.ts +++ b/searchPages/searchUtils/browseEntities.component.ts @@ -6,6 +6,7 @@ import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; import {RefineFieldResultsService} from '../../services/refineFieldResults.service'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchPageComponent } from '../searchUtils/searchPage.component'; import {SearchUtilsClass} from '../searchUtils/searchUtils.class'; @@ -43,11 +44,12 @@ export class BrowseEntitiesComponent { public sub: any; public errorCodes:ErrorCodes = new ErrorCodes(); + private errorMessages: ErrorMessagesComponent; public status = this.errorCodes.LOADING; public fieldIdsMap=this.searchFields.RESULT_REFINE_FIELDS; constructor ( private _refineFieldsService: RefineFieldResultsService ) { - + this.errorMessages = new ErrorMessagesComponent(); } public ngOnInit() { @@ -83,20 +85,27 @@ private getStats(){ } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting refine fields results (stats) by entity: "+this.entityName, err); + this.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //this.status = this.errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.status = this.errorCodes.ERROR; } else { this.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); -} + } + + private handleError(message: string, error) { + console.error("Browse Entities (Search): "+message, error); + } } diff --git a/searchPages/searchUtils/searchDownload.component.ts b/searchPages/searchUtils/searchDownload.component.ts index a7907dce..11db4519 100644 --- a/searchPages/searchUtils/searchDownload.component.ts +++ b/searchPages/searchUtils/searchDownload.component.ts @@ -85,8 +85,8 @@ export class SearchDownloadComponent { this.alertApplyAll.message = "Sorry, but the results are too many! Use the api instead!"; this.alertApplyAll.cancelButtonText = "Ok"; - console.error("denial of Download"); - + console.error("Error downloading file. Results are too many!"); + //this.handleError("Error downloading file. Results are too many!", err); } downloadfile(url:string,filename:string){ //var newWindow = window.open("", "_parent"); @@ -120,7 +120,9 @@ export class SearchDownloadComponent { } }, error => { - console.error("Error downloading the file."); + //console.error("Error downloading the file."); + this.handleError("Error downloading file: "+filename, error); + //newWindow.close(); this.closeLoading(); this.confirmOpenCsvError(); @@ -158,4 +160,7 @@ export class SearchDownloadComponent { this.alertCsvError.open(); } + private handleError(message: string, error) { + console.error("Search Download (component): "+message, error); + } } diff --git a/searchPages/simple/searchDataproviders.component.ts b/searchPages/simple/searchDataproviders.component.ts index 77a5ac2b..216078c1 100644 --- a/searchPages/simple/searchDataproviders.component.ts +++ b/searchPages/simple/searchDataproviders.component.ts @@ -5,6 +5,7 @@ import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; import {SearchResult} from '../../utils/entities/searchResult'; import { ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchPageComponent } from '../searchUtils/searchPage.component'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -32,6 +33,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; }) export class SearchDataprovidersComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; @Input() piwikSiteId = null; public results =[]; public filters =[]; @@ -60,6 +62,7 @@ properties: EnvProperties; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.page =1; } @@ -126,7 +129,10 @@ properties: EnvProperties; } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting content providers for "+entity+" with id: "+id, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; @@ -134,13 +140,13 @@ properties: EnvProperties; //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -161,20 +167,23 @@ properties: EnvProperties; } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting number of content providers for keyword: "+keyword, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -196,20 +205,23 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting content providers in share "+type+" for organization with id: "+id, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -235,20 +247,23 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting content providers for "+entity+" with id: "+id, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -268,20 +283,23 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting content providers for entity registry with id: "+id, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -338,20 +356,23 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting content providers", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -370,4 +391,8 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) var parameters = $event.value; this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); } + + private handleError(message: string, error) { + console.error("Content Providers simple Search Page: "+message, error); + } } diff --git a/searchPages/simple/searchDatasets.component.ts b/searchPages/simple/searchDatasets.component.ts index 0b2167ca..54c90eaa 100644 --- a/searchPages/simple/searchDatasets.component.ts +++ b/searchPages/simple/searchDatasets.component.ts @@ -6,6 +6,7 @@ import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; import {SearchDatasetsService} from '../../services/searchDatasets.service'; import {SearchResult} from '../../utils/entities/searchResult'; import { ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchPageComponent } from '../searchUtils/searchPage.component'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -38,6 +39,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; export class SearchDatasetsComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; @Input() piwikSiteId = null; public results =[]; public filters: Filter[] =[]; @@ -66,6 +68,7 @@ properties: EnvProperties; constructor (private route: ActivatedRoute, private _searchDatasetsService: SearchDatasetsService ) { this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.page =1; @@ -143,20 +146,23 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting research data for "+entity+" with id: "+id, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -185,20 +191,23 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting research data for content provider ("+resultsFrom+") with id: "+id, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -264,20 +273,23 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting research data", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -299,4 +311,8 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number //this.getResults(parameters, this.searchUtils.page, this.searchUtils.size, "searchPage"); this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy); } + + private handleError(message: string, error) { + console.error("Research Data simple Search Page: "+message, error); + } } diff --git a/searchPages/simple/searchOrganizations.component.ts b/searchPages/simple/searchOrganizations.component.ts index ef0dcf83..3b247fcc 100644 --- a/searchPages/simple/searchOrganizations.component.ts +++ b/searchPages/simple/searchOrganizations.component.ts @@ -5,6 +5,7 @@ import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; import {SearchOrganizationsService} from '../../services/searchOrganizations.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchPageComponent } from '../searchUtils/searchPage.component'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -32,6 +33,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; }) export class SearchOrganizationsComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; @Input() piwikSiteId = null; public results =[]; public filters =[]; @@ -55,6 +57,7 @@ properties: EnvProperties; constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService ) { this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.page =1; @@ -156,20 +159,23 @@ properties: EnvProperties; } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting organizations", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -186,4 +192,8 @@ properties: EnvProperties; //console.info("queryChanged: Execute search query "+parameters); this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); } + + private handleError(message: string, error) { + console.error("Organizations simple Search Page: "+message, error); + } } diff --git a/searchPages/simple/searchOrps.component.ts b/searchPages/simple/searchOrps.component.ts index a839ebee..95baa1ad 100644 --- a/searchPages/simple/searchOrps.component.ts +++ b/searchPages/simple/searchOrps.component.ts @@ -6,6 +6,7 @@ import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; import {SearchOrpsService} from '../../services/searchOrps.service'; import {SearchResult} from '../../utils/entities/searchResult'; import { ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchPageComponent } from '../searchUtils/searchPage.component'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -37,6 +38,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; export class SearchOrpsComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; @Input() piwikSiteId = null; public results =[]; public filters: Filter[] =[]; @@ -63,6 +65,7 @@ properties: EnvProperties; constructor (private route: ActivatedRoute, private _searchOrpsService: SearchOrpsService ) { this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.page =1; @@ -140,15 +143,18 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting other research products for "+entity+" with id: "+id, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -176,15 +182,18 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting other research products for content provider ("+resultsFrom+") with id: "+id, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -248,15 +257,18 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting other research products", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ this.disableForms = false; } @@ -276,4 +288,8 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number var parameters = $event.value; this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy); } + + private handleError(message: string, error) { + console.error("Other Research Products simple Search Page: "+message, error); + } } diff --git a/searchPages/simple/searchProjects.component.ts b/searchPages/simple/searchProjects.component.ts index e7d374a2..4767a2a2 100644 --- a/searchPages/simple/searchProjects.component.ts +++ b/searchPages/simple/searchProjects.component.ts @@ -5,6 +5,7 @@ import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; import {SearchProjectsService} from '../../services/searchProjects.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchPageComponent } from '../searchUtils/searchPage.component'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -31,6 +32,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; }) export class SearchProjectsComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; @Input() piwikSiteId = null; public results =[]; public filters: Filter[] =[]; @@ -55,6 +57,7 @@ properties: EnvProperties; constructor (private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService) { this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.page =1; @@ -159,20 +162,23 @@ properties: EnvProperties; } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting projects", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -196,20 +202,23 @@ properties: EnvProperties; } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting projects for content provider with id: "+id, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -223,4 +232,7 @@ properties: EnvProperties; this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); } + private handleError(message: string, error) { + console.error("Projects simple Search Page: "+message, error); + } } diff --git a/searchPages/simple/searchPublications.component.ts b/searchPages/simple/searchPublications.component.ts index 0ef2a443..13dd2b87 100644 --- a/searchPages/simple/searchPublications.component.ts +++ b/searchPages/simple/searchPublications.component.ts @@ -7,6 +7,7 @@ import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; import {SearchPublicationsService} from '../../services/searchPublications.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchPageComponent } from '../searchUtils/searchPage.component'; import {SearchUtilsClass} from '../searchUtils/searchUtils.class'; @@ -41,6 +42,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; }) export class SearchPublicationsComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; @Input() piwikSiteId = null; public results =[]; public filters =[]; @@ -74,6 +76,7 @@ export class SearchPublicationsComponent { properties: EnvProperties; constructor (private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService ) { this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.page =1; @@ -151,20 +154,23 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting publications for "+entity+" with id: "+id, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -193,20 +199,23 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting publications for content provider ("+resultsFrom+") with id: "+id, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -275,20 +284,23 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting publications", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -330,5 +342,7 @@ public getAggregatorResults(id:string, page: number, size: number){ } - + private handleError(message: string, error) { + console.error("Publications simple Search Page: "+message, error); + } } diff --git a/searchPages/simple/searchSoftware.component.ts b/searchPages/simple/searchSoftware.component.ts index 68268d06..b894a17f 100644 --- a/searchPages/simple/searchSoftware.component.ts +++ b/searchPages/simple/searchSoftware.component.ts @@ -6,6 +6,7 @@ import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; import {SearchSoftwareService} from '../../services/searchSoftware.service'; import {SearchResult} from '../../utils/entities/searchResult'; import {ErrorCodes} from '../../utils/properties/errorCodes'; +import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; import {SearchPageComponent } from '../searchUtils/searchPage.component'; import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -37,6 +38,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; export class SearchSoftwareComponent { private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; @Input() openaireLink: string ; @Input() connectCommunityId: string; @Input() advancedSearchParameters ; @@ -65,6 +67,7 @@ properties: EnvProperties; constructor (private route: ActivatedRoute, private _searchSoftwareService: SearchSoftwareService ) { this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.page =1; @@ -143,20 +146,23 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting software for "+entity+" with id: "+id, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -185,20 +191,23 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting software for content provider ("+resultsFrom+") with id: "+id, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ } ); } @@ -264,20 +273,23 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number } }, err => { - console.log(err); + //console.log(err); + this.handleError("Error getting software", err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } //var errorCodes:ErrorCodes = new ErrorCodes(); //this.searchUtils.status = errorCodes.ERROR; - if(err.status == '404') { + /*if(err.status == '404') { this.searchUtils.status = this.errorCodes.NOT_FOUND; } else if(err.status == '500') { this.searchUtils.status = this.errorCodes.ERROR; } else { this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + }*/ //this.searchPage.closeLoading(); this.disableForms = false; @@ -299,4 +311,8 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number //this.getResults(parameters, this.searchUtils.page, this.searchUtils.size, "searchPage"); this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy); } + + private handleError(message: string, error) { + console.error("Software simple Search Page: "+message, error); + } } diff --git a/utils/errorMessages.component.ts b/utils/errorMessages.component.ts index b2de10b5..070f7659 100644 --- a/utils/errorMessages.component.ts +++ b/utils/errorMessages.component.ts @@ -42,10 +42,11 @@ import {ErrorCodes} from './properties/errorCodes'; public errorCodes:ErrorCodes; - constructor () {} + constructor () { + this.errorCodes = new ErrorCodes(); + } ngOnInit() { - this.errorCodes = new ErrorCodes(); if(!this.status) { this.status = [this.errorCodes.LOADING]; } @@ -58,4 +59,14 @@ import {ErrorCodes} from './properties/errorCodes'; return (status == code); } } + + public getErrorCode(status: string) { + if(status == '404') { + return this.errorCodes.NOT_FOUND; + } else if(status == '500') { + return this.errorCodes.ERROR; + } else { + return this.errorCodes.NOT_AVAILABLE; + } + } }