Skip to content

Commit

Permalink
register api / indexing fixes for accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
holycrab13 committed Jan 30, 2025
1 parent 9638c06 commit c38cbaa
Show file tree
Hide file tree
Showing 28 changed files with 906 additions and 249 deletions.
3 changes: 3 additions & 0 deletions devenv/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: "3.0"
name: databus_nodejs_devenv
services:
gstore:
restart: unless-stopped
image: dbpedia/gstore:dev
container_name: databus_devenv_gstore
environment:
Expand All @@ -17,6 +18,7 @@ services:
- ./data/gstore/git:/gstore/git
- ./data/gstore/logs:/gstore/logs
lookup:
restart: unless-stopped
image: lookup:dev
container_name: databus_devenv_lookup
ports:
Expand All @@ -25,6 +27,7 @@ services:
- ./data/index/:/index
- ../search/servlet-config.yml:/resources/config.yml
virtuoso:
restart: unless-stopped
image: "openlink/virtuoso-opensource-7:latest"
container_name: databus_devenv_virtuoso
environment:
Expand Down
32 changes: 21 additions & 11 deletions public/dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/components/nav-search/nav-search-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function NavSearchController($http, $interval, $sce, searchManager) {

}

ctrl.availableResourceTypes = ['Collection', 'Artifact', 'Group', 'PersonalProfileDocument', 'Version' ];
ctrl.availableResourceTypes = ['Collection', 'Artifact', 'Group', 'Account', 'Version' ];

ctrl.$onInit = function () {

Expand Down
2 changes: 1 addition & 1 deletion public/js/components/search/search-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function SearchController($http, $interval, $sce, searchManager) {
ctrl.search();
}

ctrl.availableResourceTypes = ['Collection', 'Artifact', 'Group', 'PersonalProfileDocument', 'Version' ];
ctrl.availableResourceTypes = ['Collection', 'Artifact', 'Group', 'Account', 'Version' ];

ctrl.$onInit = function () {

Expand Down
4 changes: 2 additions & 2 deletions public/js/components/type-tag/type-tag.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/js/page-controller/group-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function GroupPageController($scope, $http, $sce, $interval, $location, collecti
var groupUpdate = $scope.dataidCreator.createGroupUpdate();

var relativeUri = new URL($scope.group.uri).pathname;
var response = await $http.put(relativeUri, groupUpdate);
var response = await $http.post('/api/register', groupUpdate);

if (response.status == 200) {
$scope.group.title = $scope.formData.group.title;
Expand Down
4 changes: 2 additions & 2 deletions public/js/page-controller/profile-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function ProfileController($scope, $http) {
null,
null);

$http.put(`/${accountName}`, accountJsonLd).then(function (result) {
$http.post(`/api/register`, accountJsonLd).then(function (result) {
window.location.reload(true);
}, function (err) {
console.log(err);
Expand Down Expand Up @@ -189,7 +189,7 @@ function ProfileController($scope, $http) {
$scope.editData.about,
$scope.editData.imageUrl);

$http.put(`/${$scope.auth.info.accountName}`, accountJsonLd).then(function (result) {
$http.post(`/api/register`, accountJsonLd).then(function (result) {
DatabusAlert.alert($scope, true, DatabusMessages.ACCOUT_PROFILE_SAVED);
}, function (err) {
console.log(err);
Expand Down
28 changes: 9 additions & 19 deletions public/js/utils/app-json-formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,32 @@ class AppJsonFormatter {
static createAccountData(resourceBaseUrl, accountName, accountLabel, accountStatus, accountImage) {

var accountUri = `${resourceBaseUrl}/${accountName}`;
var profileUri = `${resourceBaseUrl}/${accountName}${DatabusConstants.WEBID_DOCUMENT}`;
var personUri = `${resourceBaseUrl}/${accountName}${DatabusConstants.WEBID_THIS}`;

var accountJsonLd = {};

var accountGraph = {};
accountGraph[DatabusUris.JSONLD_ID] = accountUri;
accountGraph[DatabusUris.JSONLD_TYPE] = DatabusUris.DATABUS_ACCOUNT;

var personGraph = {};
personGraph[DatabusUris.JSONLD_ID] = personUri;
personGraph[DatabusUris.JSONLD_TYPE] = [
DatabusUris.FOAF_PERSON,
DatabusUris.DBP_DBPEDIAN
];
personGraph[DatabusUris.JSONLD_TYPE] = DatabusUris.FOAF_PERSON;
personGraph[DatabusUris.FOAF_NAME] = accountLabel;
personGraph[DatabusUris.FOAF_ACCOUNT] = JsonldUtils.refTo(accountUri);

if (accountStatus != null) {
personGraph[DatabusUris.FOAF_STATUS] = accountStatus;
}

personGraph[DatabusUris.FOAF_ACCOUNT] = {};
personGraph[DatabusUris.FOAF_ACCOUNT][DatabusUris.JSONLD_ID] = accountUri;

if (accountImage != null) {
personGraph[DatabusUris.FOAF_IMG] = {};
personGraph[DatabusUris.FOAF_IMG][DatabusUris.JSONLD_ID] = accountImage;
personGraph[DatabusUris.FOAF_IMG] = JsonldUtils.refTo(accountImage);
}

var profileGraph = {};
profileGraph[DatabusUris.JSONLD_ID] = profileUri;
profileGraph[DatabusUris.JSONLD_TYPE] = DatabusUris.FOAF_PERSONAL_PROFILE_DOCUMENT;
profileGraph[DatabusUris.FOAF_PRIMARY_TOPIC] = {};
profileGraph[DatabusUris.FOAF_PRIMARY_TOPIC][DatabusUris.JSONLD_ID] = personUri;
profileGraph[DatabusUris.FOAF_MAKER] = {};
profileGraph[DatabusUris.FOAF_MAKER][DatabusUris.JSONLD_ID] = personUri;

accountJsonLd[DatabusUris.JSONLD_GRAPH] = [
personGraph,
profileGraph
accountGraph,
personGraph
];

return accountJsonLd;
Expand Down
2 changes: 2 additions & 0 deletions public/js/utils/databus-uris.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class DatabusUris {
static DATABUS_PART = 'https://dataid.dbpedia.org/databus#Part';
static DATABUS_VERSION = 'https://dataid.dbpedia.org/databus#Version';
static DATABUS_GROUP = 'https://dataid.dbpedia.org/databus#Group';
static DATABUS_ACCOUNT = 'https://dataid.dbpedia.org/databus#Account';
static DATABUS_ARTIFACT = 'https://dataid.dbpedia.org/databus#Artifact';
static DATABUS_VERSION_PROPERTY = 'https://dataid.dbpedia.org/databus#version';
static DATABUS_GROUP_PROPERTY = 'https://dataid.dbpedia.org/databus#group';
Expand Down Expand Up @@ -88,6 +89,7 @@ class DatabusUris {
static FOAF_PERSON = 'http://xmlns.com/foaf/0.1/Person';
static FOAF_PRIMARY_TOPIC = 'http://xmlns.com/foaf/0.1/primaryTopic';
static FOAF_MAKER = 'http://xmlns.com/foaf/0.1/maker';
static FOAF_ACCOUNT_NAME = 'http://xmlns.com/foaf/0.1/accountName';
static FOAF_IMG = 'http://xmlns.com/foaf/0.1/img';

// S4AC
Expand Down
16 changes: 14 additions & 2 deletions public/js/utils/databus-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const DatabusCollectionUtils = require("../collections/databus-collection-utils"
var markdownit = require('markdown-it');
const moment = require("moment/moment");
const DatabusUris = require("./databus-uris");
const ApiError = require("../../../server/app/common/utils/api-error");

class DatabusUtils {

Expand Down Expand Up @@ -502,8 +503,19 @@ class DatabusUtils {
return errorList;
}

}
static validateNamespace(uri, accountName) {

var baseURL = process.env.DATABUS_RESOURCE_BASE_URL;

if (!uri.startsWith(process.env.DATABUS_RESOURCE_BASE_URL)) {
throw new ApiError(`Identifier <${uri}> does not start with the resource base url <${baseURL}> of this Databus.`, 400);
}

// export default DatabusUtils;
var namespacePrefix = `${baseURL}/${accountName}/`;
if (!uri.startsWith(namespacePrefix)) {
throw new ApiError(`Identifier <${uri}> does not start with the expected namespace prefix <${namespacePrefix}>.`, 403);
}
}
}

module.exports = DatabusUtils;
6 changes: 6 additions & 0 deletions public/js/utils/jsonld-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ const DatabusUris = require("./databus-uris");

class JsonldUtils {

static refTo(uri) {
var result = {};
result[DatabusUris.JSONLD_ID] = uri;
return result;
}

static getTypedGraph(graphs, graphType) {

for (var g in graphs) {
Expand Down
Loading

0 comments on commit c38cbaa

Please sign in to comment.