2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.components.impl;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.EnumMap;
26 import java.util.HashMap;
27 import java.util.HashSet;
28 import java.util.Iterator;
29 import java.util.List;
31 import java.util.Map.Entry;
33 import java.util.function.Function;
34 import java.util.regex.Pattern;
35 import java.util.stream.Collectors;
37 import javax.servlet.ServletContext;
39 import org.apache.commons.lang3.StringUtils;
40 import org.apache.commons.lang3.tuple.ImmutablePair;
41 import org.openecomp.sdc.be.auditing.api.IAuditingManager;
42 import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
43 import org.openecomp.sdc.be.components.impl.ImportUtils.Constants;
44 import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
45 import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaTagNamesEnum;
46 import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
47 import org.openecomp.sdc.be.config.BeEcompErrorManager;
48 import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
49 import org.openecomp.sdc.be.dao.api.ActionStatus;
50 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
51 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
52 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
53 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
54 import org.openecomp.sdc.be.impl.ComponentsUtils;
55 import org.openecomp.sdc.be.impl.WebAppContextWrapper;
56 import org.openecomp.sdc.be.model.ArtifactDefinition;
57 import org.openecomp.sdc.be.model.CapabilityDefinition;
58 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
59 import org.openecomp.sdc.be.model.CsarInfo;
60 import org.openecomp.sdc.be.model.InterfaceDefinition;
61 import org.openecomp.sdc.be.model.LifecycleStateEnum;
62 import org.openecomp.sdc.be.model.PropertyDefinition;
63 import org.openecomp.sdc.be.model.RequirementDefinition;
64 import org.openecomp.sdc.be.model.Resource;
65 import org.openecomp.sdc.be.model.UploadResourceInfo;
66 import org.openecomp.sdc.be.model.User;
67 import org.openecomp.sdc.be.model.category.CategoryDefinition;
68 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
69 import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
70 import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
71 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
72 import org.openecomp.sdc.be.model.operations.impl.CapabilityTypeOperation;
73 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
74 import org.openecomp.sdc.common.config.EcompErrorName;
75 import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
76 import org.openecomp.sdc.common.util.ValidationUtils;
77 import org.openecomp.sdc.exception.ResponseFormat;
78 import org.slf4j.Logger;
79 import org.slf4j.LoggerFactory;
80 import org.springframework.beans.factory.annotation.Autowired;
81 import org.springframework.stereotype.Component;
82 import org.springframework.web.context.WebApplicationContext;
83 import org.yaml.snakeyaml.Yaml;
85 import fj.data.Either;
87 @Component("resourceImportManager")
88 public class ResourceImportManager {
90 private ServletContext servletContext;
93 private IAuditingManager auditingManager;
96 private ResourceBusinessLogic resourceBusinessLogic;
99 private IGraphLockOperation graphLockOperation;
102 protected ComponentsUtils componentsUtils;
104 public final static Pattern PROPERTY_NAME_PATTERN_IGNORE_LENGTH = Pattern
105 .compile("[\\w\\-\\_\\d\\:]+");
107 protected CapabilityTypeOperation capabilityTypeOperation;
109 protected ToscaOperationFacade toscaOperationFacade;
111 private ResponseFormatManager responseFormatManager;
113 private static Logger log = LoggerFactory.getLogger(ResourceImportManager.class.getName());
115 public void setToscaOperationFacade(ToscaOperationFacade toscaOperationFacade) {
116 this.toscaOperationFacade = toscaOperationFacade;
119 public Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> importNormativeResource(String resourceYml, UploadResourceInfo resourceMetaData, User creator, boolean createNewVersion, boolean needLock) {
121 LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction();
122 lifecycleChangeInfo.setUserRemarks("certification on import");
123 Function<Resource, Either<Boolean, ResponseFormat>> validator = (resource) -> resourceBusinessLogic.validatePropertiesDefaultValues(resource);
125 return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false, createNewVersion, needLock, null, null, false, null, null, false);
128 public Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> importNormativeResourceFromCsar(String resourceYml, UploadResourceInfo resourceMetaData, User creator, boolean createNewVersion, boolean needLock) {
130 LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction();
131 lifecycleChangeInfo.setUserRemarks("certification on import");
132 Function<Resource, Either<Boolean, ResponseFormat>> validator = (resource) -> resourceBusinessLogic.validatePropertiesDefaultValues(resource);
134 return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false, createNewVersion, needLock, null, null, false, null, null, false);
137 public Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> importCertifiedResource(String resourceYml, UploadResourceInfo resourceMetaData, User creator, Function<Resource, Either<Boolean, ResponseFormat>> validationFunction,
138 LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean isInTransaction, boolean createNewVersion, boolean needLock, Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, boolean forceCertificationAllowed, CsarInfo csarInfo, String nodeName, boolean isNested) {
139 Resource resource = new Resource();
140 ImmutablePair<Resource, ActionStatus> responsePair = new ImmutablePair<>(resource, ActionStatus.CREATED);
141 Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> response = Either.left(responsePair);
143 String latestCertifiedResourceId = null;
145 boolean shouldBeCertified = nodeTypeArtifactsToHandle == null || nodeTypeArtifactsToHandle.isEmpty();
146 setConstantMetaData(resource, shouldBeCertified);
147 setMetaDataFromJson(resourceMetaData, resource);
149 Either<Boolean, ResponseFormat> validateResourceFromYaml = populateResourceFromYaml(resourceYml, resource, isInTransaction);
150 if (validateResourceFromYaml.isRight()) {
151 ResponseFormat validationErrorResponse = validateResourceFromYaml.right().value();
152 auditErrorImport(resourceMetaData, creator, validationErrorResponse, true);
153 return Either.right(validationErrorResponse);
157 Either<Boolean, ResponseFormat> isValidResource = validationFunction.apply(resource);
158 if (isValidResource.isLeft()) {
159 // The flag createNewVersion if false doesn't create new version
160 if (!createNewVersion) {
161 Either<Resource, StorageOperationStatus> latestByName = toscaOperationFacade.getLatestByName(resource.getName());
162 if (latestByName.isLeft()) {
163 return Either.right(componentsUtils.getResponseFormatByResource(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, resource));
167 response = resourceBusinessLogic.createOrUpdateResourceByImport(resource, creator, true, isInTransaction, needLock, csarInfo, nodeName, isNested);
168 Either<Resource, ResponseFormat> changeStateResponse;
169 if (response.isLeft()) {
170 resource = response.left().value().left;
172 if(nodeTypeArtifactsToHandle !=null && !nodeTypeArtifactsToHandle.isEmpty()){
173 Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifactsRes =
174 resourceBusinessLogic.handleNodeTypeArtifacts(resource, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, creator, isInTransaction, false);
175 if(handleNodeTypeArtifactsRes.isRight()){
176 return Either.right(handleNodeTypeArtifactsRes.right().value());
179 latestCertifiedResourceId = getLatestCertifiedResourceId(resource);
180 changeStateResponse = resourceBusinessLogic.propagateStateToCertified(creator, resource, lifecycleChangeInfo, isInTransaction, needLock, forceCertificationAllowed);
181 if (changeStateResponse.isRight()) {
182 response = Either.right(changeStateResponse.right().value());
184 responsePair = new ImmutablePair<>(changeStateResponse.left().value(), response.left().value().right);
185 response = Either.left(responsePair);
189 ResponseFormat validationErrorResponse = isValidResource.right().value();
190 auditErrorImport(resourceMetaData, creator, validationErrorResponse, true);
191 response = Either.right(validationErrorResponse);
194 } catch (RuntimeException e) {
195 ResponseFormat exceptionResponse = handleImportResourceExecption(resourceMetaData, creator, true, e);
196 response = Either.right(exceptionResponse);
198 if (latestCertifiedResourceId != null && needLock) {
199 log.debug("unlock resource {}", latestCertifiedResourceId);
200 graphLockOperation.unlockComponent(latestCertifiedResourceId, NodeTypeEnum.Resource);
207 private String getLatestCertifiedResourceId(Resource resource) {
208 Map<String, String> allVersions = resource.getAllVersions();
209 Double latestCertifiedVersion = 0.0;
210 if (allVersions != null) {
211 for (String version : allVersions.keySet()) {
212 Double dVersion = Double.valueOf(version);
213 if ((dVersion > latestCertifiedVersion) && (version.endsWith(".0"))) {
214 latestCertifiedVersion = dVersion;
217 return allVersions.get(String.valueOf(latestCertifiedVersion));
223 public Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> importUserDefinedResource(String resourceYml, UploadResourceInfo resourceMetaData, User creator, boolean isReusable, boolean isInTransaction) {
225 Resource resource = new Resource();
226 ImmutablePair<Resource, ActionStatus> responsePair = new ImmutablePair<Resource, ActionStatus>(resource, ActionStatus.CREATED);
227 Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> response = Either.left(responsePair);
230 setMetaDataFromJson(resourceMetaData, resource);
232 Either<Boolean, ResponseFormat> validateResourceFromYaml = populateResourceFromYaml(resourceYml, resource, isInTransaction);
233 if (validateResourceFromYaml.isRight()) {
234 ResponseFormat validationErrorResponse = validateResourceFromYaml.right().value();
235 auditErrorImport(resourceMetaData, creator, validationErrorResponse, false);
236 return Either.right(validationErrorResponse);
240 // currently import VF isn't supported. In future will be supported
241 // import VF only with CSER file!!
242 if (ResourceTypeEnum.VF.equals(resource.getResourceType())) {
243 log.debug("Now import VF isn't supported. It will be supported in future with CSER file only");
244 return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
247 Either<Boolean, ResponseFormat> validateDerivedFromNotEmpty = resourceBusinessLogic.validateDerivedFromNotEmpty(creator, resource, AuditingActionEnum.CREATE_RESOURCE);
248 if (validateDerivedFromNotEmpty.isRight()) {
249 return Either.right(validateDerivedFromNotEmpty.right().value());
252 Either<Boolean, ResponseFormat> validatePropertiesTypes = resourceBusinessLogic.validatePropertiesDefaultValues(resource);
254 if (validatePropertiesTypes.isLeft()) {
255 response = resourceBusinessLogic.createOrUpdateResourceByImport(resource, creator, false, isInTransaction, true, null, null, false);
257 ResponseFormat validationErrorResponse = validatePropertiesTypes.right().value();
258 auditErrorImport(resourceMetaData, creator, validationErrorResponse, false);
259 response = Either.right(validationErrorResponse);
262 } catch (RuntimeException e) {
263 ResponseFormat exceptionResponse = handleImportResourceExecption(resourceMetaData, creator, false, e);
264 response = Either.right(exceptionResponse);
271 Either<Boolean, ResponseFormat> populateResourceFromYaml(String resourceYml, Resource resource, boolean inTransaction) {
272 @SuppressWarnings("unchecked")
273 Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
274 Map<String, Object> toscaJsonAll = (Map<String, Object>) new Yaml().load(resourceYml);
275 Map<String, Object> toscaJson = toscaJsonAll;
277 // Checks if exist and builds the node_types map
278 if (toscaJsonAll.containsKey(ToscaTagNamesEnum.NODE_TYPES.getElementName()) && resource.getResourceType()!=ResourceTypeEnum.CVFC) {
279 toscaJson = new HashMap<String, Object>();
280 toscaJson.put(ToscaTagNamesEnum.NODE_TYPES.getElementName(), toscaJsonAll.get(ToscaTagNamesEnum.NODE_TYPES.getElementName()));
283 Either<Resource, ResponseFormat> setDerivedFrom = setDerivedFrom(toscaJson, resource, inTransaction);
284 if (setDerivedFrom.isRight()) {
285 return Either.right(setDerivedFrom.right().value());
287 Resource parentResource = setDerivedFrom.left().value();
288 if(StringUtils.isEmpty(resource.getToscaResourceName()))
289 setToscaResourceName(toscaJson, resource);
290 setAttributes(toscaJson, resource);
291 eitherResult = setCapabilities(toscaJson, resource, parentResource);
292 if (eitherResult.isRight())
294 eitherResult = setProperties(toscaJson, resource);
295 if (eitherResult.isRight())
297 eitherResult = setRequirements(toscaJson, resource, parentResource);
298 if (eitherResult.isRight())
300 setInterfaceLifecycle(toscaJson, resource);
305 private void setToscaResourceName(Map<String, Object> toscaJson, Resource resource) {
306 Either<Map<String, Object>, ResultStatusEnum> toscaElement = ImportUtils.findFirstToscaMapElement(toscaJson, ToscaTagNamesEnum.NODE_TYPES);
307 if (toscaElement.isLeft() || toscaElement.left().value().size() == 1) {
308 String toscaResourceName = toscaElement.left().value().keySet().iterator().next();
309 resource.setToscaResourceName(toscaResourceName);
313 private void setInterfaceLifecycle(Map<String, Object> toscaJson, Resource resource) {
314 Either<Map<String, Object>, ResultStatusEnum> toscaInterfaces = ImportUtils.findFirstToscaMapElement(toscaJson, ToscaTagNamesEnum.INTERFACES);
315 if (toscaInterfaces.isLeft()) {
316 Map<String, Object> jsonInterfaces = toscaInterfaces.left().value();
317 Map<String, InterfaceDefinition> moduleInterfaces = new HashMap<String, InterfaceDefinition>();
318 Iterator<Entry<String, Object>> interfacesNameValue = jsonInterfaces.entrySet().iterator();
319 while (interfacesNameValue.hasNext()) {
320 Entry<String, Object> interfaceNameValue = interfacesNameValue.next();
321 Either<InterfaceDefinition, ResultStatusEnum> eitherInterface = createModuleInterface(interfaceNameValue.getValue());
322 if (eitherInterface.isRight()) {
323 log.info("error when creating interface:{}, for resource:{}", interfaceNameValue.getKey(), resource.getName());
325 moduleInterfaces.put(interfaceNameValue.getKey(), eitherInterface.left().value());
329 if (moduleInterfaces.size() > 0) {
330 resource.setInterfaces(moduleInterfaces);
335 private Either<InterfaceDefinition, ResultStatusEnum> createModuleInterface(Object interfaceJson) {
336 InterfaceDefinition interf = new InterfaceDefinition();
337 Either<InterfaceDefinition, ResultStatusEnum> result = Either.left(interf);
340 if (interfaceJson instanceof String) {
341 String requirementJsonString = (String) interfaceJson;
342 interf.setType(requirementJsonString);
343 } else if (interfaceJson instanceof Map) {
344 Map<String, Object> requirementJsonMap = (Map<String, Object>) interfaceJson;
345 if (requirementJsonMap.containsKey(ToscaTagNamesEnum.TYPE.getElementName())) {
346 String type = (String) requirementJsonMap.get(ToscaTagNamesEnum.TYPE.getElementName());
347 interf.setType(type);
348 interf.setUniqueId(type.toLowerCase());
351 result = Either.right(ResultStatusEnum.GENERAL_ERROR);
354 } catch (Exception e) {
355 BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeSystemError, "Import Resource- create interface");
356 BeEcompErrorManager.getInstance().logBeSystemError("Import Resource- create interface");
357 log.debug("error when creating interface, message:{}", e.getMessage(), e);
358 result = Either.right(ResultStatusEnum.GENERAL_ERROR);
364 private Either<Boolean, ResponseFormat> setRequirements(Map<String, Object> toscaJson, Resource resource, Resource parentResource) {// Note that parentResource can be null
365 Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
366 Either<List<Object>, ResultStatusEnum> toscaRequirements = ImportUtils.findFirstToscaListElement(toscaJson, ToscaTagNamesEnum.REQUIREMENTS);
367 if (toscaRequirements.isLeft()) {
368 List<Object> jsonRequirements = toscaRequirements.left().value();
369 Map<String, List<RequirementDefinition>> moduleRequirements = new HashMap<String, List<RequirementDefinition>>();
370 // Checking for name duplication
371 Set<String> reqNames = new HashSet<>();
372 // Getting flattened list of capabilities of parent node - cap name
374 Either<Map<String, String>, ResponseFormat> reqName2Type = getReqName2Type(parentResource);
375 if (reqName2Type.isRight()) {
376 ResponseFormat responseFormat = reqName2Type.right().value();
377 log.debug("Error during setting requirements of imported resource: {}", responseFormat);
378 return Either.right(responseFormat);
380 Map<String, String> reqName2TypeMap = reqName2Type.left().value();
381 for (Object jsonRequirementObj : jsonRequirements) {
383 Map<String, Object> requirementJsonWrapper = (Map<String, Object>) jsonRequirementObj;
384 String requirementName = requirementJsonWrapper.keySet().iterator().next();
385 String reqNameLowerCase = requirementName.toLowerCase();
386 if (reqNames.contains(reqNameLowerCase)) {
387 log.debug("More than one requirement with same name {} (case-insensitive) in imported TOSCA file is invalid", reqNameLowerCase);
388 return Either.right(componentsUtils.getResponseFormat(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME, "requirement", reqNameLowerCase));
390 reqNames.add(reqNameLowerCase);
391 Either<RequirementDefinition, ResponseFormat> eitherRequirement = createRequirementFromImportFile(requirementJsonWrapper.get(requirementName));
392 if (eitherRequirement.isRight()) {
393 log.info("error when creating Requirement:{}, for resource:{}", requirementName, resource.getName());
394 return Either.right(eitherRequirement.right().value());
396 RequirementDefinition requirementDef = eitherRequirement.left().value();
397 requirementDef.setName(requirementName);
398 if (moduleRequirements.containsKey(requirementDef.getCapability())) {
399 moduleRequirements.get(requirementDef.getCapability()).add(requirementDef);
401 List<RequirementDefinition> list = new ArrayList<RequirementDefinition>();
402 list.add(requirementDef);
403 moduleRequirements.put(requirementDef.getCapability(), list);
406 // Validating against req/cap of "derived from" node
407 Either<Boolean, ResponseFormat> validateVsParentCap = validateCapNameVsDerived(reqName2TypeMap, requirementDef.getCapability(), requirementDef.getName());
408 if (validateVsParentCap.isRight()) {
409 return Either.right(validateVsParentCap.right().value());
411 if (!validateVsParentCap.left().value()) {
412 log.debug("Requirement with name {} already exists in parent {}", requirementDef.getName(), parentResource.getName());
413 ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED, "requirement", requirementDef.getName().toLowerCase(), parentResource.getName());
414 return Either.right(responseFormat);
417 if (moduleRequirements.size() > 0) {
418 resource.setRequirements(moduleRequirements);
426 private Either<RequirementDefinition, ResponseFormat> createRequirementFromImportFile(Object requirementJson) {
427 RequirementDefinition requirement = new RequirementDefinition();
428 Either<RequirementDefinition, ResponseFormat> result = Either.left(requirement);
431 if (requirementJson instanceof String) {
432 String requirementJsonString = (String) requirementJson;
433 requirement.setCapability(requirementJsonString);
434 } else if (requirementJson instanceof Map) {
435 Map<String, Object> requirementJsonMap = (Map<String, Object>) requirementJson;
436 if (requirementJsonMap.containsKey(ToscaTagNamesEnum.CAPABILITY.getElementName())) {
437 requirement.setCapability((String) requirementJsonMap.get(ToscaTagNamesEnum.CAPABILITY.getElementName()));
440 if (requirementJsonMap.containsKey(ToscaTagNamesEnum.NODE.getElementName())) {
441 requirement.setNode((String) requirementJsonMap.get(ToscaTagNamesEnum.NODE.getElementName()));
444 if (requirementJsonMap.containsKey(ToscaTagNamesEnum.RELATIONSHIP.getElementName())) {
445 requirement.setRelationship((String) requirementJsonMap.get(ToscaTagNamesEnum.RELATIONSHIP.getElementName()));
447 if (requirementJsonMap.containsKey(ToscaTagNamesEnum.OCCURRENCES.getElementName())) {
448 List<Object> occurrencesList = (List) requirementJsonMap.get(ToscaTagNamesEnum.OCCURRENCES.getElementName());
449 Either<Boolean, ResponseFormat> validateAndSetOccurrencesStatus = validateOccurrences(occurrencesList);
450 if (validateAndSetOccurrencesStatus.isRight()) {
451 result = Either.right(validateAndSetOccurrencesStatus.right().value());
454 if (validateAndSetOccurrencesStatus.left().value() == true) {
455 requirement.setMinOccurrences(occurrencesList.get(0).toString());
456 requirement.setMaxOccurrences(occurrencesList.get(1).toString());
461 result = Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_YAML));
464 } catch (Exception e) {
465 BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeSystemError, "Import Resource - create Requirement");
466 BeEcompErrorManager.getInstance().logBeSystemError("Import Resource - create Requirement");
467 log.debug("error when creating requirement, message:{}", e.getMessage(), e);
468 result = Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_YAML));
474 private Either<Boolean, ResponseFormat> setProperties(Map<String, Object> toscaJson, Resource resource) {
475 Map<String, Object> reducedToscaJson = new HashMap<>(toscaJson);
476 ImportUtils.removeElementFromJsonMap(reducedToscaJson, "capabilities");
477 Either<Boolean, ResponseFormat> result = Either.left(true);
478 Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties = ImportUtils.getProperties(reducedToscaJson);
479 if (properties.isLeft()) {
480 List<PropertyDefinition> propertiesList = new ArrayList<>();
481 Map<String, PropertyDefinition> value = properties.left().value();
483 for (Entry<String, PropertyDefinition> entry : value.entrySet()) {
484 String name = entry.getKey();
485 if(!PROPERTY_NAME_PATTERN_IGNORE_LENGTH.matcher(name).matches()){
486 log.debug("The property with invalid name {} occured upon import resource {}. ", name, resource.getName());
487 result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_NAME, JsonPresentationFields.PROPERTY)));
489 PropertyDefinition propertyDefinition = entry.getValue();
490 propertyDefinition.setName(name);
491 propertiesList.add(propertyDefinition);
494 resource.setProperties(propertiesList);
495 } else if(properties.right().value() != ResultStatusEnum.ELEMENT_NOT_FOUND){
496 result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromResultStatusEnum(properties.right().value(), JsonPresentationFields.PROPERTY)));
501 private ResultStatusEnum setAttributes(Map<String, Object> toscaJson, Resource resource) {
502 ResultStatusEnum result = ResultStatusEnum.OK;
503 Either<Map<String, PropertyDefinition>, ResultStatusEnum> attributes = ImportUtils.getAttributes(toscaJson);
504 if (attributes.isLeft()) {
505 List<PropertyDefinition> attributeList = new ArrayList<>();
506 Map<String, PropertyDefinition> value = attributes.left().value();
508 for (Entry<String, PropertyDefinition> entry : value.entrySet()) {
509 String name = entry.getKey();
510 PropertyDefinition attributeDef = entry.getValue();
511 attributeDef.setName(name);
512 attributeList.add(attributeDef);
515 resource.setAttributes(attributeList);
517 result = attributes.right().value();
522 private Either<Resource, ResponseFormat> setDerivedFrom(Map<String, Object> toscaJson, Resource resource, boolean inTransaction) {
523 Either<String, ResultStatusEnum> toscaDerivedFromElement = ImportUtils.findFirstToscaStringElement(toscaJson, ToscaTagNamesEnum.DERIVED_FROM);
524 Resource derivedFromResource = null;
525 if (toscaDerivedFromElement.isLeft()) {
526 String derivedFrom = toscaDerivedFromElement.left().value();
527 log.debug("Derived from TOSCA name is {}", derivedFrom);
528 resource.setDerivedFrom(Arrays.asList(new String[] { derivedFrom }));
529 Either<Resource, StorageOperationStatus> latestByToscaResourceName = toscaOperationFacade.getLatestByToscaResourceName(derivedFrom);
531 if (latestByToscaResourceName.isRight()) {
532 StorageOperationStatus operationStatus = latestByToscaResourceName.right().value();
533 if (operationStatus.equals(StorageOperationStatus.NOT_FOUND)) {
534 operationStatus = StorageOperationStatus.PARENT_RESOURCE_NOT_FOUND;
536 log.debug("Error when fetching parent resource {}, error: {}", derivedFrom, operationStatus);
537 ActionStatus convertFromStorageResponse = componentsUtils.convertFromStorageResponse(operationStatus);
538 BeEcompErrorManager.getInstance().logBeComponentMissingError("Import TOSCA YAML", "resource", derivedFrom);
539 return Either.right(componentsUtils.getResponseFormat(convertFromStorageResponse, derivedFrom));
541 derivedFromResource = latestByToscaResourceName.left().value();
543 return Either.left(derivedFromResource);
546 private Either<Boolean, ResponseFormat> setCapabilities(Map<String, Object> toscaJson, Resource resource, Resource parentResource) {// Note that parentResource can be null
547 Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
548 Either<Map<String, Object>, ResultStatusEnum> toscaCapabilities = ImportUtils.findFirstToscaMapElement(toscaJson, ToscaTagNamesEnum.CAPABILITIES);
549 if (toscaCapabilities.isLeft()) {
550 Map<String, Object> jsonCapabilities = toscaCapabilities.left().value();
551 Map<String, List<CapabilityDefinition>> moduleCapabilities = new HashMap<String, List<CapabilityDefinition>>();
552 Iterator<Entry<String, Object>> capabilitiesNameValue = jsonCapabilities.entrySet().iterator();
553 Set<String> capNames = new HashSet<>();
554 // Getting flattened list of capabilities of parent node - cap name
556 Either<Map<String, String>, ResponseFormat> capName2Type = getCapName2Type(parentResource);
557 if (capName2Type.isRight()) {
558 ResponseFormat responseFormat = capName2Type.right().value();
559 log.debug("Error during setting capabilities of imported resource: {}", responseFormat);
560 return Either.right(responseFormat);
562 Map<String, String> capName2TypeMap = capName2Type.left().value();
563 while (capabilitiesNameValue.hasNext()) {
564 Entry<String, Object> capabilityNameValue = capabilitiesNameValue.next();
566 // Validating that no req/cap duplicates exist in imported YAML
567 String capNameLowerCase = capabilityNameValue.getKey().toLowerCase();
568 if (capNames.contains(capNameLowerCase)) {
569 log.debug("More than one capability with same name {} (case-insensitive) in imported TOSCA file is invalid", capNameLowerCase);
570 return Either.right(componentsUtils.getResponseFormat(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME, "capability", capNameLowerCase));
572 capNames.add(capNameLowerCase);
574 Either<CapabilityDefinition, ResponseFormat> eitherCapability = createCapabilityFromImportFile(capabilityNameValue.getValue());
575 if (eitherCapability.isRight()) {
576 log.debug("error when creating capability:{}, for resource:{}", capabilityNameValue.getKey(), resource.getName());
577 return Either.right(eitherCapability.right().value());
580 CapabilityDefinition capabilityDef = eitherCapability.left().value();
581 capabilityDef.setName(capabilityNameValue.getKey());
582 if (moduleCapabilities.containsKey(capabilityDef.getType())) {
583 moduleCapabilities.get(capabilityDef.getType()).add(capabilityDef);
585 List<CapabilityDefinition> list = new ArrayList<CapabilityDefinition>();
586 list.add(capabilityDef);
587 moduleCapabilities.put(capabilityDef.getType(), list);
590 // Validating against req/cap of "derived from" node
591 Either<Boolean, ResponseFormat> validateVsParentCap = validateCapNameVsDerived(capName2TypeMap, capabilityDef.getType(), capabilityDef.getName());
592 if (validateVsParentCap.isRight()) {
593 return Either.right(validateVsParentCap.right().value());
595 if (!validateVsParentCap.left().value()) {
596 // Here parentResource is for sure not null, so it's
598 log.debug("Capability with name {} already exists in parent {}", capabilityDef.getName(), parentResource.getName());
599 ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED, "capability", capabilityDef.getName().toLowerCase(), parentResource.getName());
600 return Either.right(responseFormat);
603 if (moduleCapabilities.size() > 0) {
604 resource.setCapabilities(moduleCapabilities);
612 private Either<Map<String, String>, ResponseFormat> getCapName2Type(Resource parentResource) {
613 Map<String, String> capName2type = new HashMap<>();
614 if (parentResource != null) {
615 Map<String, List<CapabilityDefinition>> capabilities = parentResource.getCapabilities();
616 if (capabilities != null) {
617 for (List<CapabilityDefinition> capDefinitions : capabilities.values()) {
618 for (CapabilityDefinition capDefinition : capDefinitions) {
619 String nameLowerCase = capDefinition.getName().toLowerCase();
620 if (capName2type.get(nameLowerCase) != null) {
621 String parentResourceName = parentResource.getName();
622 log.debug("Resource with name {} has more than one capability with name {}, ignoring case", parentResourceName, nameLowerCase);
623 BeEcompErrorManager.getInstance().logInternalDataError("Import resource", "Parent resource " + parentResourceName + " of imported resource has one or more capabilities with name " + nameLowerCase, ErrorSeverity.ERROR);
624 return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
626 capName2type.put(nameLowerCase, capDefinition.getType());
631 return Either.left(capName2type);
634 private Either<Map<String, String>, ResponseFormat> getReqName2Type(Resource parentResource) {
635 Map<String, String> reqName2type = new HashMap<>();
636 if (parentResource != null) {
637 Map<String, List<RequirementDefinition>> requirements = parentResource.getRequirements();
638 if (requirements != null) {
639 for (List<RequirementDefinition> reqDefinitions : requirements.values()) {
640 for (RequirementDefinition reqDefinition : reqDefinitions) {
641 String nameLowerCase = reqDefinition.getName().toLowerCase();
642 if (reqName2type.get(nameLowerCase) != null) {
643 String parentResourceName = parentResource.getName();
644 log.debug("Resource with name {} has more than one requirement with name {}, ignoring case", parentResourceName, nameLowerCase);
645 BeEcompErrorManager.getInstance().logInternalDataError("Import resource", "Parent resource " + parentResourceName + " of imported resource has one or more requirements with name " + nameLowerCase, ErrorSeverity.ERROR);
646 return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
648 reqName2type.put(nameLowerCase, reqDefinition.getCapability());
653 return Either.left(reqName2type);
656 private Either<Boolean, ResponseFormat> validateCapNameVsDerived(Map<String, String> parentCapName2Type, String childCapabilityType, String reqCapName) {
657 String capNameLowerCase = reqCapName.toLowerCase();
658 log.trace("Validating capability {} vs parent resource", capNameLowerCase);
659 String parentCapType = parentCapName2Type.get(capNameLowerCase);
660 if (parentCapType != null) {
661 if (childCapabilityType.equals(parentCapType)) {
662 log.debug("Capability with name {} is of same type {} for imported resource and its parent - this is OK", capNameLowerCase, childCapabilityType);
663 return Either.left(true);
665 Either<Boolean, StorageOperationStatus> capabilityTypeDerivedFrom = capabilityTypeOperation.isCapabilityTypeDerivedFrom(childCapabilityType, parentCapType);
666 if (capabilityTypeDerivedFrom.isRight()) {
667 log.debug("Couldn't check whether imported resource capability derives from its parent's capability");
668 ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(capabilityTypeDerivedFrom.right().value()));
669 return Either.right(responseFormat);
671 return Either.left(capabilityTypeDerivedFrom.left().value());
673 return Either.left(true);
676 private Either<CapabilityDefinition, ResponseFormat> createCapabilityFromImportFile(Object capabilityJson) {
678 CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
679 Either<CapabilityDefinition, ResponseFormat> result = Either.left(capabilityDefinition);
682 if (capabilityJson instanceof String) {
683 String capabilityJsonString = (String) capabilityJson;
684 capabilityDefinition.setType(capabilityJsonString);
685 } else if (capabilityJson instanceof Map) {
686 Map<String, Object> capabilityJsonMap = (Map<String, Object>) capabilityJson;
688 if (capabilityJsonMap.containsKey(ToscaTagNamesEnum.TYPE.getElementName())) {
689 capabilityDefinition.setType((String) capabilityJsonMap.get(ToscaTagNamesEnum.TYPE.getElementName()));
692 if (capabilityJsonMap.containsKey(ToscaTagNamesEnum.VALID_SOURCE_TYPES.getElementName())) {
693 capabilityDefinition.setValidSourceTypes((List<String>) capabilityJsonMap.get(ToscaTagNamesEnum.VALID_SOURCE_TYPES.getElementName()));
696 if (capabilityJsonMap.containsKey(ToscaTagNamesEnum.DESCRIPTION.getElementName())) {
697 capabilityDefinition.setDescription((String) capabilityJsonMap.get(ToscaTagNamesEnum.DESCRIPTION.getElementName()));
699 if (capabilityJsonMap.containsKey(ToscaTagNamesEnum.OCCURRENCES.getElementName())) {
700 List<Object> occurrencesList = (List) capabilityJsonMap.get(ToscaTagNamesEnum.OCCURRENCES.getElementName());
701 Either<Boolean, ResponseFormat> validateAndSetOccurrencesStatus = validateOccurrences(occurrencesList);
702 if (validateAndSetOccurrencesStatus.isRight()) {
703 result = Either.right(validateAndSetOccurrencesStatus.right().value());
706 if (validateAndSetOccurrencesStatus.left().value() == true) {
707 capabilityDefinition.setMinOccurrences(occurrencesList.get(0).toString());
708 capabilityDefinition.setMaxOccurrences(occurrencesList.get(1).toString());
711 if (capabilityJsonMap.containsKey(ToscaTagNamesEnum.PROPERTIES.getElementName())) {
713 Either<Map<String, PropertyDefinition>, ResultStatusEnum> propertiesRes = ImportUtils.getProperties(capabilityJsonMap);
714 if (propertiesRes.isRight()) {
715 result = Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND));
718 propertiesRes.left().value().entrySet().stream().forEach(e -> e.getValue().setName(e.getKey().toLowerCase()));
719 List<ComponentInstanceProperty> capabilityProperties = propertiesRes.left().value().values().stream().map(p -> new ComponentInstanceProperty(p, p.getDefaultValue(), null)).collect(Collectors.toList());
720 capabilityDefinition.setProperties(capabilityProperties);
723 } else if (!(capabilityJson instanceof List)) {
725 result = Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_YAML));
728 } catch (Exception e) {
729 BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeSystemError, "Import Resource - create capability");
730 BeEcompErrorManager.getInstance().logBeSystemError("Import Resource - create capability");
731 log.debug("error when creating capability, message:{}", e.getMessage(), e);
732 result = Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_YAML));
738 private ResponseFormat handleImportResourceExecption(UploadResourceInfo resourceMetaData, User user, boolean isNormative, RuntimeException e) {
739 String payloadName = (resourceMetaData != null) ? resourceMetaData.getPayloadName() : "";
740 BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeSystemError, "Import Resource " + payloadName);
741 BeEcompErrorManager.getInstance().logBeSystemError("Import Resource " + payloadName);
743 log.debug("Error when importing resource from payload:{} Exception text: {}", payloadName, e.getMessage(), e);
744 ResponseFormat errorResponseWrapper = getResponseFormatManager().getResponseFormat(ActionStatus.GENERAL_ERROR);
745 auditErrorImport(resourceMetaData, user, errorResponseWrapper, isNormative);
746 return errorResponseWrapper;
749 private void auditErrorImport(UploadResourceInfo resourceMetaData, User user, ResponseFormat errorResponseWrapper, boolean isNormative) {
750 EnumMap<AuditingFieldsKeysEnum, Object> auditingFields = new EnumMap<>(AuditingFieldsKeysEnum.class);
751 auditingFields.put(AuditingFieldsKeysEnum.AUDIT_ACTION, AuditingActionEnum.IMPORT_RESOURCE.getName());
752 auditingFields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceMetaData.getName());
753 auditingFields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE, ComponentTypeEnum.RESOURCE.getValue());
754 auditingFields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_VERSION, "");
755 auditingFields.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID, user.getUserId());
756 auditingFields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_STATE, "");
757 auditingFields.put(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID, "");
758 auditingFields.put(AuditingFieldsKeysEnum.AUDIT_STATUS, errorResponseWrapper.getStatus());
760 if (errorResponseWrapper.getMessageId() != null) {
761 message = errorResponseWrapper.getMessageId() + ": ";
763 message += errorResponseWrapper.getFormattedMessage();
764 auditingFields.put(AuditingFieldsKeysEnum.AUDIT_DESC, message);
765 auditingFields.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_NAME, user.getFirstName() + " " + user.getLastName());
767 String version, lifeCycleState;
769 version = Constants.FIRST_CERTIFIED_VERSION_VERSION;
770 lifeCycleState = LifecycleStateEnum.CERTIFIED.name();
773 lifeCycleState = LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name();
776 auditingFields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION, version);
777 auditingFields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE, lifeCycleState);
778 auditingFields.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TOSCA_NODE_TYPE, "");
780 getAuditingManager().auditEvent(auditingFields);
783 private void setMetaDataFromJson(UploadResourceInfo resourceMetaData, Resource resource) {
784 resource.setTags(resourceMetaData.getTags());
785 List<CategoryDefinition> categories = resourceMetaData.getCategories();
786 resource.setCategories(categories);
787 resource.setDescription(resourceMetaData.getDescription());
788 resource.setIcon(resourceMetaData.getResourceIconPath());
789 resource.setName(resourceMetaData.getName());
790 if (categories != null && !categories.isEmpty()) {
791 CategoryDefinition categoryDef = categories.get(0);
792 resource.setAbstract(false);
793 if (categoryDef != null && categoryDef.getName() != null && categoryDef.getName().equals(Constants.ABSTRACT_CATEGORY_NAME)) {
794 SubCategoryDefinition subCategoryDef = categoryDef.getSubcategories().get(0);
795 if (subCategoryDef != null && subCategoryDef.getName().equals(Constants.ABSTRACT_SUBCATEGORY)) {
796 resource.setAbstract(true);
800 resource.setContactId(resourceMetaData.getContactId());
801 resource.setCreatorUserId(resourceMetaData.getContactId());
803 if (resourceMetaData.getVendorName() != null) {
804 resource.setVendorName(resourceMetaData.getVendorName());
807 if (resourceMetaData.getVendorRelease() != null) {
808 resource.setVendorRelease(resourceMetaData.getVendorRelease());
811 resource.setResourceType(ResourceTypeEnum.valueOf(resourceMetaData.getResourceType()));
815 private void setConstantMetaData(Resource resource, boolean shouldBeCertified) {
817 LifecycleStateEnum state;
818 if(shouldBeCertified){
819 version = ImportUtils.Constants.FIRST_CERTIFIED_VERSION_VERSION;
820 state = ImportUtils.Constants.NORMATIVE_TYPE_LIFE_CYCLE;
822 version = ImportUtils.Constants.FIRST_NON_CERTIFIED_VERSION;
823 state = ImportUtils.Constants.NORMATIVE_TYPE_LIFE_CYCLE_NOT_CERTIFIED_CHECKOUT;
825 resource.setVersion(version);
826 resource.setLifecycleState(state);
827 resource.setHighestVersion(ImportUtils.Constants.NORMATIVE_TYPE_HIGHEST_VERSION);
828 resource.setVendorName(ImportUtils.Constants.VENDOR_NAME);
829 resource.setVendorRelease(ImportUtils.Constants.VENDOR_RELEASE);
833 private Either<Boolean, ResponseFormat> validateOccurrences(List<Object> occurrensesList) {
835 if (!ValidationUtils.validateListNotEmpty(occurrensesList)) {
836 log.debug("Occurrenses list empty");
837 ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_OCCURRENCES);
838 return Either.right(responseFormat);
841 if (occurrensesList.size() < 2) {
842 log.debug("Occurrenses list size not 2");
843 ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_OCCURRENCES);
844 return Either.right(responseFormat);
846 Object minObj = occurrensesList.get(0);
847 Object maxObj = occurrensesList.get(1);
848 Integer minOccurrences = null;
849 Integer maxOccurrences = null;
850 if (minObj instanceof Integer)
851 minOccurrences = (Integer) minObj;
853 log.debug("Invalid occurrenses format. low_bound occurrense must be Integer {}", minObj);
854 ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_OCCURRENCES);
855 return Either.right(responseFormat);
857 if (minOccurrences < 0) {
858 log.debug("Invalid occurrenses format.low_bound occurrense negative {}", minOccurrences);
859 ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_OCCURRENCES);
860 return Either.right(responseFormat);
863 if (maxObj instanceof String) {
864 if (maxObj.equals("UNBOUNDED")) {
865 return Either.left(true);
867 log.debug("Invalid occurrenses format. Max occurrence is {}", maxObj);
868 ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_OCCURRENCES);
869 return Either.right(responseFormat);
872 if (maxObj instanceof Integer)
873 maxOccurrences = (Integer) maxObj;
875 log.debug("Invalid occurrenses format. Max occurrence is {}", maxObj);
876 ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_OCCURRENCES);
877 return Either.right(responseFormat);
880 if (maxOccurrences <= 0 || maxOccurrences < minOccurrences) {
881 log.debug("Invalid occurrenses format. min occurrence is {}, Max occurrence is {}", minOccurrences, maxOccurrences);
882 ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_OCCURRENCES);
883 return Either.right(responseFormat);
887 return Either.left(true);
891 public void init(ServletContext servletContext) {
892 if (this.servletContext == null) {
893 synchronized (this) {
894 if (this.servletContext == null) {
895 this.servletContext = servletContext;
896 responseFormatManager = ResponseFormatManager.getInstance();
897 resourceBusinessLogic = getResourceBL(servletContext);
903 public boolean isResourceExist(String resourceName) {
904 return resourceBusinessLogic.isResourceExist(resourceName);
907 private ResourceBusinessLogic getResourceBL(ServletContext context) {
908 WebAppContextWrapper webApplicationContextWrapper = (WebAppContextWrapper) context.getAttribute(org.openecomp.sdc.common.api.Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR);
909 WebApplicationContext webApplicationContext = webApplicationContextWrapper.getWebAppContext(context);
910 ResourceBusinessLogic resourceBl = webApplicationContext.getBean(ResourceBusinessLogic.class);
914 public ServletContext getServletContext() {
915 return servletContext;
918 public IAuditingManager getAuditingManager() {
919 return auditingManager;
922 public ResponseFormatManager getResponseFormatManager() {
923 return responseFormatManager;
926 public void setResponseFormatManager(ResponseFormatManager responseFormatManager) {
927 this.responseFormatManager = responseFormatManager;
930 public ResourceBusinessLogic getResourceBusinessLogic() {
931 return resourceBusinessLogic;
934 public void setResourceBusinessLogic(ResourceBusinessLogic resourceBusinessLogic) {
935 this.resourceBusinessLogic = resourceBusinessLogic;
938 public Logger getLog() {
942 public static void setLog(Logger log) {
943 ResourceImportManager.log = log;
946 public IGraphLockOperation getGraphLockOperation() {
947 return graphLockOperation;
950 public void setGraphLockOperation(IGraphLockOperation graphLockOperation) {
951 this.graphLockOperation = graphLockOperation;
954 public void setServletContext(ServletContext servletContext) {
955 this.servletContext = servletContext;
958 public void setAuditingManager(IAuditingManager auditingManager) {
959 this.auditingManager = auditingManager;