use of com.twinsoft.util.StringEx in project convertigo by convertigo.
the class Supervision method getServiceResult.
@Override
protected String getServiceResult(HttpServletRequest request) throws Exception {
boolean isConvertigoStarted = Engine.isStarted;
boolean bCacheDatabase = false;
String cacheType = EnginePropertiesManager.getProperty(PropertyName.CACHE_MANAGER_CLASS);
if ("com.twinsoft.convertigo.engine.cache.DatabaseCacheManager".equals(cacheType)) {
try {
SqlRequester sqlRequester = new SqlRequester(DatabaseCacheManager.DB_PROP_FILE_NAME);
sqlRequester.open();
Statement statement = null;
ResultSet resultSet = null;
StringEx sqlRequest = new StringEx(sqlRequester.getProperty(DatabaseCacheManager.PROPERTIES_SQL_REQUEST_GET_CACHE_ENTRY));
sqlRequest.replace("{RequestString}", "<supervision>");
String sSqlRequest = sqlRequest.toString();
try {
statement = sqlRequester.connection.createStatement();
resultSet = statement.executeQuery(sSqlRequest);
} finally {
if (resultSet != null) {
resultSet.close();
}
if (statement != null) {
statement.close();
}
sqlRequester.close();
}
bCacheDatabase = true;
} catch (Exception e) {
System.err.println("supervision: error while the database access for the Convertigo Cache");
e.printStackTrace();
}
}
String result = "";
result += "convertigo.started=" + (isConvertigoStarted ? "OK" : "KO") + "\n";
result += "convertigo.database.cache=" + (bCacheDatabase ? "OK" : "KO") + "\n";
return result;
}
use of com.twinsoft.util.StringEx in project convertigo by convertigo.
the class RequestableObject method getBackupWsdlTypes.
protected String getBackupWsdlTypes() throws Exception {
String backupWsdlTypes = null;
String wsdlBackupDir = getWsdlBackupDir();
File dir = new File(wsdlBackupDir);
if (dir.exists()) {
File file = new File(wsdlBackupDir + "/" + getName() + ".xml");
if (file.exists()) {
DocumentBuilder documentBuilder = XMLUtils.getDefaultDocumentBuilder();
Document document = documentBuilder.parse(file);
Element fake = document.getDocumentElement();
StringEx sx = new StringEx(XMLUtils.prettyPrintElement(fake, true, true));
sx.replace("<" + fake_root + ">", "");
sx.replace("</" + fake_root + ">", "");
backupWsdlTypes = sx.toString();
}
}
return backupWsdlTypes;
}
use of com.twinsoft.util.StringEx in project convertigo by convertigo.
the class RequestableObject method backupWsdlTypes.
protected void backupWsdlTypes(Element element) throws TransformerFactoryConfigurationError, Exception {
if (wsdlType.equals(""))
return;
StringEx sx = new StringEx(wsdlType);
sx.replaceAll("<cdata>", "<![CDATA[");
sx.replaceAll("</cdata>", "]]>");
String sDom = "<" + fake_root + ">\n" + sx.toString() + "</" + fake_root + ">";
DocumentBuilder documentBuilder = XMLUtils.getDefaultDocumentBuilder();
Document document = documentBuilder.parse(new InputSource(new StringReader(sDom)));
String wsdlBackupDir = getWsdlBackupDir(element);
File dir = new File(wsdlBackupDir);
if (!dir.exists())
dir.mkdirs();
File file = new File(wsdlBackupDir + "/" + getName() + ".xml");
XMLUtils.saveXml(document, file);
}
use of com.twinsoft.util.StringEx in project convertigo by convertigo.
the class RequestableObject method migrateToXsdTypes.
public String migrateToXsdTypes() {
String xsdTypes = null;
try {
// Retrieve backup wsdlTypes
String backupWsdlTypes = getBackupWsdlTypes();
if (backupWsdlTypes != null) {
StringEx sx = new StringEx(backupWsdlTypes);
// Replace ccc_xxxResponse by ccc__xxxResponse (Fix ticket #252)
sx.replace("_" + getName() + "Response\"", "__" + getName() + "Response\"");
// Fix missing type for sql_output element (SqlTransaction)
sx.replace("<xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"sql_output\"/>", "<xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"sql_output\" type=\"xsd:string\"/>");
// Replace xxxResponse by yyy__xxxResponseData
sx.replace("\"" + getName() + "Response\"", "\"" + getXsdTypePrefix() + getName() + "ResponseData\"");
sx.replace(":" + getName() + "Response\"", ":" + getXsdTypePrefix() + getName() + "ResponseData\"");
sx.replace("__" + getName() + "Response\"", "__" + getName() + "ResponseData\"");
sx.replaceAll("tns:", getProject().getName() + "_ns:");
xsdTypes = generateXsdRequestData() + " " + sx.toString();
}
} catch (Exception e) {
Engine.logBeans.error("Unable to migrate to XSD types for requestable \"" + getName() + "\"", e);
}
return xsdTypes;
}
use of com.twinsoft.util.StringEx in project convertigo by convertigo.
the class HtmlTransaction method migrateToXsdTypes.
@Override
public String migrateToXsdTypes() {
String xsdTypes = null;
try {
// Retrieve backup wsdlTypes
String backupWsdlTypes = getBackupWsdlTypes();
if (backupWsdlTypes != null) {
String types = backupWsdlTypes;
if (isDefault) {
/* Generate again : correct bug of ref in group */
types = generateWsdlType(null);
if (!isPublicAccessibility()) {
HtmlConnector connector = (HtmlConnector) getParent();
String prefix = (connector.isDefault ? "" : connector.getName() + "__");
String transactionName = StringUtils.normalize(prefix + getName(), true) + "Response";
/* remove complexType for transaction*/
int i = types.indexOf("<xsd:complexType name=\"" + transactionName + "\">");
if (i != -1) {
int j = types.indexOf("</xsd:complexType>", i);
if (j != -1)
types = types.substring(0, i) + types.substring(j + "</xsd:complexType>\n".length());
}
}
}
// Replace xxxResponse by yyy__xxxResponseData
StringEx sx = new StringEx(types);
sx.replace("\"" + getName() + "Response\"", "\"" + getXsdTypePrefix() + getName() + "ResponseData\"");
sx.replace(":" + getName() + "Response\"", ":" + getXsdTypePrefix() + getName() + "ResponseData\"");
sx.replace("__" + getName() + "Response\"", "__" + getName() + "ResponseData\"");
sx.replaceAll("tns:", getProject().getName() + "_ns:");
xsdTypes = generateXsdRequestData() + " " + sx.toString();
}
} catch (Exception e) {
Engine.logBeans.warn("Unable to migrate to XSD types for requestable \"" + getName() + "\"", e);
}
return xsdTypes;
}
Aggregations