Skip to content

Commit

Permalink
Remove search harvest record endpoint and improve bruno tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandro-bulgaris-qcif committed May 31, 2024
1 parent 4ade81f commit a5aa96e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 55 deletions.
5 changes: 0 additions & 5 deletions config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,6 @@ module.exports.routes = {
action: 'legacyHarvest',
csrf: false
},
'get /:branding/:portal/api/mint/harvest/search': {
controller: 'webservice/RecordController',
action: 'getHarvestRecord',
csrf: false
},
'put /:branding/:portal/api/records/objectmetadata/:oid': {
controller: 'webservice/RecordController',
action: 'updateObjectMeta',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,13 @@ tests {
expect(res.getStatus()).to.equal(200);
});

test("Test oid exists", function () {
var jsonData = res.getBody();
expect(jsonData[0]).to.have.property('oid');
});

test("Test harvestId exists", function () {
var jsonData = res.getBody();
expect(jsonData[0]).to.have.property('harvestId');
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,14 @@ tests {
expect(res.getStatus()).to.equal(200);
});

test("Test oid exists", function () {
var jsonData = res.getBody();
expect(jsonData[0]).to.have.property('oid');
});

test("Test harvestId exists", function () {
var jsonData = res.getBody();
expect(jsonData[0]).to.have.property('harvestId');
});

}

This file was deleted.

23 changes: 1 addition & 22 deletions typescript/api/controllers/webservice/RecordController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ export module Controllers {
'addRoleView',
'removeRoleView',
'harvest',
'legacyHarvest',
'getHarvestRecord'
'legacyHarvest'
];

constructor() {
Expand Down Expand Up @@ -1158,26 +1157,6 @@ export module Controllers {
}
}

public async getHarvestRecord(req, res) {
const brand:BrandingModel = BrandingService.getBrand(req.session.branding);
sails.log.debug('brand is...');
sails.log.debug(brand);
let harvestId:string = req.param('harvestId');
let recordType:string = req.param('recordType');

try {
let results = await this.findExistingHarvestRecord(harvestId,recordType);
if(!_.isEmpty(results)) {
const record:RecordModel = results[0];
return res.json(record['metadata']);
} else {
this.apiFailWrapper(req, res, 500, null, null, `Failed to get object meta for harvestId ${harvestId} and recordType ${recordType}, please check server logs.`);
}
} catch (err) {
this.apiFailWrapper(req, res, 500, null, err, `Failed to get object meta for harvestId ${harvestId} and recordType ${recordType}, please check server logs.`);
}
}

private async findExistingHarvestRecord(harvestId: string, recordType: string) {
let results = await Record.find({
'harvestId': harvestId,
Expand Down
1 change: 0 additions & 1 deletion typescript/api/services/VocabService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export module Services {
searchString = ` AND (${queryString})`;
}

//TODO instead of call external mint perform an Ajax call to ReDBOx or directly serach in the database for records or in the solr index ???
const mintUrl = `${sails.config.record.baseUrl.mint}${sails.config.mint.api.search.url}?q=repository_type:${sourceType}${searchString}&version=2.2&wt=json&start=0`;
sails.log(mintUrl);
const options = this.getMintOptions(mintUrl, sails.config.record.api.search.method);
Expand Down

0 comments on commit a5aa96e

Please sign in to comment.