Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Robert Verkerk
B2SAFE Core
Commits
cd90e9ad
Commit
cd90e9ad
authored
Sep 14, 2018
by
Claudio Cacciari
Browse files
added support for http api endpoints configuration
parent
ec14d851
Changes
2
Hide whitespace changes
Inline
Side-by-side
rulebase/local.re
View file @
cd90e9ad
...
...
@@ -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
.
...
...
rulebase/pid-service.re
View file @
cd90e9ad
...
...
@@ -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
(
*
server
ID
,*
server
ID
Length
);
msiSubstr
(
*
oldURL
,
str
(
int
(
*
server
ID
Length
))
,
"null"
,
*
sourcePath
);
msiSubstr
(
*
newURL
,
str
(
int
(
*
server
ID
Length
))
,
"null"
,
*
targetPath
);
msiStrlen
(
*
server
Api
,*
server
Api
Length
);
msiSubstr
(
*
oldURL
,
str
(
int
(
*
server
Api
Length
))
,
"null"
,
*
sourcePath
);
msiSubstr
(
*
newURL
,
str
(
int
(
*
server
Api
Length
))
,
"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
=
*
server
ID
++
*
Row
.
COLL_NAME
;
*
targetColl
=
*
server
Api
++
*
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
=
*
server
ID
++
*
objPath
;
*
targetObj
=
*
server
Api
++
*
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment