Commit cd90e9ad authored by Claudio Cacciari's avatar Claudio Cacciari
Browse files

added support for http api endpoints configuration

parent ec14d851
......@@ -39,6 +39,20 @@ getEpicApiParameters(*credStoreType, *credStorePath, *epicApi, *serverID, *epicD
}
}
# Provides parameters for the connection with the EPIC service
#
# Arguments:
# *serverApireg [OUT] the endpoint of the HTTP API interface for data with PIDs
# *serverApipub [OUT] the endpoint of the HTTP API interface for public data
#
# Author: Claudio Cacciari (Cineca)
#-------------------------------------------------------------------------------
getHttpApiParameters(*serverApireg, *serverApipub) {
*serverApireg="https://<hostnameWithFullDomain>/api/registered";
*serverApipub="https://<hostnameWithFullDomain>/api/public";
}
# Parse the credentials to connect to an EPIC server. A file called
# "credentials" MUST contain all the connection details in the home folder of
# the user running this rule.
......
......@@ -148,8 +148,12 @@ EUDATCreatePID(*parent_pid, *path, *ror, *fio, *fixed, *newPID) {
EUDATSearchPID(*path, *existing_pid) {
logDebug("[EUDATSearchPID] search pid for *path");
getEpicApiParameters(*credStoreType, *credStorePath, *epicApi, *serverID, *epicDebug);
getHttpApiParameters(*serverApireg, *serverApipub);
EUDATReplaceHash(*path, *path1);
*status = EUDATePIDsearch("URL", "*serverID*path1", *existing_pid);
*status = EUDATePIDsearch("URL", "*serverApireg*path1", *existing_pid);
if (!(*status)) {
*status = EUDATePIDsearch("URL", "*serverApipub*path1", *existing_pid);
}
logDebug("[EUDATSearchPID] pid = *existing_pid");
*status;
}
......@@ -264,8 +268,36 @@ EUDATiPIDcreate(*path, *PID) {
EUDATePIDcreate(*path, *extraType, *PID) {
getEpicApiParameters(*credStoreType, *credStorePath, *epicApi, *serverID, *epicDebug) ;
getHttpApiParameters(*serverApireg, *serverApipub);
*url="*serverID*path";
*access = "private";
# Verify that source input path is a collection
msiGetObjType(*path, *type);
if (*type != '-c') {
msiSplitPath(*path, *parent, *child);
foreach ( *R in SELECT USER_NAME WHERE DATA_NAME = '*child' AND COLL_NAME = '*parent') {
if (*R.USER_NAME == "anonymous") {
*access = "public";
break;
}
}
}
else {
foreach ( *R in SELECT COLL_OWNER_NAME WHERE COLL_NAME = '*path' ) {
if (*R.COLL_OWNER_NAME == "anonymous") {
*access = "public";
break;
}
}
}
if (*access == "public") {
*url = "*serverApipub*path";
}
else {
*url = "*serverApireg*path";
}
*resource = "";
EUDATiCHECKSUMget(*path, *checksum, *modtime, *resource);
if (*checksum != "") {
......@@ -389,10 +421,18 @@ EUDATeURLupdateColl(*PID, *newURL) {
logDebug("[EUDATeURLupdateColl] updating collection *PID with URL *newURL and all its content");
getEpicApiParameters(*credStoreType, *credStorePath, *epicApi, *serverID, *epicDebug);
getHttpApiParameters(*serverApireg, *serverApipub);
if (*oldURL like "*serverApireg\*" ) {
*serverApi = *serverApireg
}
else {
*serverApi = *serverApipub
}
EUDATeURLsearch(*PID, *oldURL);
msiStrlen(*serverID,*serverIDLength);
msiSubstr(*oldURL, str(int(*serverIDLength)), "null", *sourcePath);
msiSubstr(*newURL, str(int(*serverIDLength)), "null", *targetPath);
msiStrlen(*serverApi,*serverApiLength);
msiSubstr(*oldURL, str(int(*serverApiLength)), "null", *sourcePath);
msiSubstr(*newURL, str(int(*serverApiLength)), "null", *targetPath);
msiStrlen(*targetPath, *pathLength);
logDebug("[EUDATeURLupdateColl] loop over the sub-collections of *targetPath");
......@@ -401,7 +441,7 @@ EUDATeURLupdateColl(*PID, *newURL) {
msiSubstr(*Row.COLL_NAME, str(int(*pathLength)), "null", *subCollection);
*sourceColl = "*sourcePath*subCollection"
if (EUDATSearchPID(*sourceColl, *existing_pid)) {
*targetColl = *serverID ++ *Row.COLL_NAME;
*targetColl = *serverApi ++ *Row.COLL_NAME;
EUDATeURLupdate(*existing_pid, *targetColl);
}
}
......@@ -413,7 +453,7 @@ EUDATeURLupdateColl(*PID, *newURL) {
msiSubstr(*objPath, str(int(*pathLength)), "null", *subObjPath);
*sourceObj = "*sourcePath*subObjPath";
if (EUDATSearchPID(*sourceObj, *existing_pid)) {
*targetObj = *serverID ++ *objPath;
*targetObj = *serverApi ++ *objPath;
EUDATeURLupdate(*existing_pid, *targetObj);
}
}
......@@ -445,7 +485,7 @@ EUDATeURLsearch(*PID, *URL) {
# Author: Giacomo Mariani, CINECA
#-------------------------------------------------------------------------------
EUDATePIDremove(*path, *force) {
getEpicApiParameters(*credStoreType, *credStorePath, *epicApi, *serverID, *epicDebug)
getEpicApiParameters(*credStoreType, *credStorePath, *epicApi, *serverID, *epicDebug);
logDebug("[EUDATePIDremove] removing PID associated to: $userNameClient, *path");
if (EUDATSearchPID(*path, *pid)) {
......@@ -547,7 +587,7 @@ EUDATeFIOupdate(*pid, *newFio) {
#-----------------------------------------------------------------------------
EUDATPidsForColl(*collPath, *fixed) {
logInfo("[EUDATPidsForColl] Creating PIDs for collection *collPath");
logInfo("[EUDATPidsForColl] Creating PIDs for collection *collPath and fixed = *fixed");
# Verify that source input path is a collection
msiGetObjType(*collPath, *type);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment