Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mediaflux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
resplat-mediaflux
mediaflux
Commits
6cd07c97
Commit
6cd07c97
authored
1 month ago
by
Raj Sundararajan
Browse files
Options
Downloads
Patches
Plain Diff
use rcp service to get users for rcpuser role setting
parent
eb880c28
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/au/org/vicnode/mflux/services/SvcUserRcpUsrRoleSet.java
+12
-34
12 additions, 34 deletions
...a/au/org/vicnode/mflux/services/SvcUserRcpUsrRoleSet.java
with
12 additions
and
34 deletions
src/main/java/au/org/vicnode/mflux/services/SvcUserRcpUsrRoleSet.java
+
12
−
34
View file @
6cd07c97
...
...
@@ -36,10 +36,6 @@ public class SvcUserRcpUsrRoleSet extends PluginService {
public
SvcUserRcpUsrRoleSet
()
throws
Throwable
{
_defn
=
new
Interface
();
_defn
.
add
(
new
Interface
.
Element
(
"rcp-url"
,
StringType
.
DEFAULT
,
"Url for the rcp api"
,
1
,
1
));
_defn
.
add
(
new
Interface
.
Element
(
"api-key"
,
StringType
.
DEFAULT
,
"Api key to access rcp api"
,
1
,
1
));
}
public
Access
access
()
{
...
...
@@ -62,16 +58,12 @@ public class SvcUserRcpUsrRoleSet extends PluginService {
public
void
execute
(
XmlDoc
.
Element
args
,
Inputs
inputs
,
Outputs
outputs
,
final
XmlWriter
w
)
throws
Throwable
{
removeRCPUsrRole
();
String
rcpUrl
=
args
.
stringValue
(
"rcp-url"
);
String
api_key
=
args
.
stringValue
(
"api-key"
);
String
response
=
getRcpUsers
(
rcpUrl
,
api_key
);
Collection
<
XmlDoc
.
Element
>
response
=
getRcpUsers
();
//w.add("rcpusers",response);
JSONObject
jsonObject
=
new
JSONObject
(
response
);
for
(
Iterator
<
String
>
it
=
jsonObject
.
keys
();
it
.
hasNext
();
)
{
JSONObject
j
=
jsonObject
.
getJSONObject
(
it
.
next
());
String
path
=
j
.
getString
(
"path"
);
String
rcao
=
j
.
getString
(
"rcao"
);
Collection
<
String
>
users
=
getStringListFromJsonArray
(
j
.
getJSONArray
(
"users_with_manage_resources_permission"
));
for
(
XmlDoc
.
Element
element
:
response
)
{
String
path
=
element
.
value
(
"path"
);
String
rcao
=
element
.
value
(
"rcao"
);
Collection
<
String
>
users
=
element
.
values
(
"users-with-manage-resources-permission/user"
);
users
.
add
(
rcao
);
String
projectRole
=
Project
.
actualRoleName
(
path
,
Project
.
ProjectRoleType
.
RCPUSR
);
for
(
String
userEmail
:
users
)
{
...
...
@@ -135,31 +127,17 @@ public class SvcUserRcpUsrRoleSet extends PluginService {
}
}
public
Collection
<
String
>
getStringListFromJsonArray
(
JSONArray
array
){
Collection
<
String
>
list
=
new
ArrayList
<
String
>();
for
(
int
i
=
0
;
i
<
array
.
length
();
i
++)
{
String
s
=
array
.
getString
(
i
);
list
.
add
(
s
);
}
return
list
;
}
public
String
getRcpUsers
(
String
rcpUrl
,
String
apiKey
)
throws
IOException
,
InterruptedException
{
//https://rcp.research.unimelb.edu.au/data_resources/get_users_access/mediaflux
URL
url
=
new
URL
(
rcpUrl
);
HttpURLConnection
httpConn
=
(
HttpURLConnection
)
url
.
openConnection
();
httpConn
.
setRequestMethod
(
"GET"
);
httpConn
.
setRequestProperty
(
"Authorization"
,
"Api-Key "
+
apiKey
);
public
Collection
<
XmlDoc
.
Element
>
getRcpUsers
()
throws
Throwable
{
//unimelb.rcp.allocation.users.list :product mediaflux
XmlDocMaker
dm
=
new
XmlDocMaker
(
"args"
);
dm
.
add
(
"product"
,
"mediaflux"
);
InputStream
responseStream
=
httpConn
.
getResponseCode
()
/
100
==
2
?
httpConn
.
getInputStream
()
:
httpConn
.
getErrorStream
();
Scanner
s
=
new
Scanner
(
responseStream
).
useDelimiter
(
"\\A"
);
String
response
=
s
.
hasNext
()
?
s
.
next
()
:
""
;
XmlDoc
.
Element
r
=
executor
().
execute
(
"unimelb.rcp.allocation.users.list"
,
dm
.
root
());
Collection
<
XmlDoc
.
Element
>
allocations
=
r
.
elements
(
"allocation"
);
return
resp
ons
e
;
return
allocati
ons
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment