Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

public class BootstrAPI {

public static final String ALL = "all";
public static final String _ALL = "_all";

Check failure on line 5 in commons/src/main/java/com/deftdevs/bootstrapi/commons/constants/BootstrAPI.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.

See more on https://sonarcloud.io/project/issues?id=deftdevs_bootstrapi&issues=AZ4-8usFsVWpy8fCo6T5&open=AZ4-8usFsVWpy8fCo6T5&pullRequest=222
public static final String _ROOT = "/";

Check failure on line 6 in commons/src/main/java/com/deftdevs/bootstrapi/commons/constants/BootstrAPI.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.

See more on https://sonarcloud.io/project/issues?id=deftdevs_bootstrapi&issues=AZ4-8usFsVWpy8fCo6T6&open=AZ4-8usFsVWpy8fCo6T6&pullRequest=222

public static final String APPLICATION = "application";
public static final String APPLICATIONS = "applications";
public static final String APPLICATION_LINK = "application-link";
Expand Down Expand Up @@ -38,20 +40,24 @@
public static final String MAIL_SERVERS = "mail-servers";
public static final String MAIL_SERVER_POP = "pop";
public static final String MAIL_SERVER_SMTP = "smtp";
public static final String MAIL_TEMPLATES = "mail-templates";
public static final String PERMISSION = "permission";
public static final String PERMISSIONS = "permissions";
public static final String PERMISSION_ANONYMOUS_ACCESS = "anonymous-access";
public static final String PERMISSIONS_GLOBAL = "global";
public static final String PING = "ping";
public static final String SESSION_CONFIG = "session-config";
public static final String SETTINGS = "settings";
public static final String SETTINGS_BANNER = "banner";
public static final String SETTINGS_BRANDING = "branding";
public static final String SETTINGS_BRANDING_LOGIN_PAGE = "login-page";
public static final String SETTINGS_BRANDING_LOGO = "logo";
public static final String SETTINGS_CUSTOM_HTML = "custom-html";
public static final String SETTINGS_GENERAL = "general";
public static final String SETTINGS_SECURITY = "security";
public static final String USER = "user";
public static final String USERS = "users";
public static final String TRUSTED_PROXIES = "trusted-proxies";
public static final String USER_PASSWORD = "password";

public static final String MEDIA_TYPE_IMAGE = "image/*";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.deftdevs.bootstrapi.commons.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Map;

import static com.deftdevs.bootstrapi.commons.constants.BootstrAPI.AUTHENTICATION;

@Data
@NoArgsConstructor
@AllArgsConstructor
@XmlRootElement(name = AUTHENTICATION)
public class AuthenticationModel {

@XmlElement
private Map<String, AbstractAuthenticationIdpModel> idps;

@XmlElement
private AuthenticationSsoModel sso;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.deftdevs.bootstrapi.commons.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import static com.deftdevs.bootstrapi.commons.constants.BootstrAPI.MAIL_SERVER;

@Data
@NoArgsConstructor
@AllArgsConstructor
@XmlRootElement(name = MAIL_SERVER)
public class MailServerModel {

@XmlElement
private MailServerSmtpModel smtp;

@XmlElement
private MailServerPopModel pop;

// Example instances for documentation and tests

public static final MailServerModel EXAMPLE_1 = new MailServerModel(
MailServerSmtpModel.EXAMPLE_1,
MailServerPopModel.EXAMPLE_1
);

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
@XmlRootElement(name = SETTINGS + "-" + SETTINGS_BRANDING + "-" + COLOR_SCHEME)
@XmlRootElement(name = SETTINGS + "-" + SETTINGS_BRANDING)
@XmlAccessorType(XmlAccessType.FIELD)
public class SettingsBrandingColorSchemeModel {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.deftdevs.bootstrapi.commons.model;

import com.deftdevs.bootstrapi.commons.constants.BootstrAPI;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Builder;
Expand All @@ -13,13 +12,16 @@
import javax.xml.bind.annotation.XmlRootElement;
import java.net.URI;

import static com.deftdevs.bootstrapi.commons.constants.BootstrAPI.SETTINGS;
import static com.deftdevs.bootstrapi.commons.constants.BootstrAPI.SETTINGS_GENERAL;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@XmlRootElement(name = BootstrAPI.SETTINGS)
@XmlRootElement(name = SETTINGS + "-" + SETTINGS_GENERAL)
@XmlAccessorType(XmlAccessType.FIELD)
public class SettingsModel {
public class SettingsGeneralModel {

@XmlElement
private URI baseUrl;
Expand All @@ -46,15 +48,15 @@ public String getMode() {

// Example instances for documentation and tests

public static final SettingsModel EXAMPLE_1 = SettingsModel.builder()
public static final SettingsGeneralModel EXAMPLE_1 = SettingsGeneralModel.builder()
.title("Example")
.baseUrl(URI.create("https://example.com"))
.mode("private")
.contactMessage("Test Message")
.externalUserManagement(true)
.build();

public static final SettingsModel EXAMPLE_1_NO_MODE = SettingsModel.builder()
public static final SettingsGeneralModel EXAMPLE_1_NO_MODE = SettingsGeneralModel.builder()
.title("Example")
.baseUrl(URI.create("https://example.com"))
.mode(null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.deftdevs.bootstrapi.commons.model.type;

import java.util.Map;

public interface _AllModelAccessor {

Check warning on line 5 in commons/src/main/java/com/deftdevs/bootstrapi/commons/model/type/_AllModelAccessor.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this interface name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=deftdevs_bootstrapi&issues=AZ4-8urpsVWpy8fCo6T3&open=AZ4-8urpsVWpy8fCo6T3&pullRequest=222

Map<String, _AllModelStatus> getStatus();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.deftdevs.bootstrapi.commons.model.type;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.ws.rs.core.Response;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@Data
@NoArgsConstructor
@AllArgsConstructor
@XmlRootElement(name = "status")
public class _AllModelStatus {

Check warning on line 15 in commons/src/main/java/com/deftdevs/bootstrapi/commons/model/type/_AllModelStatus.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this class name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=deftdevs_bootstrapi&issues=AZ4-8urdsVWpy8fCo6T2&open=AZ4-8urdsVWpy8fCo6T2&pullRequest=222

@XmlElement
private int status;

@XmlElement
private String message;

@XmlElement
private String details;

public static _AllModelStatus success() {
return new _AllModelStatus(Response.Status.OK.getStatusCode(), "Success", null);
}

public static _AllModelStatus error(Response.Status status, String message, String details) {
return new _AllModelStatus(status.getStatusCode(), message, details);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.deftdevs.bootstrapi.commons.rest;

import com.deftdevs.bootstrapi.commons.model.SettingsGeneralModel;
import com.deftdevs.bootstrapi.commons.rest.api.SettingsGeneralResource;
import com.deftdevs.bootstrapi.commons.service.api.SettingsGeneralService;

import javax.ws.rs.core.Response;

public abstract class AbstractSettingsGeneralResourceImpl<B extends SettingsGeneralModel, S extends SettingsGeneralService<B>>
implements SettingsGeneralResource<B> {

private final S settingsService;

public AbstractSettingsGeneralResourceImpl(

Check warning on line 14 in commons/src/main/java/com/deftdevs/bootstrapi/commons/rest/AbstractSettingsGeneralResourceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Change the visibility of this constructor to "protected".

See more on https://sonarcloud.io/project/issues?id=deftdevs_bootstrapi&issues=AZ4-8urWsVWpy8fCo6T1&open=AZ4-8urWsVWpy8fCo6T1&pullRequest=222
final S settingsService) {

this.settingsService = settingsService;
}

@Override
public Response getSettings() {
final B settingsModel = settingsService.getSettingsGeneral();
return Response.ok(settingsModel).build();
}

@Override
public Response setSettings(B settingsModel) {
final B updatedSettingsGeneralModel = settingsService.setSettingsGeneral(settingsModel);
return Response.ok(updatedSettingsGeneralModel).build();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.deftdevs.bootstrapi.commons.rest;

import com.deftdevs.bootstrapi.commons.model.type._AllModelAccessor;
import com.deftdevs.bootstrapi.commons.model.type._AllModelStatus;
import com.deftdevs.bootstrapi.commons.rest.api._AllResource;
import com.deftdevs.bootstrapi.commons.service.api._AllService;

import javax.ws.rs.core.Response;
import java.util.Map;

public abstract class _AbstractAllResourceImpl<_AllModel extends _AllModelAccessor>

Check warning on line 11 in commons/src/main/java/com/deftdevs/bootstrapi/commons/rest/_AbstractAllResourceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this class name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=deftdevs_bootstrapi&issues=AZ4-8urOsVWpy8fCo6Ty&open=AZ4-8urOsVWpy8fCo6Ty&pullRequest=222

Check warning on line 11 in commons/src/main/java/com/deftdevs/bootstrapi/commons/rest/_AbstractAllResourceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this generic name to match the regular expression '^[A-Z][0-9]?$'.

See more on https://sonarcloud.io/project/issues?id=deftdevs_bootstrapi&issues=AZ4-8urOsVWpy8fCo6T0&open=AZ4-8urOsVWpy8fCo6T0&pullRequest=222
implements _AllResource<_AllModel> {

private final _AllService<_AllModel> allService;

public _AbstractAllResourceImpl(

Check warning on line 16 in commons/src/main/java/com/deftdevs/bootstrapi/commons/rest/_AbstractAllResourceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Change the visibility of this constructor to "protected".

See more on https://sonarcloud.io/project/issues?id=deftdevs_bootstrapi&issues=AZ4-8urOsVWpy8fCo6Tz&open=AZ4-8urOsVWpy8fCo6Tz&pullRequest=222
final _AllService<_AllModel> allService) {

this.allService = allService;
}

public Response setAll(
final _AllModel allModel) {

final _AllModel result = allService.setAll(allModel);
final int overallStatus = computeOverallStatus(result.getStatus());
return Response.status(overallStatus).entity(result).build();
}

private static int computeOverallStatus(
final Map<String, _AllModelStatus> statusMap) {

if (statusMap == null || statusMap.isEmpty()) {
return Response.Status.OK.getStatusCode();
}

return statusMap.values().stream()
.mapToInt(_AllModelStatus::getStatus)
.max()
.orElse(Response.Status.OK.getStatusCode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.deftdevs.bootstrapi.commons.constants.BootstrAPI;
import com.deftdevs.bootstrapi.commons.model.ErrorCollection;
import com.deftdevs.bootstrapi.commons.model.SettingsModel;
import com.deftdevs.bootstrapi.commons.model.SettingsGeneralModel;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
Expand All @@ -12,14 +12,14 @@
import javax.ws.rs.PUT;
import javax.ws.rs.core.Response;

public interface SettingsResource<B extends SettingsModel> {
public interface SettingsGeneralResource<B extends SettingsGeneralModel> {

@GET
@Operation(
summary = BootstrAPI.SETTINGS_GENERAL_GET_SUMMARY,
responses = {
@ApiResponse(
responseCode = "200", content = @Content(schema = @Schema(implementation = SettingsModel.class)),
responseCode = "200", content = @Content(schema = @Schema(implementation = SettingsGeneralModel.class)),
description = BootstrAPI.SETTINGS_GENERAL_GET_RESPONSE_DESCRIPTION
),
@ApiResponse(
Expand All @@ -35,7 +35,7 @@ public interface SettingsResource<B extends SettingsModel> {
summary = BootstrAPI.SETTINGS_GENERAL_PUT_SUMMARY,
responses = {
@ApiResponse(
responseCode = "200", content = @Content(schema = @Schema(implementation = SettingsModel.class)),
responseCode = "200", content = @Content(schema = @Schema(implementation = SettingsGeneralModel.class)),
description = BootstrAPI.SETTINGS_GENERAL_PUT_RESPONSE_DESCRIPTION
),
@ApiResponse(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.deftdevs.bootstrapi.commons.rest.api;

import com.deftdevs.bootstrapi.commons.constants.BootstrAPI;
import com.deftdevs.bootstrapi.commons.model.ErrorCollection;
import com.deftdevs.bootstrapi.commons.model.type._AllModelAccessor;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;

import javax.validation.constraints.NotNull;
import javax.ws.rs.PUT;
import javax.ws.rs.core.Response;

public interface _AllResource<_AllModel extends _AllModelAccessor> {

Check warning on line 15 in commons/src/main/java/com/deftdevs/bootstrapi/commons/rest/api/_AllResource.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this interface name to match the regular expression '^[A-Z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=deftdevs_bootstrapi&issues=AZ4-8urIsVWpy8fCo6Tw&open=AZ4-8urIsVWpy8fCo6Tw&pullRequest=222

Check warning on line 15 in commons/src/main/java/com/deftdevs/bootstrapi/commons/rest/api/_AllResource.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this generic name to match the regular expression '^[A-Z][0-9]?$'.

See more on https://sonarcloud.io/project/issues?id=deftdevs_bootstrapi&issues=AZ4-8urIsVWpy8fCo6Tx&open=AZ4-8urIsVWpy8fCo6Tx&pullRequest=222

@PUT
@Operation(
summary = "Apply a complete configuration",
responses = {
@ApiResponse(
responseCode = "200",
description = "Configuration applied successfully"
),
@ApiResponse(
responseCode = "default", content = @Content(schema = @Schema(implementation = ErrorCollection.class)),
description = BootstrAPI.ERROR_COLLECTION_RESPONSE_DESCRIPTION
),
}
)
Response setAll(
@NotNull final _AllModel bean);

}
Loading