Skip to content
Merged
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 @@ -14,9 +14,6 @@ public class BootstrAPI {
public static final String AUTHENTICATION_IDP_SAML = "saml";
public static final String AUTHENTICATION_SSO = "sso";
public static final String BACKUP = "backup";
public static final String BACKUP_EXPORT = "export";
public static final String BACKUP_IMPORT = "import";
public static final String BACKUP_QUEUE = "queue";
public static final String CACHE = "cache";
public static final String CACHES = "caches";
public static final String CACHE_FLUSH = "flush";
Expand Down Expand Up @@ -62,6 +59,16 @@ public class BootstrAPI {

public static final String MEDIA_TYPE_IMAGE = "image/*";

public static final String ERROR_COLLECTION_RESPONSE_DESCRIPTION = "Returns a list of error messages.";
public static final String SETTINGS_GENERAL_GET_SUMMARY = "Get the general settings";
public static final String SETTINGS_GENERAL_GET_RESPONSE_DESCRIPTION = "Returns the general settings";
public static final String SETTINGS_GENERAL_PUT_SUMMARY = "Set the general settings";
public static final String SETTINGS_GENERAL_PUT_RESPONSE_DESCRIPTION = "Returns the general security settings";
public static final String SETTINGS_SECURITY_GET_SUMMARY = "Get the security settings";
public static final String SETTINGS_SECURITY_GET_RESPONSE_DESCRIPTION = "Returns the security settings";
public static final String SETTINGS_SECURITY_PUT_SUMMARY = "Set the security settings";
public static final String SETTINGS_SECURITY_PUT_RESPONSE_DESCRIPTION = "Returns the updated security settings";

private BootstrAPI() {
}

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

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

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

import static com.deftdevs.bootstrapi.commons.constants.BootstrAPI.*;
import static com.deftdevs.bootstrapi.commons.constants.BootstrAPI.SETTINGS;
import static com.deftdevs.bootstrapi.commons.constants.BootstrAPI.SETTINGS_SECURITY;

@Data
@Builder
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@XmlRootElement(name = SETTINGS + "-" + SETTINGS_SECURITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,26 @@

import javax.ws.rs.core.Response;

public abstract class AbstractSettingsResourceImpl implements SettingsResource {
public abstract class AbstractSettingsResourceImpl<B extends SettingsBean, S extends SettingsService<B>>
implements SettingsResource<B> {

private final SettingsService settingsService;
private final S settingsService;

public AbstractSettingsResourceImpl(
final S settingsService) {

public AbstractSettingsResourceImpl(final SettingsService settingsService) {
this.settingsService = settingsService;
}

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

@Override
public Response setSettings(SettingsBean settingsBean) {
final SettingsBean updatedSettingsBean = settingsService.setSettings(settingsBean);
public Response setSettings(B settingsBean) {
final B updatedSettingsBean = settingsService.setSettingsGeneral(settingsBean);
return Response.ok(updatedSettingsBean).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.deftdevs.bootstrapi.commons.rest;

import com.deftdevs.bootstrapi.commons.model.SettingsSecurityBean;
import com.deftdevs.bootstrapi.commons.rest.api.SettingsSecurityResource;
import com.deftdevs.bootstrapi.commons.service.api.SettingsSecurityService;

import javax.inject.Inject;
import javax.ws.rs.core.Response;

public abstract class AbstractSettingsSecurityResourceImpl<B extends SettingsSecurityBean, S extends SettingsSecurityService<B>>
implements SettingsSecurityResource<B> {

private final S settingsSecurityService;

@Inject
public AbstractSettingsSecurityResourceImpl(
final S settingsSecurityService) {

this.settingsSecurityService = settingsSecurityService;
}

@Override
public Response getSettingsSecurity() {
final B result = settingsSecurityService.getSettingsSecurity();
return Response.ok(result).build();
}

@Override
public Response setSettingsSecurity(
final B bean) {

final B result = settingsSecurityService.setSettingsSecurity(bean);
return Response.ok(result).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,43 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;

import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

public interface SettingsResource {
public interface SettingsResource<B extends SettingsBean> {

@GET
@Produces(MediaType.APPLICATION_JSON)
@Operation(
tags = { BootstrAPI.SETTINGS },
summary = "Get the application settings",
summary = BootstrAPI.SETTINGS_GENERAL_GET_SUMMARY,
responses = {
@ApiResponse(
responseCode = "200", content = @Content(schema = @Schema(implementation = SettingsBean.class)),
description = "Returns the application settings"
description = BootstrAPI.SETTINGS_GENERAL_GET_RESPONSE_DESCRIPTION
),
@ApiResponse(
responseCode = "default", content = @Content(schema = @Schema(implementation = ErrorCollection.class)),
description = "Returns a list of error messages."
description = BootstrAPI.ERROR_COLLECTION_RESPONSE_DESCRIPTION
),
}
)
Response getSettings();

@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(
tags = { BootstrAPI.SETTINGS },
summary = "Set the application settings",
summary = BootstrAPI.SETTINGS_GENERAL_PUT_SUMMARY,
responses = {
@ApiResponse(
responseCode = "200", content = @Content(schema = @Schema(implementation = SettingsBean.class)),
description = "Returns the application settings"
description = BootstrAPI.SETTINGS_GENERAL_PUT_RESPONSE_DESCRIPTION
),
@ApiResponse(
responseCode = "default", content = @Content(schema = @Schema(implementation = ErrorCollection.class)),
description = "Returns a list of error messages."
description = BootstrAPI.ERROR_COLLECTION_RESPONSE_DESCRIPTION
),
}
)
Response setSettings(
@NotNull final SettingsBean bean);
@NotNull final B bean);

}
Original file line number Diff line number Diff line change
@@ -1,59 +1,52 @@
package com.deftdevs.bootstrapi.confluence.rest.api;
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.confluence.model.SettingsSecurityBean;
import com.deftdevs.bootstrapi.commons.model.SettingsSecurityBean;
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.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

public interface SettingsSecurityResource {
public interface SettingsSecurityResource<B extends SettingsSecurityBean> {

@GET
@Produces(MediaType.APPLICATION_JSON)
@Operation(
tags = { BootstrAPI.SETTINGS },
summary = "Get the security settings",
summary = BootstrAPI.SETTINGS_SECURITY_GET_SUMMARY,
responses = {
@ApiResponse(
responseCode = "200", content = @Content(schema = @Schema(implementation = SettingsSecurityBean.class)),
description = "Returns the security settings"
description = BootstrAPI.SETTINGS_SECURITY_GET_RESPONSE_DESCRIPTION
),
@ApiResponse(
responseCode = "default", content = @Content(schema = @Schema(implementation = SettingsSecurityBean.class)),
description = "Returns a list of error messages."
responseCode = "default", content = @Content(schema = @Schema(implementation = ErrorCollection.class)),
description = BootstrAPI.ERROR_COLLECTION_RESPONSE_DESCRIPTION
),
}
)
Response getSecurity();
Response getSettingsSecurity();

@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(
tags = { BootstrAPI.SETTINGS },
summary = "Set the security settings",
summary = BootstrAPI.SETTINGS_SECURITY_PUT_SUMMARY,
responses = {
@ApiResponse(
responseCode = "200", content = @Content(schema = @Schema(implementation = SettingsSecurityBean.class)),
description = "Returns the updated security settings"
description = BootstrAPI.SETTINGS_SECURITY_PUT_RESPONSE_DESCRIPTION
),
@ApiResponse(
responseCode = "default", content = @Content(schema = @Schema(implementation = ErrorCollection.class)),
description = "Returns a list of error messages."
description = BootstrAPI.ERROR_COLLECTION_RESPONSE_DESCRIPTION
),
}
)
Response setSecurity(
@NotNull final SettingsSecurityBean bean);
Response setSettingsSecurity(
@NotNull final B bean);

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public interface SettingsBrandingService {
*/
SettingsBrandingColorSchemeBean getColourScheme();


/**
* Set the colour scheme
*
Expand Down Expand Up @@ -53,4 +52,5 @@ void setLogo(
*/
void setFavicon(
@NotNull InputStream faviconBinary);

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

import com.deftdevs.bootstrapi.commons.model.SettingsSecurityBean;

import javax.validation.constraints.NotNull;

public interface SettingsSecurityService<B extends SettingsSecurityBean> {

/**
* Get the security settings.
*
* @return the security settings
*/
B getSettingsSecurity();

/**
* Set the settings
*
* @param settingsSecurityBean the security settings to set
* @return the security settings
*/
B setSettingsSecurity(
@NotNull final B settingsSecurityBean);

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

import javax.validation.constraints.NotNull;

public interface SettingsService {
public interface SettingsService<B extends SettingsBean> {

/**
* Get the settings.
*
* @return the settings
* @return the general settings
*/
SettingsBean getSettings();

B getSettingsGeneral();

/**
* Set the settings
*
* @param settingsBean the settings to set
* @param settingsBean the general settings to set
* @return the settings
*/
SettingsBean setSettings(
@NotNull final SettingsBean settingsBean);
B setSettingsGeneral(
@NotNull final B settingsBean);

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void setup() {
void testGetSettings() {
final SettingsBean bean = SettingsBean.EXAMPLE_1;

doReturn(bean).when(settingsService).getSettings();
doReturn(bean).when(settingsService).getSettingsGeneral();

final Response response = resource.getSettings();
assertEquals(200, response.getStatus());
Expand All @@ -44,7 +44,7 @@ void testGetSettings() {
void testSetSettings() {
final SettingsBean bean = SettingsBean.EXAMPLE_1;

doReturn(bean).when(settingsService).setSettings(bean);
doReturn(bean).when(settingsService).setSettingsGeneral(bean);

final Response response = resource.setSettings(bean);
assertEquals(200, response.getStatus());
Expand Down
Loading