Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IA2
GMS
Commits
ae69e025
Commit
ae69e025
authored
Apr 24, 2020
by
Sonia Zorba
Browse files
Update on CLI; bugfix in CreateGroupCall; added workaround for invited registration trigger
parent
32687700
Changes
9
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
ae69e025
...
...
@@ -62,3 +62,5 @@ nbactions.xml
/gms/node/
nb-configuration.xml
dependency-reduced-pom.xml
gms-client/gms-cli/gms.properties
View file @
ae69e025
#base_url=http://localhost:8081/gms
#client_id=test
#client_secret=test
base_url
=
https://sso.ia2.inaf.it/gms
client_id
=
sso-admin
client_secret
=
cXjbauYe8g
base_url
=
http://localhost:8082/gms/ws/jwt
token
=
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjM0ZmU4MDcwMDVhNTcxMTYifQ.eyJpc3MiOiJzc28uaWEyLmluYWYuaXQiLCJzdWIiOiIyMzg2IiwiaWF0IjoxNTg3NjU5NzYxLCJleHAiOjE1ODc3NDYxNjEsImF1ZCI6ImdtcyJ9.KcXRAciG3ApqlE8MFM8VYW9WAX3hEZb7Vk8jB9uJtWsOMU48ha_Ybb4k_f0nrD2jhOxwaNn2QMxWZuflwCf1N-KiCj5Ff9f8xKOrrXZrl-w1H3_dwtMlIS8t2b0-w0WwRJ7UIhrwVBzmCcWinD3qJhFPzyO2pi-A4aXV57RpJ68VXfALQXeHK0sslrf-RgAU3xWYOgjGTUoGB5BQYC9huA_bZ0eV1HFcancs9pDdoTusqZs8OkPFCJbo7-L5eibsuykqnLHztYdCcP2Vtvtwb0pww-ofWZblIHzoMI8i-ipnfLJETG8Dpc7FrhjCYLw3AEGZg4U1wYTeqG3HRbPXSQ
gms-client/gms-cli/pom.xml
View file @
ae69e025
...
...
@@ -2,12 +2,6 @@
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.1.7.RELEASE
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>
it.inaf.ia2
</groupId>
<artifactId>
gms-cli
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
...
...
@@ -15,34 +9,40 @@
<description>
GMS Command Line Client
</description>
<properties>
<java.version>
1.8
</java.version>
<maven.compiler.source>
12
</maven.compiler.source>
<maven.compiler.target>
12
</maven.compiler.target>
<java.version>
12
</java.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
gms-client-lib
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-shade-plugin
</artifactId>
<version>
3.2.3
</version>
<executions>
<execution>
<phase>
package
</phase>
<goals>
<goal>
shade
</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation=
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"
>
<mainClass>
it.inaf.ia2.gms.cli.CLI
</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
gms-client/gms-cli/src/main/java/it/inaf/ia2/gms/cli/CLI.java
View file @
ae69e025
package
it.inaf.ia2.gms.cli
;
import
it.inaf.ia2.gms.client.GmsClient
;
import
it.inaf.ia2.gms.client.model.Permission
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Properties
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.stereotype.Component
;
@Component
public
class
CLI
implements
CommandLineRunner
{
public
class
CLI
{
private
final
GmsClient
client
;
public
CLI
()
throws
IOException
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
CLI
().
run
(
args
);
}
private
CLI
()
throws
IOException
{
File
config
=
new
File
(
"gms.properties"
);
if
(!
config
.
exists
())
{
...
...
@@ -35,22 +35,15 @@ public class CLI implements CommandLineRunner {
System
.
exit
(
1
);
}
String
clientId
=
(
String
)
properties
.
get
(
"client_id"
);
if
(
clientId
==
null
)
{
System
.
err
.
println
(
"Missing client_id in gms.properties"
);
System
.
exit
(
1
);
}
String
clientSecret
=
(
String
)
properties
.
get
(
"client_secret"
);
if
(
clientSecret
==
null
)
{
System
.
err
.
println
(
"Missing client_secret in gms.properties"
);
String
token
=
(
String
)
properties
.
get
(
"token"
);
if
(
token
==
null
)
{
System
.
err
.
println
(
"Missing token in gms.properties"
);
System
.
exit
(
1
);
}
client
=
new
GmsClient
(
baseUrl
,
clientId
,
clientSecret
);
client
=
new
GmsClient
(
baseUrl
).
setAccessToken
(
token
);
}
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
if
(
args
.
length
<
2
)
{
displayUsage
();
...
...
@@ -58,39 +51,43 @@ public class CLI implements CommandLineRunner {
switch
(
args
[
0
])
{
case
"create-group"
:
client
.
addGroup
(
getNames
(
args
,
1
));
boolean
leaf
=
false
;
if
(
args
.
length
>
1
)
{
leaf
=
Boolean
.
parseBoolean
(
args
[
2
]);
}
client
.
createGroup
(
args
[
1
],
leaf
);
System
.
out
.
println
(
"Group created"
);
break
;
case
"delete-group"
:
client
.
remov
eGroup
(
getNames
(
args
,
1
)
);
client
.
delet
eGroup
(
args
[
1
]
);
System
.
out
.
println
(
"Group deleted"
);
break
;
case
"add-member"
:
if
(
args
.
length
<
3
)
{
displayUsage
();
}
client
.
addMember
(
getNames
(
args
,
1
,
args
.
length
-
2
),
args
[
args
.
length
-
1
]);
client
.
addMember
(
args
[
1
]
,
args
[
2
]);
System
.
out
.
println
(
"Member added"
);
break
;
case
"remove-member"
:
if
(
args
.
length
<
3
)
{
displayUsage
();
}
client
.
removeMember
(
getNames
(
args
,
1
,
args
.
length
-
2
),
args
[
args
.
length
-
1
]);
client
.
removeMember
(
args
[
1
]
,
args
[
2
]);
System
.
out
.
println
(
"Member removed"
);
break
;
case
"add-permission"
:
if
(
args
.
length
<
4
)
{
displayUsage
();
}
client
.
addPermission
(
getNames
(
args
,
1
,
args
.
length
-
3
),
args
[
args
.
length
-
2
],
args
[
args
.
length
-
1
]
);
client
.
addPermission
(
args
[
1
]
,
args
[
2
],
Permission
.
valueOf
(
args
[
3
])
);
System
.
out
.
println
(
"Permission added"
);
break
;
case
"delete-permission"
:
if
(
args
.
length
<
4
)
{
displayUsage
();
}
client
.
removePermission
(
getNames
(
args
,
1
,
args
.
length
-
2
),
args
[
args
.
length
-
1
]);
client
.
removePermission
(
args
[
1
]
,
args
[
2
]);
System
.
out
.
println
(
"Permission removed"
);
break
;
default
:
...
...
@@ -101,24 +98,12 @@ public class CLI implements CommandLineRunner {
private
void
displayUsage
()
{
System
.
out
.
println
(
"java -jar gms-client.jar\n"
+
" create-group <name1
name2
name3>\n"
+
" delete-group <name1
name2
name3>\n"
+
" add-member <name1
name2
name3> <user_id>\n"
+
" remove-member <name1
name2
name3> <user_id>\n"
+
" add-permission <name1
name2
name3> <user_id> <permission>\n"
+
" delete-permission <name1
name2
name3> <user_id>"
);
+
" create-group <name1
.
name2
.
name3>
<leaf>
\n"
+
" delete-group <name1
.
name2
.
name3>\n"
+
" add-member <name1
.
name2
.
name3> <user_id>\n"
+
" remove-member <name1
.
name2
.
name3> <user_id>\n"
+
" add-permission <name1
.
name2
.
name3> <user_id> <permission>\n"
+
" delete-permission <name1
.
name2
.
name3> <user_id>"
);
System
.
exit
(
0
);
}
private
List
<
String
>
getNames
(
String
[]
args
,
int
startIndex
)
{
return
getNames
(
args
,
startIndex
,
args
.
length
-
1
);
}
private
List
<
String
>
getNames
(
String
[]
args
,
int
startIndex
,
int
endIndex
)
{
List
<
String
>
names
=
new
ArrayList
<>();
for
(
int
i
=
startIndex
;
i
<=
endIndex
;
i
++)
{
names
.
add
(
args
[
i
]);
}
return
names
;
}
}
gms-client/gms-cli/src/main/java/it/inaf/ia2/gms/cli/GmsCliApplication.java
deleted
100644 → 0
View file @
32687700
package
it.inaf.ia2.gms.cli
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@SpringBootApplication
public
class
GmsCliApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
GmsCliApplication
.
class
,
args
);
}
}
gms-client/gms-cli/src/test/java/it/inaf/ia2/gms/cli/GmsCliApplicationTests.java
deleted
100644 → 0
View file @
32687700
package
it.inaf.ia2.gms.cli
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
GmsCliApplicationTests
{
@Test
public
void
contextLoads
()
{
}
}
gms-client/gms-client-lib/src/main/java/it/inaf/ia2/gms/client/call/CreateGroupCall.java
View file @
ae69e025
...
...
@@ -14,6 +14,7 @@ public class CreateGroupCall extends BaseGmsCall {
HttpRequest
groupsRequest
=
newHttpRequest
(
completeGroupName
)
.
header
(
"Accept"
,
"text/plain"
)
.
header
(
"Content-Type"
,
"application/x-www-form-urlencoded"
)
.
POST
(
BodyPublishers
.
ofString
(
"leaf="
+
leaf
))
.
build
();
...
...
gms/src/main/java/it/inaf/ia2/gms/manager/InvitedRegistrationManager.java
View file @
ae69e025
...
...
@@ -110,6 +110,8 @@ public class InvitedRegistrationManager extends UserAwareComponent {
}
invitedRegistration
.
setUserId
(
getCurrentUserId
());
// FIXME (workaround): separated update for user and done in order to use triggers
invitedRegistrationDAO
.
setRegistrationUser
(
invitedRegistration
);
invitedRegistrationDAO
.
setRegistrationDone
(
invitedRegistration
);
httpSession
.
removeAttribute
(
INVITED_REGISTRATION
);
...
...
gms/src/main/java/it/inaf/ia2/gms/persistence/InvitedRegistrationDAO.java
View file @
ae69e025
...
...
@@ -92,9 +92,9 @@ public class InvitedRegistrationDAO {
return
Optional
.
ofNullable
(
registration
);
}
public
void
setRegistration
Done
(
InvitedRegistration
invitedRegistration
)
{
public
void
setRegistration
User
(
InvitedRegistration
invitedRegistration
)
{
String
sql
=
"UPDATE invited_registration_request SET \"user\" = ?
, done = true
WHERE id = ?"
;
String
sql
=
"UPDATE invited_registration_request SET \"user\" = ? WHERE id = ?"
;
jdbcTemplate
.
update
(
conn
->
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
...
...
@@ -103,4 +103,15 @@ public class InvitedRegistrationDAO {
return
ps
;
});
}
public
void
setRegistrationDone
(
InvitedRegistration
invitedRegistration
)
{
String
sql
=
"UPDATE invited_registration_request SET done = true WHERE id = ?"
;
jdbcTemplate
.
update
(
conn
->
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
invitedRegistration
.
getId
());
return
ps
;
});
}
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment