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";
public static final String _ROOT = "/";

public static final String APPLICATION = "application";
public static final String APPLICATIONS = "applications";
public static final String APPLICATION_LINK = "application-link";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ public abstract class AbstractDirectoryModel {
@XmlElement
private Date updatedDate;

@XmlElement
private Boolean testConnection;

}
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 {

@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
Expand Up @@ -26,7 +26,7 @@ public Response setDirectories (
final boolean testConnection,
final List<AbstractDirectoryModel> directories) {

List<AbstractDirectoryModel> directoryModels = directoriesService.setDirectories(directories, testConnection);
List<AbstractDirectoryModel> directoryModels = directoriesService.setDirectories(directories);
return Response.ok(directoryModels).build();
}

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

import com.deftdevs.bootstrapi.commons.rest.api._AllResource;
import com.deftdevs.bootstrapi.commons.service.api._AllService;

import javax.ws.rs.core.Response;

public abstract class _AbstractAllResourceImpl<_AllModel>
implements _AllResource<_AllModel> {

private final _AllService<_AllModel> allService;

public _AbstractAllResourceImpl(
final _AllService<_AllModel> allService) {

this.allService = allService;
}

public Response setAll(
final _AllModel allModel) {

return Response.ok(allService.setAll(allModel)).build();
}
}
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.SettingsModel;
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> {

@PUT
@Operation(
summary = BootstrAPI._ALL,
responses = {
@ApiResponse(
responseCode = "200", content = @Content(schema = @Schema(implementation = SettingsModel.class)),
description = BootstrAPI._ALL
),
@ApiResponse(
responseCode = "default", content = @Content(schema = @Schema(implementation = ErrorCollection.class)),
description = BootstrAPI._ALL
),
}
)
Response setAll(
@NotNull final _AllModel bean);

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

import com.deftdevs.bootstrapi.commons.model.AbstractDirectoryModel;
import com.deftdevs.bootstrapi.commons.model.type._AllModelStatus;
import com.deftdevs.bootstrapi.commons.service.api._AllService;

import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;

public abstract class _AbstractAllServiceImpl<_A> implements _AllService<_A> {

protected <T> _AllModelStatus setEntity(
final T entity,
final Function<T, T> updateFunction,
final Consumer<T> resultConsumer) {

if (entity == null) {
return null;
}

try {
final T updatedEntity = updateFunction.apply(entity);
resultConsumer.accept(updatedEntity);
return _AllModelStatus.success();
} catch (Exception e) {
return _AllModelStatus.error(
Response.Status.INTERNAL_SERVER_ERROR,
"Failed to apply ...",
e.getMessage()
);
}
}

protected <T> _AllModelStatus setEntities(
final Map<String, T> entityMap,
final Function<T, String> getIdentifier,
final Function<List<T>, List<T>> updateFunction,
final Consumer<Map<String, T>> resultConsumer) {

if (entityMap == null || entityMap.isEmpty()) {
return null;
}

// return updateFunction.apply(new ArrayList<>(entityMap.values()));

for (Map.Entry<String, T> entityEntry : entityMap.entrySet()) {
try {
final T updatedEntity = updateFunction.apply(entityEntry.getValue());
resultConsumer.accept(updatedEntity);
return _AllModelStatus.success();
} catch (Exception e) {
return _AllModelStatus.error(
Response.Status.INTERNAL_SERVER_ERROR,
"Failed to apply ...",
e.getMessage()
);
}
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ AbstractDirectoryModel getDirectory(
/**
* Adds or Updates directory configurations. Any existing configurations with the same 'name' property is updated.
*
* @param directories the directories
* @param testConnection whether to test connection
* @param directories the directories
* @return the directories
*/
List<AbstractDirectoryModel> setDirectories(
List<AbstractDirectoryModel> directories,
boolean testConnection);
List<AbstractDirectoryModel> directories);

/**
* Updates a single directory configuration. Any existing configuration with the same 'name' property is updated.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.deftdevs.bootstrapi.commons.service.api;

public interface _AllService<_AllModel> {

/**
* Apply a complete configuration.
*
* @param allModel the configuration to apply
* @return the updated configuration with status
*/
_AllModel setAll(
_AllModel allModel);

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void testSetDirectories() {
final DirectoryCrowdModel directoryModel1 = DirectoryCrowdModel.EXAMPLE_1;
final DirectoryCrowdModel directoryModel2 = DirectoryCrowdModel.EXAMPLE_3;
final List<AbstractDirectoryModel> directoryModels = Arrays.asList(directoryModel1, directoryModel2);
doReturn(directoryModels).when(directoriesService).setDirectories(directoryModels, false);
doReturn(directoryModels).when(directoriesService).setDirectories(directoryModels);

final Response response = resource.setDirectories(Boolean.FALSE, directoryModels);
assertEquals(200, response.getStatus());
Expand Down
34 changes: 34 additions & 0 deletions confluence/Apis/AllApi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# AllApi

All URIs are relative to *https://&lt;CONFLUENCE_URL&gt;/rest/bootstrapi/1*

| Method | HTTP request | Description |
|------------- | ------------- | -------------|
| [**setAll**](AllApi.md#setAll) | **PUT** / | _all |


<a name="setAll"></a>
# **setAll**
> SettingsModel setAll(\_AllModel)

_all

### Parameters

|Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **\_AllModel** | [**_AllModel**](../Models/_AllModel.md)| | |

### Return type

[**SettingsModel**](../Models/SettingsModel.md)

### Authorization

[basicAuth](../README.md#basicAuth)

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json

1 change: 1 addition & 0 deletions confluence/Models/AbstractDirectoryModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
| **active** | **Boolean** | | [optional] [default to null] |
| **createdDate** | **Date** | | [optional] [default to null] |
| **updatedDate** | **Date** | | [optional] [default to null] |
| **testConnection** | **Boolean** | | [optional] [default to null] |
| **type** | **String** | | [default to null] |
| **connector** | [**DirectoryDelegatingConnector**](DirectoryDelegatingConnector.md) | | [optional] [default to null] |
| **configuration** | [**DirectoryDelegatingConfiguration**](DirectoryDelegatingConfiguration.md) | | [optional] [default to null] |
Expand Down
1 change: 1 addition & 0 deletions confluence/Models/DirectoryCrowdModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
| **active** | **Boolean** | | [optional] [default to null] |
| **createdDate** | **Date** | | [optional] [default to null] |
| **updatedDate** | **Date** | | [optional] [default to null] |
| **testConnection** | **Boolean** | | [optional] [default to null] |
| **type** | **String** | | [default to null] |
| **server** | [**DirectoryCrowdServer**](DirectoryCrowdServer.md) | | [optional] [default to null] |
| **permissions** | [**DirectoryCrowdPermissions**](DirectoryCrowdPermissions.md) | | [optional] [default to null] |
Expand Down
1 change: 1 addition & 0 deletions confluence/Models/DirectoryDelegatingModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
| **active** | **Boolean** | | [optional] [default to null] |
| **createdDate** | **Date** | | [optional] [default to null] |
| **updatedDate** | **Date** | | [optional] [default to null] |
| **testConnection** | **Boolean** | | [optional] [default to null] |
| **type** | **String** | | [default to null] |
| **server** | [**DirectoryLdapServer**](DirectoryLdapServer.md) | | [optional] [default to null] |
| **permissions** | [**DirectoryPermissions**](DirectoryPermissions.md) | | [optional] [default to null] |
Expand Down
1 change: 1 addition & 0 deletions confluence/Models/DirectoryGenericModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
| **active** | **Boolean** | | [optional] [default to null] |
| **createdDate** | **Date** | | [optional] [default to null] |
| **updatedDate** | **Date** | | [optional] [default to null] |
| **testConnection** | **Boolean** | | [optional] [default to null] |
| **type** | **String** | | [default to null] |
| **server** | [**DirectoryLdapServer**](DirectoryLdapServer.md) | | [optional] [default to null] |
| **permissions** | [**DirectoryLdapPermissions**](DirectoryLdapPermissions.md) | | [optional] [default to null] |
Expand Down
1 change: 1 addition & 0 deletions confluence/Models/DirectoryInternalModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
| **active** | **Boolean** | | [optional] [default to null] |
| **createdDate** | **Date** | | [optional] [default to null] |
| **updatedDate** | **Date** | | [optional] [default to null] |
| **testConnection** | **Boolean** | | [optional] [default to null] |
| **type** | **String** | | [default to null] |
| **server** | [**DirectoryLdapServer**](DirectoryLdapServer.md) | | [optional] [default to null] |
| **permissions** | [**DirectoryPermissions**](DirectoryPermissions.md) | | [optional] [default to null] |
Expand Down
1 change: 1 addition & 0 deletions confluence/Models/DirectoryLdapModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
| **active** | **Boolean** | | [optional] [default to null] |
| **createdDate** | **Date** | | [optional] [default to null] |
| **updatedDate** | **Date** | | [optional] [default to null] |
| **testConnection** | **Boolean** | | [optional] [default to null] |
| **type** | **String** | | [default to null] |
| **server** | [**DirectoryLdapServer**](DirectoryLdapServer.md) | | [optional] [default to null] |
| **permissions** | [**DirectoryLdapPermissions**](DirectoryLdapPermissions.md) | | [optional] [default to null] |
Expand Down
12 changes: 12 additions & 0 deletions confluence/Models/_AllModel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# _AllModel
## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
| **settings** | [**SettingsModel**](SettingsModel.md) | | [optional] [default to null] |
| **users** | [**Map**](UserModel.md) | | [optional] [default to null] |
| **groups** | [**Map**](GroupModel.md) | | [optional] [default to null] |
| **status** | [**Map**](_AllModelStatus.md) | | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

11 changes: 11 additions & 0 deletions confluence/Models/_AllModelStatus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# _AllModelStatus
## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
| **status** | **Integer** | | [optional] [default to null] |
| **message** | **String** | | [optional] [default to null] |
| **details** | **String** | | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

3 changes: 3 additions & 0 deletions confluence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All URIs are relative to *https://<CONFLUENCE_URL>/rest/bootstrapi/1*

| Class | Method | HTTP request | Description |
|------------ | ------------- | ------------- | -------------|
| *AllApi* | [**setAll**](Apis/AllApi.md#setall) | **PUT** / | _all |
| *ApplicationLinkApi* | [**createApplicationLink**](Apis/ApplicationLinkApi.md#createapplicationlink) | **POST** /application-link | Create an application link |
*ApplicationLinkApi* | [**deleteApplicationLink**](Apis/ApplicationLinkApi.md#deleteapplicationlink) | **DELETE** /application-link/{uuid} | Delete an application link |
*ApplicationLinkApi* | [**getApplicationLink**](Apis/ApplicationLinkApi.md#getapplicationlink) | **GET** /application-link/{uuid} | Get an application link |
Expand Down Expand Up @@ -94,6 +95,8 @@ All URIs are relative to *https://<CONFLUENCE_URL>/rest/bootstrapi/1*
- [SettingsModel](./Models/SettingsModel.md)
- [SettingsSecurityModel](./Models/SettingsSecurityModel.md)
- [UserModel](./Models/UserModel.md)
- [_AllModel](./Models/_AllModel.md)
- [_AllModelStatus](./Models/_AllModelStatus.md)


<a name="documentation-for-authorization"></a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.deftdevs.bootstrapi.confluence.model;

import com.deftdevs.bootstrapi.commons.model.GroupModel;
import com.deftdevs.bootstrapi.commons.model.SettingsModel;
import com.deftdevs.bootstrapi.commons.model.UserModel;
import com.deftdevs.bootstrapi.commons.model.type._AllModelStatus;
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;

@Data
@NoArgsConstructor
@AllArgsConstructor
@XmlRootElement(name = "all")
public class _AllModel {

@XmlElement
private SettingsModel settings;

@XmlElement
private Map<String, UserModel> users;

@XmlElement
private Map<String, GroupModel> groups;

@XmlElement
private Map<String, _AllModelStatus> status;

}
Loading
Loading