/** * Copyright (C) 2015 Orange * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Please modify this class to meet your needs * This class is not complete */ package com.francetelecom.clara.cloud.providersoap.incubator.v4.service; import com.francetelecom.clara.cloud.core.service.ManageApplicationRelease; import com.francetelecom.clara.cloud.coremodel.ApplicationRelease; import com.francetelecom.clara.cloud.deployment.logical.service.ManageLogicalDeployment; import com.francetelecom.clara.cloud.logicalmodel.LogicalDeployment; import com.francetelecom.clara.cloud.logicalmodel.samplecatalog.SampleAppFactory; import com.francetelecom.clara.cloud.providersoap.mapping.SoapMapper; import com.francetelecom.clara.cloud.service.backdoor.BackdoorService; import com.orange.clara.cloud.providersoap.incubator.v4.exception.InvalidLogicalDeploymentError; import com.orange.clara.cloud.providersoap.incubator.v4.model.CreateUserCommand; import com.orange.clara.cloud.providersoap.incubator.v4.model.SetLogicalDeploymentFromCatalogCommand; import com.orange.clara.cloud.providersoap.incubator.v4.service.InvalidLogicalDeploymentErrorFault; import com.orange.clara.cloud.providersoap.incubator.v4.service.PaasIncubatorService; import com.orange.clara.cloud.providersoap.security.v1.Credentials; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import java.util.Map; /** * This class was generated by Apache CXF 2.4.5 2012-02-21T15:12:46.851+01:00 * Generated source version: 2.4.5 */ @javax.jws.WebService( serviceName = "PaasIncubatorService", portName = "PaasIncubatorServicePort", targetNamespace = "http://www.orange.com/paas/incubator/v4/PaasIncubatorService", endpointInterface = "com.orange.clara.cloud.providersoap.incubator.v4.service.PaasIncubatorService") @org.apache.cxf.annotations.SchemaValidation public class PaasIncubatorServiceImpl implements PaasIncubatorService { private static final Logger LOG = LoggerFactory.getLogger(PaasIncubatorServiceImpl.class); private ManageApplicationRelease manageApplicationRelease; private ManageLogicalDeployment manageLogicalDeployment; private BackdoorService backdoorService; private SoapMapper mapper; // This is automatically inject by spring without any declaration (xml or javaconfig) @Autowired Map<String, SampleAppFactory> sampleAppsCatalog; /** * Set a logical deployment for a given release * * @throws InvalidLogicalDeploymentErrorFault The setting of a logical deployment for this release * failed * @parameter releaseUID The UUID of the release to set a logical deployment * for */ @Override public void setLogicalDeploymentFromCatalog(SetLogicalDeploymentFromCatalogCommand command, Credentials credentials) throws InvalidLogicalDeploymentErrorFault { try { String releaseUID = command.getReleaseUID(); String logicalModelNameReference= command.getLogicalModelNameReference(); // get the release ApplicationRelease release = manageApplicationRelease.findApplicationReleaseByUID(releaseUID); SampleAppFactory catalog; catalog = sampleAppsCatalog.get(logicalModelNameReference); if (catalog==null){ StringBuilder expectedNames= new StringBuilder(); for (String name : sampleAppsCatalog.keySet()) { expectedNames.append(name); expectedNames.append(','); } throw new IllegalStateException("LogicalModel is unkwown : Expected is " + expectedNames + "; But was : " + logicalModelNameReference); } // populate release with logical deployment using catalog // pre-defined logical deployment // Refetch to eagerly fetch all fields. LogicalDeployment logicalDeployment = manageLogicalDeployment.findLogicalDeployment(release.getLogicalDeployment().getId()); logicalDeployment = catalog.populateLogicalDeployment(logicalDeployment); logicalDeployment = manageLogicalDeployment.updateLogicalDeployment(logicalDeployment); logicalDeployment = manageLogicalDeployment.checkOverallConsistencyAndUpdateLogicalDeployment(logicalDeployment); } catch (Exception e) { LOG.warn("exception : " + e); throw (InvalidLogicalDeploymentErrorFault) mapper.map(e, InvalidLogicalDeploymentErrorFault.class, InvalidLogicalDeploymentError.class); } } @Override public void createUser(CreateUserCommand command, Credentials credentials) { String username = command.getUsername(); String ssoId = command.getSsoId(); String mail = command.getMail(); this.backdoorService.createPaasUser(ssoId, username, mail); } /** * Setter for mapper (Dozer) * * @param mapper */ public void setMapper(SoapMapper mapper) { this.mapper = mapper; } /** * Setter for manageApplicationRelease * * @param manageApplicationRelease */ public void setManageApplicationRelease(ManageApplicationRelease manageApplicationRelease) { this.manageApplicationRelease = manageApplicationRelease; } /** * Setter for manageLogicalDeployment * * @param manageLogicalDeployment */ public void setManageLogicalDeployment(ManageLogicalDeployment manageLogicalDeployment) { this.manageLogicalDeployment = manageLogicalDeployment; } public void setBackdoorService(BackdoorService backdoorService) { this.backdoorService = backdoorService; } }