@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(); }
final boolean isRequiredMigrationStep) { final SoftwareModule appMod = softwareModuleManagement.create(entityFactory.softwareModule().create() .type(findOrCreateSoftwareModuleType(SM_TYPE_APP, Integer.MAX_VALUE)).name(prefix + SM_TYPE_APP) .version(version + "." + new SecureRandom().nextInt(100)).description(LOREM.words(20)) .vendor(prefix + " vendor Limited, California")); final SoftwareModule runtimeMod = softwareModuleManagement .create(entityFactory.softwareModule().create().type(findOrCreateSoftwareModuleType(SM_TYPE_RT)) .name(prefix + "app runtime").version(version + "." + new SecureRandom().nextInt(100)) .description(LOREM.words(20)).vendor(prefix + " vendor GmbH, Stuttgart, Germany")); final SoftwareModule osMod = softwareModuleManagement .create(entityFactory.softwareModule().create().type(findOrCreateSoftwareModuleType(SM_TYPE_OS)) .name(prefix + " Firmware").version(version + "." + new SecureRandom().nextInt(100)) .description(LOREM.words(20)).vendor(prefix + " vendor Limited Inc, California"));
/** * Creates {@link SoftwareModule} with {@link #DEFAULT_VENDOR} and * {@link #DEFAULT_VERSION} and random generated * {@link Target#getDescription()} in the repository. * * @param typeKey * of the {@link SoftwareModuleType} * @param prefix * added to name and version * * @return persisted {@link SoftwareModule}. */ public SoftwareModule createSoftwareModule(final String typeKey, final String prefix) { return softwareModuleManagement.create(entityFactory.softwareModule().create() .type(findOrCreateSoftwareModuleType(typeKey)).name(prefix + typeKey).version(prefix + DEFAULT_VERSION) .description(LOREM.words(10)).vendor(DEFAULT_VENDOR)); }
private static SoftwareModuleCreate fromRequest(final EntityFactory entityFactory, final MgmtSoftwareModuleRequestBodyPost smsRest) { return entityFactory.softwareModule().create().type(smsRest.getType()).name(smsRest.getName()) .version(smsRest.getVersion()).description(smsRest.getDescription()).vendor(smsRest.getVendor()); }
final boolean isRequiredMigrationStep) { final SoftwareModule appMod = softwareModuleManagement.create(entityFactory.softwareModule().create() .type(findOrCreateSoftwareModuleType(SM_TYPE_APP, Integer.MAX_VALUE)).name(prefix + SM_TYPE_APP) .version(version + "." + new SecureRandom().nextInt(100)).description(LOREM.words(20)) .vendor(prefix + " vendor Limited, California")); final SoftwareModule runtimeMod = softwareModuleManagement .create(entityFactory.softwareModule().create().type(findOrCreateSoftwareModuleType(SM_TYPE_RT)) .name(prefix + "app runtime").version(version + "." + new SecureRandom().nextInt(100)) .description(LOREM.words(20)).vendor(prefix + " vendor GmbH, Stuttgart, Germany")); final SoftwareModule osMod = softwareModuleManagement .create(entityFactory.softwareModule().create().type(findOrCreateSoftwareModuleType(SM_TYPE_OS)) .name(prefix + " Firmware").version(version + "." + new SecureRandom().nextInt(100)) .description(LOREM.words(20)).vendor(prefix + " vendor Limited Inc, California"));
/** * Creates {@link SoftwareModule} with {@link #DEFAULT_VENDOR} and * {@link #DEFAULT_VERSION} and random generated * {@link Target#getDescription()} in the repository. * * @param typeKey * of the {@link SoftwareModuleType} * @param prefix * added to name and version * * @return persisted {@link SoftwareModule}. */ public SoftwareModule createSoftwareModule(final String typeKey, final String prefix) { return softwareModuleManagement.create(entityFactory.softwareModule().create() .type(findOrCreateSoftwareModuleType(typeKey)).name(prefix + typeKey).version(prefix + DEFAULT_VERSION) .description(LOREM.words(10)).vendor(DEFAULT_VENDOR)); }
private void addNewBaseSoftware() { final String name = nameTextField.getValue(); final String version = versionTextField.getValue(); final String vendor = vendorTextField.getValue(); final String description = descTextArea.getValue(); final String type = typeComboBox.getValue() != null ? typeComboBox.getValue().toString() : null; final SoftwareModuleType softwareModuleTypeByName = softwareModuleTypeManagement.getByName(type) .orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, type)); final SoftwareModuleCreate softwareModule = entityFactory.softwareModule().create() .type(softwareModuleTypeByName).name(name).version(version).description(description).vendor(vendor); final SoftwareModule newSoftwareModule = softwareModuleManagement.create(softwareModule); eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.ADD_ENTITY, newSoftwareModule)); uiNotifcation.displaySuccess(i18n.getMessage("message.save.success", new Object[] { newSoftwareModule.getName() + ":" + newSoftwareModule.getVersion() })); softwareModuleTable.setValue(Sets.newHashSet(newSoftwareModule.getId())); }
private void addNewBaseSoftware() { final String name = nameTextField.getValue(); final String version = versionTextField.getValue(); final String vendor = vendorTextField.getValue(); final String description = descTextArea.getValue(); final String type = typeComboBox.getValue() != null ? typeComboBox.getValue().toString() : null; final SoftwareModuleType softwareModuleTypeByName = softwareModuleTypeManagement.getByName(type) .orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, type)); final SoftwareModuleCreate softwareModule = entityFactory.softwareModule().create() .type(softwareModuleTypeByName).name(name).version(version).description(description).vendor(vendor); final SoftwareModule newSoftwareModule = softwareModuleManagement.create(softwareModule); eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.ADD_ENTITY, newSoftwareModule)); uiNotifcation.displaySuccess(i18n.getMessage("message.save.success", newSoftwareModule.getName() + ":" + newSoftwareModule.getVersion())); softwareModuleTable.setValue(Sets.newHashSet(newSoftwareModule.getId())); }
/** * 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()))); }
+ SpPermission.CREATE_REPOSITORY) public void postSoftwareModules() throws Exception { final SoftwareModule os = entityFactory.softwareModule().create().type(osType).name("name1").version("version1") .description("description1").vendor("vendor1").build(); final SoftwareModule ah = entityFactory.softwareModule().create().type(appType).name("name3") .version("version1").description("description1").vendor("vendor1").build();
public void putSoftwareModule() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); softwareModuleManagement.update(entityFactory.softwareModule().update(sm.getId()).description("a description")); final SoftwareModule update = entityFactory.softwareModule().create().name("another name") .vendor("another Vendor").description("a new description").type(Constants.SMT_DEFAULT_OS_KEY).build();
@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)))); }