Search in sources :

Example 1 with DescriptorMetadata

use of com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata in project hub-alert by blackducksoftware.

the class DescriptorMetadataActions method createDescriptorMetadata.

private Optional<DescriptorMetadata> createDescriptorMetadata(DescriptorKey descriptorKey, ConfigContextEnum context, DescriptorType descriptorType) {
    if (authorizationManager.hasPermissions(context, descriptorKey)) {
        Set<AccessOperation> operations = gatherDescriptorContextOperations(context, descriptorKey);
        boolean readOnly = authorizationManager.isReadOnly(context, descriptorKey);
        DescriptorMetadata descriptorMetadata = new DescriptorMetadata(descriptorKey, descriptorType, context, operations, readOnly);
        return Optional.of(descriptorMetadata);
    }
    return Optional.empty();
}
Also used : AccessOperation(com.synopsys.integration.alert.common.enumeration.AccessOperation) DescriptorMetadata(com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata)

Example 2 with DescriptorMetadata

use of com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata in project hub-alert by blackducksoftware.

the class AboutReader method getDescriptorData.

private Set<DescriptorMetadata> getDescriptorData(DescriptorType descriptorType) {
    Set<DescriptorMetadata> descriptorData = Set.of();
    ActionResponse<DescriptorsResponseModel> response = descriptorActions.getDescriptorsByType(descriptorType.name());
    if (response.hasContent()) {
        DescriptorsResponseModel providersData = response.getContent().get();
        descriptorData = providersData.getDescriptors();
    }
    return descriptorData;
}
Also used : DescriptorMetadata(com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata) DescriptorsResponseModel(com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel)

Example 3 with DescriptorMetadata

use of com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata in project hub-alert by blackducksoftware.

the class DescriptorMetadataActionsTest method getDescriptorsWithAllParametersTest.

@Test
public void getDescriptorsWithAllParametersTest() {
    DescriptorType type1 = DescriptorType.CHANNEL;
    String componentName1 = getNamePrefix(type1) + "_2";
    ConfigContextEnum context1 = ConfigContextEnum.GLOBAL;
    ActionResponse<DescriptorsResponseModel> response1 = actions.getDescriptorsByPermissions(componentName1, type1.name(), context1.name());
    assertTrue(response1.isSuccessful());
    assertTrue(response1.hasContent());
    Set<DescriptorMetadata> descriptorMetadata1 = response1.getContent().get().getDescriptors();
    assertEquals(1, descriptorMetadata1.size());
}
Also used : DescriptorType(com.synopsys.integration.alert.common.enumeration.DescriptorType) DescriptorMetadata(com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata) ConfigContextEnum(com.synopsys.integration.alert.common.enumeration.ConfigContextEnum) DescriptorsResponseModel(com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel) Test(org.junit.jupiter.api.Test)

Example 4 with DescriptorMetadata

use of com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata in project hub-alert by blackducksoftware.

the class DescriptorControllerTestIT method assertValidResponse.

private DescriptorsResponseModel assertValidResponse(MockHttpServletRequestBuilder request) throws Exception {
    MvcResult mvcResult = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk()).andReturn();
    String listOfDescriptorsJson = mvcResult.getResponse().getContentAsString();
    DescriptorsResponseModel descriptorsResponseModel = new Gson().fromJson(listOfDescriptorsJson, DescriptorsResponseModel.class);
    Set<DescriptorMetadata> setOfDescriptors = descriptorsResponseModel.getDescriptors();
    assertTrue(setOfDescriptors.size() > 0);
    return descriptorsResponseModel;
}
Also used : DescriptorMetadata(com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata) Gson(com.google.gson.Gson) MvcResult(org.springframework.test.web.servlet.MvcResult) DescriptorsResponseModel(com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel)

Example 5 with DescriptorMetadata

use of com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata in project hub-alert by blackducksoftware.

the class DescriptorMetadataActions method createDescriptorResponse.

private ActionResponse<DescriptorsResponseModel> createDescriptorResponse(Predicate<Descriptor> descriptorFilter, Set<ConfigContextEnum> requestedContexts) {
    Set<DescriptorMetadata> descriptorMetadata = descriptors.stream().filter(descriptorFilter).map(descriptor -> createDescriptorMetadata(descriptor, requestedContexts)).flatMap(Set::stream).collect(Collectors.toSet());
    DescriptorsResponseModel responseModel = new DescriptorsResponseModel(descriptorMetadata);
    return new ActionResponse<>(HttpStatus.OK, responseModel);
}
Also used : DescriptorMetadata(com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata) ActionResponse(com.synopsys.integration.alert.common.action.ActionResponse) DescriptorsResponseModel(com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel)

Aggregations

DescriptorMetadata (com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata)10 DescriptorsResponseModel (com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel)7 Test (org.junit.jupiter.api.Test)6 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)4 AccessOperation (com.synopsys.integration.alert.common.enumeration.AccessOperation)2 DescriptorType (com.synopsys.integration.alert.common.enumeration.DescriptorType)2 Gson (com.google.gson.Gson)1 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)1 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)1 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)1 AboutModel (com.synopsys.integration.alert.web.api.about.AboutModel)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1