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);
}
}
}
}
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);
}
}
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;
}
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));
}
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;
}
Aggregations