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.vendorlicense.licenseartifacts.impl.types;
23 import com.ctc.wstx.api.WstxInputProperties;
24 import com.ctc.wstx.stax.WstxInputFactory;
25 import com.ctc.wstx.stax.WstxOutputFactory;
26 import com.fasterxml.jackson.annotation.JsonProperty;
27 import com.fasterxml.jackson.dataformat.xml.XmlFactory;
28 import com.fasterxml.jackson.dataformat.xml.XmlMapper;
29 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
30 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
31 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
32 import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
33 import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel;
34 import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
35 import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitXml;
36 import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinEntitlementPoolEntityForVnfArtifact;
37 import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinFeatureGroupModel;
38 import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLicenseKeyGroupEntityForVnfArtifact;
39 import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLimitArtifact;
41 import java.io.Writer;
42 import java.util.ArrayList;
43 import java.util.List;
44 import javax.xml.stream.XMLStreamException;
45 import javax.xml.stream.XMLStreamWriter;
47 @JacksonXmlRootElement(localName = "vf-license-model",
48 namespace = "http://xmlns.openecomp.org/asdc/license-model/1.0")
49 public class VnfLicenseArtifact extends XmlArtifact {
50 @JsonProperty(value = "vendor-name")
52 @JsonProperty(value = "vf-id")
54 List<FeatureGroupModel> featureGroups = new ArrayList<>();
56 public String getVspId() {
60 public void setVspId(String vspId) {
64 public String getVendorName() {
68 public void setVendorName(String vendorName) {
69 this.vendorName = vendorName;
72 @JacksonXmlProperty(isAttribute = false, localName = "feature-group")
73 @JacksonXmlElementWrapper(localName = "feature-group-list")
74 public List<FeatureGroupModel> getFeatureGroups() {
78 public void setFeatureGroups(List<FeatureGroupModel> featureGroups) {
79 this.featureGroups = featureGroups;
83 WstxOutputFactory wstxOutputFactory = new WstxOutputFactory() {
85 public XMLStreamWriter createXMLStreamWriter(Writer writer) throws XMLStreamException {
86 mConfig.setProperty(WstxInputProperties.P_RETURN_NULL_FOR_DEFAULT_NAMESPACE, true);
87 return super.createXMLStreamWriter(writer);
90 XmlFactory factory = new XmlFactory(new WstxInputFactory(), wstxOutputFactory);
92 xmlMapper = new XmlMapper(factory);
95 xmlMapper.addMixIn(EntitlementPoolEntity.class, MixinEntitlementPoolEntityForVnfArtifact.class);
96 xmlMapper.addMixIn(LicenseKeyGroupEntity.class, MixinLicenseKeyGroupEntityForVnfArtifact.class);
97 xmlMapper.addMixIn(FeatureGroupModel.class, MixinFeatureGroupModel.class);
98 xmlMapper.addMixIn(LimitXml.class, MixinLimitArtifact.class);