Search in sources :

Example 11 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class TslMetaDataHandler method loadScriptData.

public void loadScriptData(InputStream in) {
    Reader fr = null;
    try {
        fr = new InputStreamReader(in, "UTF-8");
        XMLElement e = new CaseSensitiveXMLElement();
        e.parseFromReader(fr);
        parseMetaData(e);
    } catch (IOException e) {
        logger.error("Error: ", e);
    } finally {
        if (fr != null) {
            try {
                fr.close();
            } catch (IOException e1) {
                logger.error("Error: ", e1);
            }
        }
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) InputStreamReader(java.io.InputStreamReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) FileReader(java.io.FileReader) IOException(java.io.IOException) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 12 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class TslMetaDataHandler method addAdapters.

/**
 * @param xn
 * @param element
 */
private void addAdapters(XMLElement xn, String element) {
    Set<String> s = usesAdapter.get(element);
    if (s == null) {
        return;
    }
    for (Iterator<String> iter = s.iterator(); iter.hasNext(); ) {
        String adapter = iter.next();
        XMLElement xnincl = new CaseSensitiveXMLElement();
        xnincl.setName("adapters");
        xnincl.setAttribute("name", adapter);
        xn.addChild(xnincl);
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 13 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class TslMetaDataHandler method getScriptMetadata.

public XMLElement getScriptMetadata(String scriptName) {
    XMLElement x = new CaseSensitiveXMLElement();
    x.setName("metadata");
    addScriptElement(x, scriptName);
    return x;
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 14 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class TagMap method setInsert.

public void setInsert(Binary b) throws UserException {
    insert = b;
    String insertChild = new String(b.getData());
    XMLElement xe = new CaseSensitiveXMLElement(true);
    try {
        xe.parseFromReader(new StringReader(insertChild));
    } catch (IOException ex) {
        logger.error("XML parse problem: ", ex);
    }
    // get child based on childName set
    TagMap child = getChild();
    child.setChild(TagMap.parseXMLElement(xe, this.compact));
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) StringReader(java.io.StringReader) IOException(java.io.IOException) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 15 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class ScriptCompiler method generateDs.

private String generateDs(String packagePath, String script, List<Dependency> dependencies, Set<String> dependentResources) throws IOException {
    String fullName;
    String compiledDate = "" + Long.valueOf(new Date().getTime());
    if (packagePath.equals("")) {
        fullName = script;
    } else {
        fullName = packagePath + "/" + script;
    }
    String javaPackagePath;
    if ("".equals(packagePath)) {
        javaPackagePath = "defaultPackage";
    } else {
        javaPackagePath = packagePath.replaceAll("/", ".");
    }
    String tenant = tenantFromScriptPath(fullName);
    if (tenant == null) {
        tenant = getTentantSpecificDependency(dependencies);
    }
    String symbolicName = rpcNameFromScriptPath(fullName).replaceAll("/", ".");
    boolean hasTenantSpecificFile = tenant != null;
    XMLElement xe = new CaseSensitiveXMLElement("scr:component");
    xe.setAttribute("xmlns:scr", "http://www.osgi.org/xmlns/scr/v1.1.0");
    xe.setAttribute("immediate", "true");
    if (tenant != null) {
        xe.setAttribute("name", symbolicName + "_" + tenant);
    } else {
        xe.setAttribute("name", symbolicName);
    }
    xe.setAttribute("activate", "activate");
    xe.setAttribute("deactivate", "deactivate");
    xe.setAttribute("configuration-policy", "optional");
    XMLElement implementation = new CaseSensitiveXMLElement("implementation");
    xe.addChild(implementation);
    implementation.setAttribute("class", javaPackagePath + "." + script + "Factory");
    XMLElement service = new CaseSensitiveXMLElement("service");
    xe.addChild(service);
    XMLElement provide = new CaseSensitiveXMLElement("provide");
    service.addChild(provide);
    provide.setAttribute("interface", CompiledScriptFactory.class.getName());
    addProperty("navajo.scriptName", "String", symbolicName, xe);
    addProperty("navajo.compileddate", "String", compiledDate, xe);
    if (hasTenantSpecificFile) {
        addProperty("navajo.tenant", "String", tenant, xe);
        addProperty("service.ranking", "Integer", "1000", xe);
    } else {
        addProperty("service.ranking", "Integer", "0", xe);
        addProperty("navajo.tenant", "String", "default", xe);
    }
    for (String resource : dependentResources) {
        XMLElement dep = new CaseSensitiveXMLElement("reference");
        dep.setAttribute("bind", "set" + resource);
        dep.setAttribute("unbind", "clear" + resource);
        dep.setAttribute("policy", "static");
        dep.setAttribute("cardinality", "1..1");
        dep.setAttribute("interface", "javax.sql.DataSource");
        dep.setAttribute("target", "(navajo.resource.name=" + resource + ")");
        xe.addChild(dep);
    }
    PrintWriter w = new PrintWriter(navajoIOConfig.getOutputWriter(navajoIOConfig.getCompiledScriptPath(), packagePath, script, ".xml"));
    w.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    xe.write(w);
    w.flush();
    w.close();
    return compiledDate;
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) CompiledScriptFactory(com.dexels.navajo.script.api.CompiledScriptFactory) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) Date(java.util.Date) PrintWriter(java.io.PrintWriter)

Aggregations

CaseSensitiveXMLElement (com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)53 XMLElement (com.dexels.navajo.document.nanoimpl.XMLElement)49 IOException (java.io.IOException)10 InputStreamReader (java.io.InputStreamReader)7 FileReader (java.io.FileReader)5 HashMap (java.util.HashMap)5 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 APIException (com.dexels.navajo.article.APIException)2 Message (com.dexels.navajo.document.Message)2 Property (com.dexels.navajo.document.Property)2 BufferedReader (java.io.BufferedReader)2 InputStream (java.io.InputStream)2 PrintWriter (java.io.PrintWriter)2 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 StringWriter (java.io.StringWriter)2 ArrayList (java.util.ArrayList)2 XMLParseException (com.dexels.navajo.document.nanoimpl.XMLParseException)1 AdapterFieldDependency (com.dexels.navajo.mapping.compiler.meta.AdapterFieldDependency)1