Example usage for org.xml.sax InputSource setPublicId

List of usage examples for org.xml.sax InputSource setPublicId

Introduction

In this page you can find the example usage for org.xml.sax InputSource setPublicId.

Prototype

public void setPublicId(String publicId) 

Source Link

Document

Set the public identifier for this input source.

Usage

From source file:de.tudarmstadt.ukp.dkpro.core.io.ancora.AncoraReader.java

@Override
public void getNext(JCas aJCas) throws IOException, CollectionException {
    Resource res = nextFile();/*from  w  w  w .j av a 2s  . c  o m*/
    initCas(aJCas, res);

    // Set up language
    if (getLanguage() != null) {
        aJCas.setDocumentLanguage(getLanguage());
    }

    // Configure mapping only now, because now the language is set in the CAS
    try {
        posMappingProvider.configure(aJCas.getCas());
    } catch (AnalysisEngineProcessException e1) {
        throw new IOException(e1);
    }

    InputStream is = null;
    try {
        is = CompressionUtils.getInputStream(res.getLocation(), res.getInputStream());

        // Create handler
        AncoraHandler handler = new AncoraHandler();
        handler.setJCas(aJCas);
        handler.setLogger(getLogger());

        // Parse XML
        SAXParserFactory pf = SAXParserFactory.newInstance();
        SAXParser parser = pf.newSAXParser();

        InputSource source = new InputSource(is);
        source.setPublicId(res.getLocation());
        source.setSystemId(res.getLocation());
        parser.parse(source, handler);
    } catch (ParserConfigurationException | SAXException e) {
        throw new IOException(e);
    } finally {
        closeQuietly(is);
    }

    if (dropSentencesMissingPosTags) {
        List<FeatureStructure> toRemove = new ArrayList<>();

        // Remove sentences without pos TAGs
        for (Sentence s : select(aJCas, Sentence.class)) {
            boolean remove = false;
            for (Token t : selectCovered(Token.class, s)) {
                if (t.getPos() == null) {
                    toRemove.add(s);
                    remove = true;
                    break;
                }
            }

            if (remove) {
                for (Token t : selectCovered(Token.class, s)) {
                    toRemove.add(t);
                    if (t.getLemma() != null) {
                        toRemove.add(t.getLemma());
                    }
                    if (t.getPos() != null) {
                        toRemove.add(t.getPos());
                    }
                }
            }
        }

        for (FeatureStructure fs : toRemove) {
            aJCas.getCas().removeFsFromIndexes(fs);
        }

        // Remove tokens without pos tags that are located *BETWEEN* sentences!
        toRemove.clear();
        for (Token t : select(aJCas, Token.class)) {
            if (t.getPos() == null) {
                toRemove.add(t);
                if (t.getLemma() != null) {
                    toRemove.add(t.getLemma());
                }
                if (t.getPos() != null) {
                    toRemove.add(t.getPos());
                }
            }
        }

        for (FeatureStructure fs : toRemove) {
            aJCas.getCas().removeFsFromIndexes(fs);
        }
    }
}

From source file:de.tudarmstadt.ukp.dkpro.core.io.tei.TeiReader.java

private void nextTeiElement() throws CollectionException, IOException {
    if (teiElementIterator == null) {
        currentTeiElement = null;/*from  w  ww  . j  a va 2  s  .c o  m*/
        return;
    }

    while (!teiElementIterator.hasNext() && super.hasNext()) {
        currentResource = nextFile();

        InputStream is = null;

        try {
            is = currentResource.getInputStream();

            if (currentResource.getPath().endsWith(".gz")) {
                is = new GZIPInputStream(is);
            }

            InputSource source = new InputSource(is);
            source.setPublicId(currentResource.getLocation());
            source.setSystemId(currentResource.getLocation());

            SAXReader reader = new SAXReader();
            Document xml = reader.read(source);

            final XPath teiPath = new Dom4jXPath("//tei:TEI");
            teiPath.addNamespace("tei", "http://www.tei-c.org/ns/1.0");

            List<Element> teiElements = teiPath.selectNodes(xml);

            //            System.out.printf("Found %d TEI elements in %s.%n", teiElements.size(),
            //                  currentResource.getLocation());

            teiElementIterator = teiElements.iterator();
            currentTeiElementNumber = 0;
        } catch (DocumentException e) {
            throw new IOException(e);
        } catch (JaxenException e) {
            throw new IOException(e);
        } finally {
            closeQuietly(is);
        }
    }

    currentTeiElement = teiElementIterator.hasNext() ? teiElementIterator.next() : null;
    currentTeiElementNumber++;

    if (!super.hasNext() && !teiElementIterator.hasNext()) {
        // Mark end of processing.
        teiElementIterator = null;
    }
}

From source file:de.tudarmstadt.ukp.clarin.webanno.tei.TeiReader.java

private void nextTeiElement() throws CollectionException, IOException {
    if (teiElementIterator == null) {
        currentTeiElement = null;/*from   w  w  w  .  jav  a2s  .c o m*/
        return;
    }

    while (!teiElementIterator.hasNext() && super.hasNext()) {
        currentResource = nextFile();

        InputStream is = null;

        try {
            is = currentResource.getInputStream();

            if (currentResource.getPath().endsWith(".gz")) {
                is = new GZIPInputStream(is);
            }

            InputSource source = new InputSource(is);
            source.setPublicId(currentResource.getLocation());
            source.setSystemId(currentResource.getLocation());

            SAXReader reader = new SAXReader();
            Document xml = reader.read(source);

            final XPath teiPath = new Dom4jXPath("//tei:TEI");
            teiPath.addNamespace("tei", "http://www.tei-c.org/ns/1.0");

            @SuppressWarnings("unchecked")
            List<Element> teiElements = teiPath.selectNodes(xml);

            teiElementIterator = teiElements.iterator();
            currentTeiElementNumber = 0;
        } catch (DocumentException e) {
            throw new IOException(e);
        } catch (JaxenException e) {
            throw new IOException(e);
        } finally {
            closeQuietly(is);
        }
    }

    currentTeiElement = teiElementIterator.hasNext() ? teiElementIterator.next() : null;
    currentTeiElementNumber++;

    if (!super.hasNext() && !teiElementIterator.hasNext()) {
        // Mark end of processing.
        teiElementIterator = null;
    }
}

From source file:net.sf.ginp.setup.SetupManagerImpl.java

/**
 * @param stream// w  w w  .  j a va  2s .  c  om
 * @return
 * @throws IOException
 * @throws DocumentException
 */
private Document validateConfig(final InputStream stream) throws IOException, DocumentException {
    SAXReader read = new SAXReader(true);
    InputSource source = new InputSource();
    StringReader stringRead = new StringReader(GinpUtil.readBufferIntoMemory(stream));
    String ginpFile = this.getClass().getResource("/net/sf/ginp/config/ginp.dtd").toExternalForm();
    ginpFile = ginpFile.substring(0, ginpFile.lastIndexOf("/") + 1);
    source.setSystemId(ginpFile);
    source.setPublicId("ginp.dtd");
    source.setCharacterStream(stringRead);

    return read.read(source);
}

From source file:org.solmix.runtime.support.spring.ContainerEntityResolver.java

@Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    InputSource source = super.resolveEntity(publicId, systemId);
    if (null == source && null != systemId) {
        // try the schema and dtd resolver in turn, ignoring the suffix in publicId
        LOG.info("Attempting to resolve systemId {}", systemId);
        source = schemaResolver.resolveEntity(publicId, systemId);
        if (null == source) {
            source = dtdResolver.resolveEntity(publicId, systemId);
        }/*from   w  w  w .j a  v  a 2  s  .c  o  m*/
    }
    String resourceLocation = schemaMappings.get(systemId);
    if (resourceLocation != null && publicId == null) {
        Resource resource = new ClassPathResource(resourceLocation, classLoader);
        if (resource != null && resource.exists()) {
            source.setPublicId(systemId);
            source.setSystemId(resource.getURL().toString());
        }
    }
    return source;
}

From source file:net.sf.ginp.setup.SetupManagerImpl.java

/**
 * @throws SetupException if there's a problem reading the doc
 * note: don't be fooled, we can't report the path of the
 *       offending document because it is supplied as a Stream.
 * @throws IOException/*from   w  ww.  j  a v  a 2s  .  com*/
 * @see net.sf.ginp.setup.SetupManager#testValidConfig(java.io.InputStream)
 */
public final Document testValidConfig(final InputStream stream) throws SetupException, IOException {
    String reader = GinpUtil.readBufferIntoMemory(stream);

    try {
        return validateConfig(new ByteArrayInputStream(reader.getBytes()));
    } catch (DocumentException d) {
        SAXReader read = new SAXReader(false);

        try {
            InputSource source = new InputSource();
            source.setCharacterStream(new StringReader(reader));

            String ginpFile = this.getClass().getResource("/net/sf/ginp/config/ginp.dtd").toExternalForm();
            ginpFile = ginpFile.substring(0, ginpFile.lastIndexOf("/") + 1);
            source.setSystemId(ginpFile);
            source.setPublicId("ginp.dtd");

            Document document = read.read(source);
            List list = document.selectNodes("/ginp/collection/users");
            list.addAll(document.selectNodes("/ginp/collection/admins"));

            Iterator iter = list.iterator();

            while (iter.hasNext()) {
                Element e = (Element) iter.next();
                String value = e.getText();
                String[] users = value.split(",");

                for (int x = 0; x < users.length; x++) {
                    if (users[x].length() == 0) {
                        continue;
                    }

                    Element element = e.addElement("username");
                    element.setText(users[x].trim());
                }

                e.setText("");
            }

            try {
                return validateConfig(new ByteArrayInputStream(document.asXML().getBytes()));
            } catch (DocumentException e) {
                //Some XML parsers don't support validation
                if (e.getMessage().indexOf("not supported") >= 0) {
                    log.warn("Validation Not Supported by your XML parser", e);

                    return document;
                } else {
                    log.error("Validation Error:", e);
                }

                throw e;
            }
        } catch (DocumentException e) {
            log.error("throwing new SetupException", e);
            throw new SetupException(GinpUtil.message(TROUBLE_PARSING), d);
        }
    }
}

From source file:org.data.support.beans.factory.xml.ResourceEntityResolver.java

@Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    InputSource source = super.resolveEntity(publicId, systemId);
    if (source == null && systemId != null) {
        String resourcePath = null;
        try {/* ww w.j  a v  a2s  .  co  m*/
            String decodedSystemId = URLDecoder.decode(systemId);
            String givenUrl = new URL(decodedSystemId).toString();
            String systemRootUrl = new File("").toURL().toString();
            // Try relative to resource base if currently in system root.
            if (givenUrl.startsWith(systemRootUrl)) {
                resourcePath = givenUrl.substring(systemRootUrl.length());
            }
        } catch (Exception ex) {
            // Typically a MalformedURLException or AccessControlException.
            if (logger.isDebugEnabled()) {
                logger.debug("Could not resolve XML entity [" + systemId + "] against system root URL", ex);
            }
            // No URL (or no resolvable URL) -> try relative to resource base.
            resourcePath = systemId;
        }
        if (resourcePath != null) {
            if (logger.isTraceEnabled()) {
                logger.trace(
                        "Trying to locate XML entity [" + systemId + "] as resource [" + resourcePath + "]");
            }
            Resource resource = this.resourceLoader.getResource(resourcePath);
            source = new InputSource(resource.getInputStream());
            source.setPublicId(publicId);
            source.setSystemId(systemId);
            if (logger.isDebugEnabled()) {
                logger.debug("Found XML entity [" + systemId + "]: " + resource);
            }
        }
    }
    return source;
}

From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java

private InputSource resolveResourceFromRegisteredSchemasByNamespace(String namespaceURI) {
    if (namespaceURI != null) {
        if (parsedSchemas.containsKey(namespaceURI)) {
            SchemaDescription schemaDescription = parsedSchemas.get(namespaceURI);
            if (schemaDescription.canInputStream()) {
                InputStream inputStream = schemaDescription.openInputStream();
                InputSource source = new InputSource();
                source.setByteStream(inputStream);
                //source.setSystemId(schemaDescription.getPath());
                // Make sure that both publicId and systemId are always set to schema namespace
                // this helps to avoid double processing of the schemas
                source.setSystemId(namespaceURI);
                source.setPublicId(namespaceURI);
                return source;
            } else {
                throw new IllegalStateException("Requested resolution of schema "
                        + schemaDescription.getSourceDescription() + " that does not support input stream");
            }/*from  w ww.  ja  va2s .c  o  m*/
        }
    }
    return null;
}

From source file:org.apache.axis2.deployment.resolver.AARFileBasedURIResolver.java

public InputSource resolveEntity(String targetNamespace, String schemaLocation, String baseUri) {
    //no issue with abloslute schemas 
    // this schema can be in a relative location for another base scheama. so first
    // try to see the proper location

    lastImportLocation = URI.create(baseUri).resolve(schemaLocation);
    if (isAbsolute(lastImportLocation.toString())) {
        return super.resolveEntity(targetNamespace, schemaLocation, baseUri);
    } else {//from  www.ja v  a2s  .  c om
        //validate
        if ((baseUri == null || "".equals(baseUri)) && schemaLocation.startsWith("..")) {
            throw new RuntimeException("Unsupported schema location " + schemaLocation);
        }

        ZipInputStream zin = null;
        try {
            zin = new ZipInputStream(new FileInputStream(aarFile));

            ZipEntry entry;
            byte[] buf = new byte[1024];
            int read;
            ByteArrayOutputStream out;
            String searchingStr = lastImportLocation.toString();
            while ((entry = zin.getNextEntry()) != null) {
                String entryName = entry.getName().toLowerCase();
                if (entryName.equalsIgnoreCase(searchingStr)) {
                    out = new ByteArrayOutputStream();
                    while ((read = zin.read(buf)) > 0) {
                        out.write(buf, 0, read);
                    }
                    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
                    InputSource inputSoruce = new InputSource(in);
                    inputSoruce.setSystemId(lastImportLocation.getPath());
                    inputSoruce.setPublicId(targetNamespace);
                    return inputSoruce;
                }
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                if (zin != null) {
                    zin.close();
                }
            } catch (IOException e) {
                log.debug(e);
            }
        }

    }

    log.info("AARFileBasedURIResolver: Unable to resolve" + lastImportLocation);
    return null;
}

From source file:org.apache.axis2.jaxbri.CodeGenerationUtility.java

/**
 * @param additionalSchemas/*from  w w w .j  a  v  a2 s  .c  o  m*/
 * @throws RuntimeException
 */
public static TypeMapper processSchemas(final List schemas, Element[] additionalSchemas,
        CodeGenConfiguration cgconfig) throws RuntimeException {
    try {

        //check for the imported types. Any imported types are supposed to be here also
        if (schemas == null || schemas.isEmpty()) {
            //there are no types to be code generated
            //However if the type mapper is left empty it will be a problem for the other
            //processes. Hence the default type mapper is set to the configuration
            return new DefaultTypeMapper();
        }

        final Map schemaToInputSourceMap = new HashMap();
        final Map<String, StringBuffer> publicIDToStringMap = new HashMap<String, StringBuffer>();

        //create the type mapper
        JavaTypeMapper mapper = new JavaTypeMapper();

        String baseURI = cgconfig.getBaseURI();
        if (!baseURI.endsWith("/")) {
            baseURI = baseURI + "/";
        }

        for (int i = 0; i < schemas.size(); i++) {
            XmlSchema schema = (XmlSchema) schemas.get(i);
            InputSource inputSource = new InputSource(new StringReader(getSchemaAsString(schema)));
            //here we have to set a proper system ID. otherwise when processing the
            // included schaemas for this schema we have a problem
            // it creates the system ID using this target namespace value

            inputSource.setSystemId(baseURI + "xsd" + i + ".xsd");
            inputSource.setPublicId(schema.getTargetNamespace());
            schemaToInputSourceMap.put(schema, inputSource);
        }

        File outputDir = new File(cgconfig.getOutputLocation(), "src");
        outputDir.mkdir();

        Map nsMap = cgconfig.getUri2PackageNameMap();
        EntityResolver resolver = new EntityResolver() {
            public InputSource resolveEntity(String publicId, String systemId)
                    throws SAXException, IOException {
                InputSource returnInputSource = null;
                XmlSchema key = null;
                for (Iterator iter = schemaToInputSourceMap.keySet().iterator(); iter.hasNext();) {
                    key = (XmlSchema) iter.next();
                    String nsp = key.getTargetNamespace();
                    if (nsp != null && nsp.equals(publicId)) {

                        // when returning the input stream we have to always return a new
                        // input stream.
                        // sinc jaxbri internally consumes the input stream it gives an
                        // exception.
                        returnInputSource = new InputSource(new StringReader(getSchemaAsString(key)));
                        InputSource existingInputSource = (InputSource) schemaToInputSourceMap.get(key);
                        returnInputSource.setSystemId(existingInputSource.getSystemId());
                        returnInputSource.setPublicId(existingInputSource.getPublicId());
                        break;
                    }
                }
                if (returnInputSource == null) {
                    // then we have to find this using the file system
                    if (systemId != null) {
                        returnInputSource = new InputSource(systemId);
                        returnInputSource.setSystemId(systemId);
                    }
                }

                if (returnInputSource == null) {
                    if (publicId != null) {

                        if (!publicIDToStringMap.containsKey(publicId)) {
                            URL url = new URL(publicId);
                            BufferedReader bufferedReader = new BufferedReader(
                                    new InputStreamReader(url.openStream()));
                            StringBuffer stringBuffer = new StringBuffer();
                            String str = null;
                            while ((str = bufferedReader.readLine()) != null) {
                                stringBuffer.append(str);
                            }
                            publicIDToStringMap.put(publicId, stringBuffer);
                        }

                        String schemaString = publicIDToStringMap.get(publicId).toString();
                        returnInputSource = new InputSource(new StringReader(schemaString));
                        returnInputSource.setPublicId(publicId);
                        returnInputSource.setSystemId(publicId);
                    }
                }
                return returnInputSource;
            }
        };

        Map properties = cgconfig.getProperties();
        String bindingFileName = (String) properties.get(BINDING_FILE_NAME);

        XmlSchema key = null;
        for (Iterator schemaIter = schemaToInputSourceMap.keySet().iterator(); schemaIter.hasNext();) {

            SchemaCompiler sc = XJC.createSchemaCompiler();
            if (bindingFileName != null) {
                if (bindingFileName.endsWith(".jar")) {
                    scanEpisodeFile(new File(bindingFileName), sc);
                } else {
                    InputSource inputSoruce = new InputSource(new FileInputStream(bindingFileName));
                    inputSoruce.setSystemId(new File(bindingFileName).toURI().toString());
                    sc.getOptions().addBindFile(inputSoruce);
                }

            }

            key = (XmlSchema) schemaIter.next();

            if (nsMap != null) {
                Iterator iterator = nsMap.entrySet().iterator();
                while (iterator.hasNext()) {
                    Map.Entry entry = (Map.Entry) iterator.next();
                    String namespace = (String) entry.getKey();
                    String pkg = (String) nsMap.get(namespace);
                    registerNamespace(sc, namespace, pkg);
                }
            }

            sc.setEntityResolver(resolver);

            sc.setErrorListener(new ErrorListener() {
                public void error(SAXParseException saxParseException) {
                    log.error(saxParseException.getMessage());
                    log.debug(saxParseException.getMessage(), saxParseException);
                }

                public void fatalError(SAXParseException saxParseException) {
                    log.error(saxParseException.getMessage());
                    log.debug(saxParseException.getMessage(), saxParseException);
                }

                public void warning(SAXParseException saxParseException) {
                    log.warn(saxParseException.getMessage());
                    log.debug(saxParseException.getMessage(), saxParseException);
                }

                public void info(SAXParseException saxParseException) {
                    log.info(saxParseException.getMessage());
                    log.debug(saxParseException.getMessage(), saxParseException);
                }
            });

            sc.parseSchema((InputSource) schemaToInputSourceMap.get(key));
            sc.getOptions().addGrammar((InputSource) schemaToInputSourceMap.get(key));

            for (Object property : properties.keySet()) {
                String propertyName = (String) property;
                if (propertyName.startsWith("X")) {
                    String[] args = null;
                    String propertyValue = (String) properties.get(property);
                    if (propertyValue != null) {
                        args = new String[] { "-" + propertyName, propertyValue };
                    } else {
                        args = new String[] { "-" + propertyName };
                    }
                    sc.getOptions().parseArguments(args);
                }
            }

            // Bind the XML
            S2JJAXBModel jaxbModel = sc.bind();

            if (jaxbModel == null) {
                throw new RuntimeException("Unable to generate code using jaxbri");
            }

            // Emit the code artifacts
            JCodeModel codeModel = jaxbModel.generateCode(null, null);
            FileCodeWriter writer = new FileCodeWriter(outputDir);
            codeModel.build(writer);

            Collection mappings = jaxbModel.getMappings();

            Iterator iter = mappings.iterator();

            while (iter.hasNext()) {
                Mapping mapping = (Mapping) iter.next();
                QName qn = mapping.getElement();
                String typeName = mapping.getType().getTypeClass().fullName();

                mapper.addTypeMappingName(qn, typeName);
            }

            //process the unwrapped parameters
            if (!cgconfig.isParametersWrapped()) {
                //figure out the unwrapped operations
                List axisServices = cgconfig.getAxisServices();
                for (Iterator servicesIter = axisServices.iterator(); servicesIter.hasNext();) {
                    AxisService axisService = (AxisService) servicesIter.next();
                    for (Iterator operations = axisService.getOperations(); operations.hasNext();) {
                        AxisOperation op = (AxisOperation) operations.next();

                        if (WSDLUtil.isInputPresentForMEP(op.getMessageExchangePattern())) {
                            AxisMessage message = op.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
                            if (message != null && message.getParameter(Constants.UNWRAPPED_KEY) != null) {

                                Mapping mapping = jaxbModel.get(message.getElementQName());
                                List elementProperties = mapping.getWrapperStyleDrilldown();
                                for (int j = 0; j < elementProperties.size(); j++) {
                                    Property elementProperty = (Property) elementProperties.get(j);

                                    QName partQName = WSDLUtil.getPartQName(op.getName().getLocalPart(),
                                            WSDLConstants.INPUT_PART_QNAME_SUFFIX,
                                            elementProperty.elementName().getLocalPart());
                                    //this type is based on a primitive type- use the
                                    //primitive type name in this case
                                    String fullJaveName = elementProperty.type().fullName();
                                    if (elementProperty.type().isArray()) {
                                        fullJaveName = fullJaveName.concat("[]");
                                    }
                                    mapper.addTypeMappingName(partQName, fullJaveName);

                                    if (elementProperty.type().isPrimitive()) {
                                        mapper.addTypeMappingStatus(partQName, Boolean.TRUE);
                                    }
                                    if (elementProperty.type().isArray()) {
                                        mapper.addTypeMappingStatus(partQName, Constants.ARRAY_TYPE);
                                    }
                                }
                            }
                        }

                        if (WSDLUtil.isOutputPresentForMEP(op.getMessageExchangePattern())) {
                            AxisMessage message = op.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
                            if (message != null && message.getParameter(Constants.UNWRAPPED_KEY) != null) {

                                Mapping mapping = jaxbModel.get(message.getElementQName());
                                List elementProperties = mapping.getWrapperStyleDrilldown();
                                for (int j = 0; j < elementProperties.size(); j++) {
                                    Property elementProperty = (Property) elementProperties.get(j);

                                    QName partQName = WSDLUtil.getPartQName(op.getName().getLocalPart(),
                                            WSDLConstants.OUTPUT_PART_QNAME_SUFFIX,
                                            elementProperty.elementName().getLocalPart());
                                    //this type is based on a primitive type- use the
                                    //primitive type name in this case
                                    String fullJaveName = elementProperty.type().fullName();
                                    if (elementProperty.type().isArray()) {
                                        fullJaveName = fullJaveName.concat("[]");
                                    }
                                    mapper.addTypeMappingName(partQName, fullJaveName);

                                    if (elementProperty.type().isPrimitive()) {
                                        mapper.addTypeMappingStatus(partQName, Boolean.TRUE);
                                    }
                                    if (elementProperty.type().isArray()) {
                                        mapper.addTypeMappingStatus(partQName, Constants.ARRAY_TYPE);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        // Return the type mapper
        return mapper;

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}