documentazione

This commit is contained in:
Alfredo Oliviero 2024-02-27 12:45:01 +01:00
parent c7f147d1c9
commit e64b19bddf
9 changed files with 136 additions and 56 deletions

2
.vscode/launch.json vendored
View File

@ -10,7 +10,7 @@
"projectName": "identity-manager", "projectName": "identity-manager",
"request": "attach", "request": "attach",
"hostName": "localhost", "hostName": "localhost",
"port": 5005 "port": 5001
} }
] ]
} }

View File

@ -1,3 +1,9 @@
{ {
"java.configuration.updateBuildConfiguration": "automatic" "java.configuration.updateBuildConfiguration": "automatic",
"Workspace_Formatter.excludePattern": [
"**/build",
"**/.*",
"**/.vscode",
"**/target/*"
]
} }

72
Instructions.md Normal file
View File

@ -0,0 +1,72 @@
# instructions
## project structure
├── .gitignore
├── pom.xml
├── src
│ └── ***
├── gcube/
│ └── extra-resources/
│ └── WEB-INF/
│ ├── application.yaml
│ └── web.xml
# optional, for local develop in docker containers
├── docker/
│ ├── ontainer.ini
│ └── logback.xml
├── docker-compose.yaml
└── Dockerfile
### file details
* gitignore: gitignore file for java projects
* pom.xml
* <parent>: maven-parent configuration. currently 1.2.0 version
* <properties><webappDirectory> : path for web.xml
* <scm> ???
* <dependencyManagement> gcube dependency manager
* docker/container.ini: configurations for the docker container.
* mode: [online/offline]: register the service on IS. use offline for local docker instances
# EXCECUTION
start the docker container
```./buildImageAndStart.sh```
test urls (replace {{TOKEN}} with your token):
http://localhost:8081/helloworld/guest
http://localhost:8080/helloworld/details?gcube-token={{TOKEN}}
http://localhost:8080/helloworld/hello/details?gcube-token={{TOKEN}}
http://localhost:8080/helloworld/auth?gcube-token={{TOKEN}} (checks for myRole role)
http://localhost:8080/helloworld/auth/orm_member?gcube-token={{TOKEN}} (checks for OrganizationMember role)
### Authentication:
#### GCUBE-TOKEN param
obtain personal token at https://next.dev.d4science.org/group/gcube/home
add
### DEBUG
start the docker container in debug Mode
```./buildImageAndStartWithDebug.sh```
connect the JAVA debugger to port 5005
* VSCODE: press the green play button and start "Debug (Attach)

View File

@ -14,40 +14,6 @@ HelloWorld service for smartgears4
## Documentation ## Documentation
start the docker container
```./buildImageAndStart.sh```
test urls (replace {{TOKEN}} with your token):
http://localhost:8080/helloworld/guest
http://localhost:8080/helloworld/details?gcube-token={{TOKEN}}
http://localhost:8080/helloworld/hello/details?gcube-token={{TOKEN}}
http://localhost:8080/helloworld/auth?gcube-token={{TOKEN}} (checks for myRole role)
http://localhost:8080/helloworld/auth/orm_member?gcube-token={{TOKEN}} (checks for OrganizationMember role)
### Authentication:
#### GCUBE-TOKEN param
obtain personal token at https://next.dev.d4science.org/group/gcube/home
add
### DEBUG
start the docker container in debug Mode
```./buildImageAndStartWithDebug.sh```
connect the JAVA debugger to port 5005
* VSCODE: press the green play button and start "Debug (Attach)
## Change log ## Change log
See [Releases](https://code-repo.d4science.org/gCubeSystem/helloworld/releases). See [Releases](https://code-repo.d4science.org/gCubeSystem/helloworld/releases).

View File

@ -1,3 +1,9 @@
mvn clean package mvn clean package
docker build -t smartgears-helloworld .
docker run -p 8080:8080 smartgears-helloworld NAME=smartgears-helloworld
PORT=8081
DEBUG_PORT=5001
docker build -t $NAME.
docker run -p $PORT:8080 --name $NAME $NAME

View File

@ -1,3 +1,8 @@
mvn package mvn clean package
docker build -t smartgears-helloworld .
docker run -p 8080:8080 -p 5005:5005 -e JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=y" smartgears-helloworld NAME=smartgears-helloworld
PORT=8081
DEBUG_PORT=5001
docker build -t $NAME .
docker run -p $PORT:8080 -p $DEBUG_PORT:5005 -e JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=y" $NAME

View File

@ -1,13 +1,11 @@
<configuration scan="true" debug="true"> <configuration scan="true" debug="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>Ï <encoder>Ï <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder> </encoder>
</appender> </appender>
<logger name="org.gcube.service.helloworld" level="DEBUG" /> <logger name="org.gcube.service.helloworld" level="DEBUG" />
<logger name="org.gcube.smartgears" level="DEBUG" /> <logger name="org.gcube.smartgears" level="DEBUG" />

View File

@ -311,7 +311,7 @@
"variable": [ "variable": [
{ {
"key": "base_url", "key": "base_url",
"value": "http://localhost:8080", "value": "http://localhost:8081",
"type": "string" "type": "string"
}, },
{ {

41
pom.xml
View File

@ -2,23 +2,30 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.gcube.tools</groupId>
<artifactId>maven-parent</artifactId>
<version>1.2.0</version>
</parent>
<groupId>org.gcube.service</groupId> <groupId>org.gcube.service</groupId>
<artifactId>helloworld</artifactId> <artifactId>helloworld</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<name>Smartgears HelloWorld Service</name> <name>Smartgears HelloWorld Service</name>
<packaging>war</packaging> <packaging>war</packaging>
<parent>
<groupId>org.gcube.tools</groupId>
<artifactId>maven-parent</artifactId>
<version>1.2.0</version>
</parent>
<properties> <properties>
<java.version>11</java.version> <java.version>11</java.version>
<aspectj-plugin.version>1.14.0</aspectj-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>${java.version}</maven.compiler.source> <maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target> <maven.compiler.target>${java.version}</maven.compiler.target>
<!-- OPTIONAL. for authorization-control-library -->
<aspectj-plugin.version>1.14.0</aspectj-plugin.version>
</properties> </properties>
<scm> <scm>
<connection> <connection>
scm:git:https://code-repo.d4science.org/gCubeSystem/hello-world-sg4-service.git</connection> scm:git:https://code-repo.d4science.org/gCubeSystem/hello-world-sg4-service.git</connection>
@ -26,6 +33,7 @@
scm:git:https://code-repo.d4science.org/gCubeSystem/hello-world-sg4-service.git</developerConnection> scm:git:https://code-repo.d4science.org/gCubeSystem/hello-world-sg4-service.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/hello-world-sg4-service.git</url> <url>https://code-repo.d4science.org/gCubeSystem/hello-world-sg4-service.git</url>
</scm> </scm>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
@ -37,6 +45,7 @@
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<dependencies> <dependencies>
<!-- smartgears --> <!-- smartgears -->
<dependency> <dependency>
@ -55,6 +64,7 @@
<groupId>org.gcube.core</groupId> <groupId>org.gcube.core</groupId>
<artifactId>common-smartgears-app</artifactId> <artifactId>common-smartgears-app</artifactId>
</dependency> </dependency>
<!-- jersey --> <!-- jersey -->
<dependency> <dependency>
<groupId>javax.ws.rs</groupId> <groupId>javax.ws.rs</groupId>
@ -64,6 +74,7 @@
<groupId>org.glassfish.jersey.containers</groupId> <groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId> <artifactId>jersey-container-servlet</artifactId>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.inject/jersey-cdi2-se --> <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.inject/jersey-cdi2-se -->
<dependency> <dependency>
<groupId>org.glassfish.jersey.inject</groupId> <groupId>org.glassfish.jersey.inject</groupId>
@ -74,6 +85,7 @@
<artifactId>javax.servlet-api</artifactId> <artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version> <version>3.0.1</version>
</dependency> </dependency>
<!-- add jackson as json provider --> <!-- add jackson as json provider -->
<dependency> <dependency>
<groupId>org.glassfish.jersey.media</groupId> <groupId>org.glassfish.jersey.media</groupId>
@ -84,10 +96,25 @@
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>${project.artifactId}</finalName> <finalName>${project.artifactId}</finalName>
<plugins> <plugins>
<!-- add this plugin if you want to use gcube authorization control funzionalities -->
<!-- OPTIONAL generate the war in a different folder, that will be mounted on docker
container -->
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>identity-manager</warName>
<outputDirectory>tomcat/webapps</outputDirectory>
</configuration>
</plugin> -->
<!-- OPTIONAL. authorization-control-library: add this plugin if you want to use gcube
authorization control funzionalities -->
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId> <artifactId>aspectj-maven-plugin</artifactId>