diff options
author | 2017-08-23 18:27:19 -0400 | |
---|---|---|
committer | 2017-08-23 21:12:56 -0400 | |
commit | 978dbcf0a196acbafad72fe1e2478ec0e384f02f (patch) | |
tree | 17e1ceaa4a12a599320cbb317947e990bf1a5383 /ecomp-portal-widget-ms/src/main/java/org/openecomp/portalapp/widget/service/impl/InitializationServiceImpl.java | |
parent | bc7350dce5b7b1dcd1c472a3922b42c4ea99809d (diff) |
Deliver centralized role management feature
Repair multiple defects also.
Revise deployment to use docker-compose.
Remove all zip archives.
Issue: PORTAL-21, PORTAL-25, PORTAL-28, PORTAL-52, PORTAL-69,
PORTAL-74, PORTAL-76, PORTAL-80, PORTAL-82
Change-Id: Ie72fec7d35ba78beb162bba6ed27b2caee340c61
Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'ecomp-portal-widget-ms/src/main/java/org/openecomp/portalapp/widget/service/impl/InitializationServiceImpl.java')
-rw-r--r-- | ecomp-portal-widget-ms/src/main/java/org/openecomp/portalapp/widget/service/impl/InitializationServiceImpl.java | 128 |
1 files changed, 0 insertions, 128 deletions
diff --git a/ecomp-portal-widget-ms/src/main/java/org/openecomp/portalapp/widget/service/impl/InitializationServiceImpl.java b/ecomp-portal-widget-ms/src/main/java/org/openecomp/portalapp/widget/service/impl/InitializationServiceImpl.java deleted file mode 100644 index 31635f74..00000000 --- a/ecomp-portal-widget-ms/src/main/java/org/openecomp/portalapp/widget/service/impl/InitializationServiceImpl.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.openecomp.portalapp.widget.service.impl; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.HashSet; - -import javax.transaction.Transactional; - -import org.openecomp.portalapp.widget.controller.WidgetsCatalogController; -import org.openecomp.portalapp.widget.domain.MicroserviceData; -import org.openecomp.portalapp.widget.domain.MicroserviceParameter; -import org.openecomp.portalapp.widget.domain.RoleApp; -import org.openecomp.portalapp.widget.domain.WidgetCatalog; -import org.openecomp.portalapp.widget.service.InitializationService; -import org.openecomp.portalapp.widget.service.MicroserviceService; -import org.openecomp.portalapp.widget.service.StorageService; -import org.openecomp.portalapp.widget.service.WidgetCatalogService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Service; - -@Service("initService") -@Transactional -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -public class InitializationServiceImpl implements InitializationService{ - - private static final String BASIC_AUTH = "Basic Authentication"; - private static final String PARAMETER_KEY = "resourceType"; - private static final Logger logger = LoggerFactory.getLogger(WidgetsCatalogController.class); - - @Autowired - WidgetCatalogService widgetCatalogService; - - @Autowired - StorageService storageService; - - @Autowired - MicroserviceService microserviceService; - - @Value("${account.user.name}") - String account_user; - - @Value("${account.user.password}") - String account_password; - - @Value("${initialization.widgetData.url}") - String widgetData_url; - - @Override - public void initialize() { - initCommonWidget("News"); - initCommonWidget("Events"); - initCommonWidget("Resources"); - } - - private void initCommonWidget(String name){ - - final String newServiceName = name + " Microservice"; - final String newWidgetName = name + " Widget"; - - Long serviceId = microserviceService.getMicroserviceIdByName(newServiceName); - - if(serviceId == null){ - MicroserviceData newService = new MicroserviceData(); - newService.setName(newServiceName); - newService.setDesc(name); - newService.setAppId(1); - newService.setUrl(widgetData_url); - newService.setSecurityType(BASIC_AUTH); - newService.setUsername(account_user); - newService.setPassword(account_password); - newService.setActive("Y"); - serviceId = microserviceService.saveMicroserivce(newService); - - - MicroserviceParameter parameter = new MicroserviceParameter(); - parameter.setServiceId(serviceId); - parameter.setPara_key(PARAMETER_KEY); - String parameter_value = null; - switch(name.toLowerCase()){ - case "news": - parameter_value = "NEWS"; - break; - case "events": - parameter_value = "EVENTS"; - break; - case "resources": - parameter_value = "IMPORTANTRESOURCES"; - break; - } - parameter.setPara_value(parameter_value); - microserviceService.saveMicroserviceParameter(parameter); - } - - if(!widgetCatalogService.getWidgetIdByName(newWidgetName)){ - WidgetCatalog newWidget = new WidgetCatalog(); - newWidget.setName(newWidgetName); - newWidget.setDesc(name); - newWidget.setAllowAllUser("1"); - String fileLocation = name.toLowerCase() + "-widget.zip"; - newWidget.setFileLocation(fileLocation); - newWidget.setServiceId(serviceId); - newWidget.setWidgetRoles(new HashSet<RoleApp>()); - long widgetId = widgetCatalogService.saveWidgetCatalog(newWidget); - - File file = new File("/tmp/" + fileLocation); - try{ - - InputStream fileInputStream = this.getClass().getClassLoader().getResourceAsStream(fileLocation); - OutputStream outputStream = new FileOutputStream(file); - int read = 0; - byte[] bytes = new byte[4096]; - while ((read = fileInputStream.read(bytes)) != -1) { - outputStream.write(bytes, 0, read); - } - }catch(Exception e){ - logger.error("Exception occurred while performing InitializationServiceImpl.initCommonWidget in widget microservices. Details:" + e.getMessage()); - } - storageService.initSave(file, newWidget, widgetId); - } - } -} |