Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ docs/_build/
.idea
.project
.classpath
.settings/
bin/
*.bak
.gradle
ajcore.*.txt
**/WebContent/WEB-INF/application.properties
**/WebContent/WEB-INF/version

Expand Down
2 changes: 2 additions & 0 deletions components/java/racm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/lib/
/WebContent/WEB-INF/classes/
39 changes: 39 additions & 0 deletions components/java/racm/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# RACM Component

## Code Style
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much of this file is generic either the repo as a whole or the java projects within. Perhaps it is prudent to place much of it at a higher level in the repo sooner rather than later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, but let's discuss our GenAI usage and how it is reflected in the code base in general.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is probably best for this PR to leave the CLAUDE.md file here and later when working in the larger context to add a file there and maybe move some of the current content up.

- Java 17 project
- ALWAYS use Gradle for package dependencies and managing the environment
- Always use SIMPLEST code and structure, don't over-engineer
- Don't create unnecessary files. When creating new version of a file, archive or delete the legacy file
- DO NOT ADD UNNECESSARY FEATURES! Keep code simple

## Building
- Gradle root is at `components/java/` (where `settings.gradle` lives)
- Build racm and deps: `cd components/java && ./gradlew :racm:modelJar && ./gradlew :racm:build`
- RACM's `build.gradle` excludes `spring-boot-starter-logging` to avoid log4j bridge conflicts

## Eclipse Setup
- Import as Gradle project from `components/java/` — creates separate projects per subproject
- Buildship prefs `connection.project.dir` must point to the Gradle root (`..` for depth-1, `../..` for depth-2 subprojects)
- Do NOT use the legacy flat `.classpath` at root (renamed to `.classpath.bak`)

## Debugging in Eclipse
- Run/debug `org.sciserver.springapp.RACMApplication` as Java Application
- Requires two `-javaagent` VM arguments in Debug Configuration:
- `-javaagent:<path>/aspectjweaver-1.9.22.1.jar` (AspectJ load-time weaving, found in Gradle cache)
- `-javaagent:<path>/spring-instrument-<version>.jar` (Spring classloader instrumentation, stored in `racm/lib/`; version should match Spring Framework)
- The `lib/` folder is gitignored and holds JARs needed only for local Eclipse debugging
- Without these agents, `@EnableLoadTimeWeaving` and EclipseLink entity enhancement will fail

## Configuration
- `application.properties` consolidates all config for local development (server, login, admin, DB, URLs, etc.)
- `jpa-config.properties` is loaded separately by EclipseLink via `RACMDatabaseConfiguration`
- `persistence.xml` lists all JPA entity classes
- In production, Helm generates `racm-application.yaml` with all config (see `helm/sciserver/files/racm-application.yaml`)

## Key Architecture
- Spring Boot with EclipseLink JPA (not Hibernate)
- AspectJ for `@Transactional` support (`AdviceMode.ASPECTJ`)
- SQL Server database
- Auth: header, cookie, and query param filters via Spring Security
- Depends on: `springutils:logging-interceptor`, `springutils:authenticator`, `clients:auth`
90 changes: 90 additions & 0 deletions components/java/racm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# RACM - Resource Access Control Manager

RACM is the central authorization and resource management service for SciServer.
It manages users, groups, resources, access control, compute jobs, and storage.

## Building

```sh
cd components/java
./gradlew :racm:modelJar && ./gradlew :racm:build
```

## Running Locally

RACM can be run locally via the Spring Boot main class
`org.sciserver.springapp.RACMApplication`. This starts an embedded Tomcat server
without needing an external servlet container.

### Prerequisites

- Java 17 JDK
- SQL Server with a `racm` database
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could supply more information on this (e.g. version requirements, how to start one in docker), or we can add a reference to the relevant place in the helm chart to look

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the database could also be named differently as long as it is properly set in the config file(s)

- Two Java agent JARs (required by AspectJ load-time weaving and EclipseLink):
- `aspectjweaver-1.9.22.1.jar` (available in Gradle cache after building)
- `spring-instrument.jar` (download from Maven Central, store in `racm/lib/` which is gitignored; version should match the Spring Framework version used by the project)

### Configuration

Create `src/main/resources/application.properties` (gitignored) with your local
configuration. Use `helm/sciserver/files/racm-application.yaml` as a reference
for all available properties. At minimum you need:

```properties
spring.application.name=racm
server.servlet.context-path=/racm
spring.mvc.pathmatch.matching-strategy=ant-path-matcher

spring.datasource.url=jdbc:sqlserver://localhost;DatabaseName=RACM
spring.datasource.username=racm_user
spring.datasource.password=<your-password>

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
spring.main.allow-circular-references=true
spring.flyway.enabled=false

eclipselink.logging.level=WARNING

org.sciserver.racm.login.loginPortalUrl=http://localhost:8080/login-portal/
org.sciserver.racm.login.login-admin.username=admin
org.sciserver.racm.login.login-admin.password=<password>

org.sciserver.racm.admin.username=__racm__
org.sciserver.racm.admin.password=<password>
org.sciserver.racm.admin.email=racm@do.not.send
```

### JVM Arguments

Both Java agents must be passed as VM arguments when launching:

```
-javaagent:<path-to>/aspectjweaver-1.9.22.1.jar
-javaagent:<path-to>/racm/lib/spring-instrument-<version>.jar
```

Without these, `@EnableLoadTimeWeaving` and EclipseLink entity enhancement will
fail on startup.

### Verifying

The app starts on `http://localhost:8080/racm/`. Example endpoints:
- `GET /racm/ugm/rest/publicgroups` — list public groups
- `GET /racm/actuator/health` — health check

### Eclipse Setup

To debug in Eclipse:

1. **File > Import > Gradle > Existing Gradle Project**, browse to `components/java/`
2. Right-click `RACMApplication.java` in the `sciserver-java-racm` project > **Debug As > Java Application**
3. In **Run > Debug Configurations > Arguments > VM arguments**, add both `-javaagent` entries above

## Notes

- `jpa-config.properties` is loaded separately by EclipseLink via `RACMDatabaseConfiguration`
- External services (Login Portal, File Service, Logging) may not be available
locally — the app will start but those features won't work
- The `aop.xml` excludes `org.springframework.boot.jdbc` from AspectJ weaving
to avoid Oracle DataSource class errors
1 change: 1 addition & 0 deletions components/java/racm/src/main/resources/META-INF/aop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<!-- weave only our code, vourp, and spring framework -->
<include within="org.springframework..*"/>
<exclude within="org.springframework.boot.liquibase.*"/>
<exclude within="org.springframework.boot.jdbc..*"/>
<include within="org.ivoa..*"/>
<include within="org.sciserver.racm..*"/>
<include within="vourp..*"/>
Expand Down
4 changes: 3 additions & 1 deletion components/java/springutils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ subprojects {
}

dependencies {
api 'org.springframework.boot:spring-boot-starter-web:2.6.6'
api('org.springframework.boot:spring-boot-starter-web:2.6.6') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
Comment on lines +13 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this better belongs in the racm gradle file, similar to that of fileservice. However if there is another reason to do it here due to eclipse, we probably want to create an issue to track a resolution

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to homogenize how logging is done anyway I think? so an issue is in order.
This is still a draft and let's have some further discussion how to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd like to take the current solution, issue an issue and move towards updating the logging of racm.

implementation 'org.springdoc:springdoc-openapi-ui:1.6.6'
api project(':logging')
testImplementation 'org.testng:testng:6.14.3'
Expand Down