3434import org .opentosca .container .api .dto .request .CsarTransformRequest ;
3535import org .opentosca .container .api .dto .request .CsarUploadRequest ;
3636import org .opentosca .container .api .service .CsarService ;
37- import org .opentosca .container .api .service .PlanService ;
3837import org .opentosca .container .api .util .ModelUtil ;
3938import org .opentosca .container .api .util .UriUtil ;
4039import org .opentosca .container .connector .winery .WineryConnector ;
4140import org .opentosca .container .control .IOpenToscaControlService ;
4241import org .opentosca .container .core .common .EntityExistsException ;
43- import org .opentosca .container .core .common .SystemException ;
44- import org .opentosca .container .core .common .UserException ;
42+ import org .opentosca .container .core .common .Settings ;
4543import org .opentosca .container .core .engine .IToscaEngineService ;
4644import org .opentosca .container .core .model .csar .CSARContent ;
4745import org .opentosca .container .core .model .csar .id .CSARID ;
@@ -198,6 +196,14 @@ private Response handleCsarUpload(final String filename, final InputStream is) {
198196
199197 final File file = this .csarService .storeTemporaryFile (filename , is );
200198
199+ final WineryConnector wc = new WineryConnector ();
200+
201+ // perform management feature enrichment for the given CSAR
202+ if (Boolean .parseBoolean (Settings .OPENTOSCA_MANAGEMENT_FEATURE_ENRICHMENT )) {
203+ logger .debug ("Management feature enrichment enabled. Trying to enrich given CSAR with available features..." );
204+ wc .performManagementFeatureEnrichment (file );
205+ }
206+
201207 CSARID csarId ;
202208
203209 try {
@@ -235,27 +241,22 @@ private Response handleCsarUpload(final String filename, final InputStream is) {
235241 }
236242
237243 // TODO this is such a brutal hack, won't go through reviews....
238- final WineryConnector wc = new WineryConnector ();
239- boolean repoAvailable = wc .isWineryRepositoryAvailable ();
240-
244+ final boolean repoAvailable = wc .isWineryRepositoryAvailable ();
241245 final StringBuilder strB = new StringBuilder ();
242246
243247 // quick and dirty parallel thread to upload the csar to the container
244248 // repository
245249 // This is needed for the state save feature
246- Thread parallelUploadThread = new Thread (new Runnable () {
247- @ Override
248- public void run () {
249- if (wc .isWineryRepositoryAvailable ()) {
250- try {
251- strB .append (wc .uploadCSAR (file , false ));
252- }
253- catch (URISyntaxException e ) {
254- e .printStackTrace ();
255- }
256- catch (IOException e ) {
257- e .printStackTrace ();
258- }
250+ final Thread parallelUploadThread = new Thread (() -> {
251+ if (wc .isWineryRepositoryAvailable ()) {
252+ try {
253+ strB .append (wc .uploadCSAR (file , false ));
254+ }
255+ catch (final URISyntaxException e1 ) {
256+ e1 .printStackTrace ();
257+ }
258+ catch (final IOException e2 ) {
259+ e2 .printStackTrace ();
259260 }
260261 }
261262 });
@@ -294,7 +295,6 @@ public void run() {
294295 return Response .serverError ().build ();
295296 }
296297
297-
298298 if (!success ) {
299299 return Response .serverError ().build ();
300300 }
@@ -322,23 +322,24 @@ public Response deleteCsar(@ApiParam("ID of CSAR") @PathParam("csar") final Stri
322322
323323 return Response .noContent ().build ();
324324 }
325-
325+
326326 @ POST
327327 @ Path ("/transform" )
328328 @ ApiOperation (value = "Transform this CSAR to a new CSAR" )
329329 @ Consumes ({MediaType .APPLICATION_JSON , MediaType .APPLICATION_XML })
330330 @ Produces ({MediaType .APPLICATION_JSON , MediaType .APPLICATION_XML })
331331 public Response transformCsar (@ ApiParam (required = true ) final CsarTransformRequest request ) {
332-
333- String sourceCsarName = request .getSourceCsarName ();
334- String targetCsarName = request .getTargetCsarName ();
335-
336- CSARID csarId = this .csarService .generateTransformationPlans (new CSARID (sourceCsarName ), new CSARID (targetCsarName ));
337-
338- this .controlService .setDeploymentProcessStateStored (csarId );
332+
333+ final String sourceCsarName = request .getSourceCsarName ();
334+ final String targetCsarName = request .getTargetCsarName ();
335+
336+ final CSARID csarId =
337+ this .csarService .generateTransformationPlans (new CSARID (sourceCsarName ), new CSARID (targetCsarName ));
338+
339+ this .controlService .setDeploymentProcessStateStored (csarId );
339340 boolean success = this .controlService .invokeTOSCAProcessing (csarId );
340341
341-
342+
342343 if (success ) {
343344 final List <QName > serviceTemplates =
344345 this .engineService .getToscaReferenceMapper ().getServiceTemplateIDsContainedInCSAR (csarId );
@@ -351,15 +352,15 @@ public Response transformCsar(@ApiParam(required = true) final CsarTransformRequ
351352 success = false ;
352353 }
353354 }
354- }
355-
356- if (success ) {
355+ }
356+
357+ if (success ) {
357358 return Response .ok ().build ();
358359 } else {
359360 return Response .serverError ().build ();
360361 }
361362 }
362-
363+
363364
364365
365366 public void setCsarService (final CsarService csarService ) {
0 commit comments