ApplicationWrapper.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.utils.wadl;

  21. import org.slf4j.Logger;

  22. import java.util.HashMap;
  23. import java.util.List;
  24. import java.util.Map;

  25. import org.jvnet.ws.wadl.ast.ApplicationNode;
  26. import org.openspcoop2.utils.xml.AbstractXMLUtils;
  27. import org.openspcoop2.utils.xml.XMLException;
  28. import org.openspcoop2.utils.xml.XSDSchemaCollection;
  29. import org.openspcoop2.utils.xml.XSDUtils;

  30. /**
  31.  * ApplicationWrapper
  32.  *
  33.  *
  34.  * @author Andrea Poli (apoli@link.it)
  35.  * @author $Author$
  36.  * @version $Rev$, $Date$
  37.  */
  38. public class ApplicationWrapper {

  39.     private ApplicationNode applicationNode;
  40.     private Map<String, byte[]> resources = new HashMap<String, byte[]>();
  41.     private Map<String, List<String>> mappingNamespaceLocations = new HashMap<>();
  42.     private AbstractXMLUtils xmlUtils = null;
  43.     private XSDUtils xsdUtils = null;
  44.    
  45.     public ApplicationWrapper(ApplicationNode applicationNode,
  46.             Map<String, byte[]> resources, Map<String, List<String>> mappingNamespaceLocations,
  47.             AbstractXMLUtils xmlUtils){
  48.         this.applicationNode = applicationNode;
  49.         this.resources = resources;
  50.         this.mappingNamespaceLocations = mappingNamespaceLocations;
  51.         this.xmlUtils = xmlUtils;
  52.         this.xsdUtils = new XSDUtils(this.xmlUtils);
  53.     }
  54.    
  55.     public ApplicationNode getApplicationNode() {
  56.         return this.applicationNode;
  57.     }

  58.     public Map<String, byte[]> getResources() {
  59.         return this.resources;
  60.     }

  61.     public Map<String, List<String>> getMappingNamespaceLocations() {
  62.         return this.mappingNamespaceLocations;
  63.     }
  64.    
  65.     public void addResource(String systemId, byte[] resource) throws XMLException{
  66.        
  67.         if(this.resources.containsKey(systemId)==false){
  68.        
  69.             // registro risorsa con systemid
  70.             this.resources.put(systemId, resource);
  71.    
  72.             // registro namespace
  73.             this.xsdUtils.registraMappingNamespaceLocations(resource, systemId, this.mappingNamespaceLocations);
  74.            
  75.         }
  76.     }
  77.    
  78.     public XSDSchemaCollection buildSchemaCollection(Logger log) throws XMLException{
  79.         return this.xsdUtils.buildSchemaCollection(this.resources, this.mappingNamespaceLocations, log);
  80.     }

  81. }