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.licenseartifacts.impl.types.mixins.MixinEntitlementPoolEntityForVnfArtifact;
36 import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinFeatureGroupModel;
37 import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLicenseKeyGroupEntityForVnfArtifact;
39 import java.io.Writer;
40 import java.util.ArrayList;
41 import java.util.List;
42 import javax.xml.stream.XMLStreamException;
43 import javax.xml.stream.XMLStreamWriter;
45 @JacksonXmlRootElement(localName = "vf-license-model",
46 namespace = "http://xmlns.openecomp.org/asdc/license-model/1.0")
47 public class VnfLicenseArtifact extends XmlArtifact {
48 @JsonProperty(value = "vendor-name")
50 @JsonProperty(value = "vf-id")
52 List<FeatureGroupModel> featureGroups = new ArrayList<>();
54 public String getVspId() {
58 public void setVspId(String vspId) {
62 public String getVendorName() {
66 public void setVendorName(String vendorName) {
67 this.vendorName = vendorName;
70 @JacksonXmlProperty(isAttribute = false, localName = "feature-group")
71 @JacksonXmlElementWrapper(localName = "feature-group-list")
72 public List<FeatureGroupModel> getFeatureGroups() {
76 public void setFeatureGroups(List<FeatureGroupModel> featureGroups) {
77 this.featureGroups = featureGroups;
81 WstxOutputFactory wstxOutputFactory = new WstxOutputFactory() {
83 public XMLStreamWriter createXMLStreamWriter(Writer writer) throws XMLStreamException {
84 mConfig.setProperty(WstxInputProperties.P_RETURN_NULL_FOR_DEFAULT_NAMESPACE, true);
85 return super.createXMLStreamWriter(writer);
88 XmlFactory factory = new XmlFactory(new WstxInputFactory(), wstxOutputFactory);
90 xmlMapper = new XmlMapper(factory);
93 xmlMapper.addMixIn(EntitlementPoolEntity.class, MixinEntitlementPoolEntityForVnfArtifact.class);
94 xmlMapper.addMixIn(LicenseKeyGroupEntity.class, MixinLicenseKeyGroupEntityForVnfArtifact.class);
95 xmlMapper.addMixIn(FeatureGroupModel.class, MixinFeatureGroupModel.class);