Skip to content

Commit

Permalink
add google code format
Browse files Browse the repository at this point in the history
  • Loading branch information
swaroopar committed Dec 11, 2024
1 parent 13c3ee7 commit 2a99017
Show file tree
Hide file tree
Showing 921 changed files with 22,548 additions and 20,769 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
uses: opentofu/[email protected]
with:
tofu_version: 1.6.1
- name: Format check
run: mvn spotless:check && mvn checkstyle:check
- name: Build
run: mvn --batch-mode --update-snapshots --no-transfer-progress verify
- name: Generate API doc
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Code of Conduct

Code of conduct for Xpanse projects are documented on our
website [here](https://eclipse.dev/xpanse/docs/Contribute/code-of-conduct).
website [here](https://eclipse.dev/xpanse/docs/Contribute/code-of-conduct).
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributing

Contributing guidelines for Xpanse projects are documented on our
website [here](https://eclipse.dev/xpanse/docs/Contribute/new-developers).
website [here](https://eclipse.dev/xpanse/docs/Contribute/new-developers).
58 changes: 37 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
![Xpanse logo](static/full-logo.png)
<p align='center'>
<a href="https://github.com/eclipse-xpanse/xpanse/actions/workflows/ci.yml" target="_blank">
<img src="https://github.com/eclipse-xpanse/xpanse/actions/workflows/ci.yml/badge.svg" alt="build">
<img src="https://github.com/eclipse-xpanse/xpanse/actions/workflows/ci.yml/badge.svg" alt="build">
</a>

<a href="https://github.com/eclipse-xpanse/xpanse/actions/workflows/coverage.yml" target="_blank">
<img src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/eclipse-xpanse-bot/3d9c022b98734fbf615c21136abe4add/raw/xpanse-coverage.json" alt="coverage">
</a>
<a href="https://github.com/eclipse-xpanse/xpanse/actions/workflows/coverage.yml" target="_blank">
<img src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/eclipse-xpanse-bot/3d9c022b98734fbf615c21136abe4add/raw/xpanse-coverage.json" alt="coverage">
</a>

<a href="https://opensource.org/licenses/Apache-2.0" target="_blank">
<img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="coverage">
</a>
<img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="coverage">
</a>
</p>

Xpanse is an Open Source project allowing to easily implement native-managed service on any cloud service provider. This
Expand All @@ -36,43 +36,43 @@ Details can be found on the project website [here](https://eclipse.dev/xpanse/do
## Generate terraform-boot client code

1. Run the terraform-boot project with spring-profile `oauth` with methods mentioned here.
This is necessary even if the terraform-boot will be actually used without oauth enabled in production.
This will make the client to handle both with and without authentication usecases automatically.
This is necessary even if the terraform-boot will be actually used without oauth enabled in production.
This will make the client to handle both with and without authentication usecases automatically.
2. Access http://localhost:9090/v3/api-docs to get the openapi json.
3. Copy all the JSON content of the openapi json and replace all the content in the JSON file
[terraform-boot-openapi.json](modules/deployment/src/main/resources/terraform-boot-openapi.json).
[terraform-boot-openapi.json](modules/deployment/src/main/resources/terraform-boot-openapi.json).
4. Run the below maven command to generate the REST API client and data models for terraform-boot. The command can be
executed directly inside the `deployment` module.
executed directly inside the `deployment` module.

```ssh
mvn clean generate-sources -DskipTerraformBootClientGeneration=false
mvn clean generate-sources -DskipTerraformBootClientGeneration=false
```

## Generate tofu-maker client code

1. Run the tofu-maker project with spring-profile `oauth` with methods mentioned here.
This is necessary even if the tofu-maker will be actually used without oauth enabled in production.
This will make the client to handle both with and without authentication usecases automatically.
This is necessary even if the tofu-maker will be actually used without oauth enabled in production.
This will make the client to handle both with and without authentication usecases automatically.
2. Access http://localhost:9092/v3/api-docs to get the openapi json.
3. Copy all the JSON content of the openapi json and replace all the content in the JSON file
[tofu-maker-openapi.json](modules/deployment/src/main/resources/tofu-maker-openapi.json).
4. Run the below maven command to generate the REST API client and data models for tofu-maker. The
command can be executed directly inside the `deployment` module.
[tofu-maker-openapi.json](modules/deployment/src/main/resources/tofu-maker-openapi.json).
4. Run the below maven command to generate the REST API client and data models for tofu-maker. The
command can be executed directly inside the `deployment` module.

```ssh
mvn clean generate-sources -DskipTofuMakerClientGeneration=false
mvn clean generate-sources -DskipTofuMakerClientGeneration=false
```

## Generate policy-man client code

1. Run the policy-man project and access “http://localhost:8090/swagger/doc.json” to get the openapi json.
2. Copy all the JSON content of the openapi json and replace all the content in the JSON file
[policy-man-openapi.json](modules/policy/src/main/resources/policy-man-openapi.json)
[policy-man-openapi.json](modules/policy/src/main/resources/policy-man-openapi.json)
3. Run the below maven command to generate the REST API client and data models for policy-man. The command can be
executed directly inside the `policy` module.
executed directly inside the `policy` module.

```ssh
mvn clean generate-sources -DskipPolicyManClientGeneration=false
mvn clean generate-sources -DskipPolicyManClientGeneration=false
```

## Static Code Analysis using CheckStyle
Expand All @@ -99,7 +99,7 @@ credential management, sensitive variable information during service deployment,

* For local development, the AES private key file must exist in the project root path.
* For environments where the application jar is directly executed, The Aes key file (aes_sec) must be
in the same directory as the project jar file (xpanse-runtime-x.x.x-SNAPSHOT.jar)
in the same directory as the project jar file (xpanse-runtime-x.x.x-SNAPSHOT.jar)

#### Generate AES Private Key

Expand All @@ -117,3 +117,19 @@ the JVM.
## Dependencies File

All third-party related content is listed in the [DEPENDENCIES](DEPENDENCIES) file.

## Code Formatter

The project follows [google-code-format](https://github.com/google/google-java-format).
We use the [spotless plugin](https://github.com/diffplug/spotless/tree/main/plugin-maven#google-java-format) to format code and to validate code format.
We can automatically format the code using the command below.

```shell
mvn spotless:apply
```

To validate errors we can run the command below.

```shell
mvn spotless:check && mvn checkstyle:check
```
35 changes: 0 additions & 35 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@
<property name="eachLine" value="true"/>
</module>

<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="100"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>

<module name="SuppressWithPlainTextCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE OFF\: ([\w\|]+)"/>
<property name="onCommentFormat" value="CHECKSTYLE ON\: ([\w\|]+)"/>
Expand Down Expand Up @@ -103,27 +97,6 @@
or preceding-sibling::*[last()][self::LCURLY]]"/>
</module>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyLambdas" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
<property name="ignoreEnhancedForColon" value="false"/>
<property name="tokens"
value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR,
BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT, LAMBDA, LAND,
LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY,
LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED,
LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN,
NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR,
SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND"/>
<message key="ws.notFollowed"
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks
may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
<message key="ws.notPreceded"
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
</module>
<module name="OneStatementPerLine"/>
<module name="MultipleVariableDeclarations"/>
<module name="ArrayTypeStyle"/>
Expand Down Expand Up @@ -280,13 +253,6 @@
METHOD_DEF, QUESTION, RESOURCE_SPECIFICATION, SUPER_CTOR_CALL, LAMBDA,
RECORD_DEF"/>
</module>
<module name="OperatorWrap">
<property name="option" value="NL"/>
<property name="tokens"
value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR,
LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR, METHOD_REF,
TYPE_EXTENSION_AND "/>
</module>
<module name="AnnotationLocation">
<property name="id" value="AnnotationLocationMostCases"/>
<property name="tokens"
Expand Down Expand Up @@ -395,7 +361,6 @@
<module name="MethodParamPad"/>
<module name="NoWhitespaceBefore"/>
<module name="NoWhitespaceAfter"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,28 @@

package org.eclipse.xpanse.api.config;


import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Get custom annotations for csp information.
*/
/** Get custom annotations for csp information. */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface AuditApiRequest {

/**
* The class of the method can get csp info.
*/
/** The class of the method can get csp info. */
Class<?> clazz() default GetCspInfoFromRequest.class;

/**
* The method name can get csp info.
*/
/** The method name can get csp info. */
String methodName() default "";

/**
* The param types of the method can get csp info.
*/
/** The param types of the method can get csp info. */
Class<?>[] paramTypes() default {String.class};

/**
* The index of params can be used to get csp info with the method.
*/
/** The index of params can be used to get csp info with the method. */
int[] paramIndexes() default {0};

/**
* Identifies whether csp can be obtained directly.
*/
/** Identifies whether csp can be obtained directly. */
boolean enabled() default true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,21 @@
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
* Writer for audit logs.
*/
/** Writer for audit logs. */
@Slf4j
@Aspect
@Component
public class AuditLogWriter {

private static final String DEFAULT_GET_CSP_METHOD_NAME = "getCspFromRequestUri";

@Resource
private PluginManager pluginManager;
@Resource
private UserServiceHelper userServiceHelper;
@Resource
private GetCspInfoFromRequest getCspInfoFromRequest;
@Resource private PluginManager pluginManager;
@Resource private UserServiceHelper userServiceHelper;
@Resource private GetCspInfoFromRequest getCspInfoFromRequest;

/**
* Pointcut for all controller methods.
*/
/** Pointcut for all controller methods. */
@Pointcut("execution(* org.eclipse.xpanse.api.controllers.*.*(..))")
public void controllerMethods() {
}
public void controllerMethods() {}

/**
* Validate request parameters.
Expand All @@ -71,8 +63,12 @@ public Object auditRequest(ProceedingJoinPoint joinPoint) throws Throwable {
.getRequest();
OrchestratorPlugin orchestratorPlugin = pluginManager.getOrchestratorPlugin(csp);
orchestratorPlugin.auditApiRequest(
getAuditLog(csp, joinPoint.getSignature().getName(), request,
joinPoint.getArgs(), result));
getAuditLog(
csp,
joinPoint.getSignature().getName(),
request,
joinPoint.getArgs(),
result));
}
return result;
}
Expand Down Expand Up @@ -134,9 +130,8 @@ private Csp getCspFromRequestParams(Object[] args) {
return null;
}

private AuditLog getAuditLog(Csp csp, String methodName, HttpServletRequest request,
Object[] args,
Object result) {
private AuditLog getAuditLog(
Csp csp, String methodName, HttpServletRequest request, Object[] args, Object result) {
AuditLog auditLog = new AuditLog();
auditLog.setMethodName(methodName);
auditLog.setMethodType(request.getMethod());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
* Bean for serializing string in request parameters to BillingMode enum.
*/
/** Bean for serializing string in request parameters to BillingMode enum. */
@Component
public class BillingModeEnumConverter implements Converter<String, BillingMode> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
* Bean for serializing string in request parameters to Category enum.
*/
/** Bean for serializing string in request parameters to Category enum. */
@Component
public class CategoryEnumConverter implements Converter<String, Category> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
* Bean for serializing string in request parameters to CredentialType enum.
*/
/** Bean for serializing string in request parameters to CredentialType enum. */
@Component
public class CredentialTypeEnumConverter implements Converter<String, CredentialType> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
* Bean for serializing string in request parameters to Csp enum.
*/
/** Bean for serializing string in request parameters to Csp enum. */
@Component
public class CspEnumConverter implements Converter<String, Csp> {

Expand Down
Loading

0 comments on commit 2a99017

Please sign in to comment.