@Override public ResponseEntity<MgmtSoftwareModule> updateSoftwareModule( @PathVariable("softwareModuleId") final Long softwareModuleId, @RequestBody final MgmtSoftwareModuleRequestBodyPut restSoftwareModule) { final SoftwareModule module = softwareModuleManagement .update(entityFactory.softwareModule().update(softwareModuleId) .description(restSoftwareModule.getDescription()).vendor(restSoftwareModule.getVendor())); final MgmtSoftwareModule response = MgmtSoftwareModuleMapper.toResponse(module); MgmtSoftwareModuleMapper.addLinks(module, response); return ResponseEntity.ok(response); }
/** * Creates {@link DistributionSet}s in repository including three * {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} * , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an * iterative number and {@link DistributionSet#isRequiredMigrationStep()} * <code>false</code>. * * In addition it updates the created {@link DistributionSet}s and * {@link SoftwareModule}s to ensure that * {@link BaseEntity#getLastModifiedAt()} and * {@link BaseEntity#getLastModifiedBy()} is filled. * * @return persisted {@link DistributionSet}. */ public DistributionSet createUpdatedDistributionSet() { DistributionSet set = createDistributionSet(""); set = distributionSetManagement.update( entityFactory.distributionSet().update(set.getId()).description("Updated " + DEFAULT_DESCRIPTION)); set.getModules().forEach(module -> softwareModuleManagement.update( entityFactory.softwareModule().update(module.getId()).description("Updated " + DEFAULT_DESCRIPTION))); // load also lazy stuff return distributionSetManagement.getWithDetails(set.getId()).get(); }
/** * Creates {@link DistributionSet}s in repository including three * {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} * , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an * iterative number and {@link DistributionSet#isRequiredMigrationStep()} * <code>false</code>. * * In addition it updates the created {@link DistributionSet}s and * {@link SoftwareModule}s to ensure that * {@link BaseEntity#getLastModifiedAt()} and * {@link BaseEntity#getLastModifiedBy()} is filled. * * @return persisted {@link DistributionSet}. */ public DistributionSet createUpdatedDistributionSet() { DistributionSet set = createDistributionSet(""); set = distributionSetManagement.update( entityFactory.distributionSet().update(set.getId()).description("Updated " + DEFAULT_DESCRIPTION)); set.getModules().forEach(module -> softwareModuleManagement.update( entityFactory.softwareModule().update(module.getId()).description("Updated " + DEFAULT_DESCRIPTION))); // load also lazy stuff return distributionSetManagement.getWithDetails(set.getId()).get(); }
/** * updates a softwareModule */ private void updateSwModule() { final SoftwareModule newSWModule = softwareModuleManagement.update(entityFactory.softwareModule() .update(baseSwModuleId).description(descTextArea.getValue()).vendor(vendorTextField.getValue())); if (newSWModule != null) { uiNotifcation.displaySuccess(i18n.getMessage("message.save.success", newSWModule.getName() + ":" + newSWModule.getVersion())); eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.UPDATED_ENTITY, newSWModule)); } }
/** * updates a softwareModule */ private void updateSwModule() { final SoftwareModule newSWModule = softwareModuleManagement.update(entityFactory.softwareModule() .update(baseSwModuleId).description(descTextArea.getValue()).vendor(vendorTextField.getValue())); if (newSWModule != null) { uiNotifcation.displaySuccess(i18n.getMessage("message.save.success", new Object[] { newSWModule.getName() + ":" + newSWModule.getVersion() })); eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.UPDATED_ENTITY, newSWModule)); } } }
protected DistributionSet createDistributionSet() { DistributionSet distributionSet = testdataFactory.createDistributionSet(""); distributionSet = distributionSetManagement.update(entityFactory.distributionSet() .update(distributionSet.getId()).description("The descption of the distribution set.")); distributionSet.getModules().forEach(module -> { final byte[] random = RandomStringUtils.random(5).getBytes(); artifactManagement .create(new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "file1", false, 0)); softwareModuleManagement.update(entityFactory.softwareModule().update(module.getId()) .description("Description of the software module")); }); return distributionSet; }
@Test @Description("Handles the GET request of retrieving all softwaremodules within SP with given page size and offset including sorting by version descending and filter down to all sets which name starts with 'SM'. Required Permission: " + SpPermission.READ_REPOSITORY) public void getSoftwareModulesWithParameters() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); softwareModuleManagement.update(entityFactory.softwareModule().update(sm.getId()).description("a description")); final SoftwareModule sm2 = testdataFactory.createSoftwareModuleApp(); softwareModuleManagement .update(entityFactory.softwareModule().update(sm2.getId()).description("a description")); mockMvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING).param("offset", "1") .param("limit", "2").param("sort", "version:DESC").param("q", "name==SM*")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) .andDo(this.document.document(getFilterRequestParamter())); }
@Test @Description("Handles the GET request of retrieving all softwaremodules within SP. Required Permission: " + SpPermission.READ_REPOSITORY) public void getSoftwareModules() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); softwareModuleManagement.update(entityFactory.softwareModule().update(sm.getId()).description("a description")); final SoftwareModule sm2 = testdataFactory.createSoftwareModuleApp(); softwareModuleManagement .update(entityFactory.softwareModule().update(sm2.getId()).description("a description")); mockMvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()).andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) .andDo(this.document.document(responseFields( fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), fieldWithPath("content").description(MgmtApiModelProperties.SM_LIST), fieldWithPath("content[].id").description(ApiModelPropertiesGeneric.ITEM_ID), fieldWithPath("content[].name").description(ApiModelPropertiesGeneric.NAME), fieldWithPath("content[].description").description(ApiModelPropertiesGeneric.DESCRPTION), fieldWithPath("content[].vendor").description(MgmtApiModelProperties.VENDOR), fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), fieldWithPath("content[].lastModifiedBy") .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), fieldWithPath("content[].lastModifiedAt") .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), fieldWithPath("content[].type").description(MgmtApiModelProperties.SM_TYPE), fieldWithPath("content[].version").description(MgmtApiModelProperties.VERSION), fieldWithPath("content[]._links.self").ignored()))); }
@Test @Description("Handles the GET request of retrieving a single softwaremodule within SP. Required Permission: " + SpPermission.READ_REPOSITORY) public void getSoftwareModule() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); softwareModuleManagement.update(entityFactory.softwareModule().update(sm.getId()).description("a description")); mockMvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}", sm.getId())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) .andDo(this.document.document( pathParameters( parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), responseFields(fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), fieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), fieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), fieldWithPath("vendor").description(MgmtApiModelProperties.VENDOR), fieldWithPath("deleted").description(ApiModelPropertiesGeneric.DELETED), fieldWithPath("type").description(MgmtApiModelProperties.SM_TYPE), fieldWithPath("version").description(MgmtApiModelProperties.VERSION), fieldWithPath("_links.self").ignored(), fieldWithPath("_links.type").description(MgmtApiModelProperties.SM_TYPE), fieldWithPath("_links.artifacts").description(MgmtApiModelProperties.ARTIFACT_LIST), fieldWithPath("_links.metadata").description(MgmtApiModelProperties.META_DATA)))); }
public void putSoftwareModule() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); softwareModuleManagement.update(entityFactory.softwareModule().update(sm.getId()).description("a description"));