use of com.twinsoft.convertigo.beans.core.RequestableObject in project convertigo by convertigo.
the class NgxPickerComposite method lookupModelData.
private Map<String, Object> lookupModelData(TVObject tvObject) {
Map<String, Object> data = new HashMap<String, Object>();
Map<String, String> params = new HashMap<String, String>();
DatabaseObject dbo = null;
String searchPath = "";
Object object = tvObject.getObject();
JSONObject infos = tvObject.getInfos();
if (object != null) {
try {
if (object instanceof RequestableObject) {
dbo = (RequestableObject) object;
searchPath = "";
} else if (object instanceof DesignDocument) {
dbo = (DesignDocument) object;
DesignDocument dd = (DesignDocument) dbo;
params.put("ddoc", dd.getName());
params.put("view", tvObject.getParent().getName());
params.put("include_docs", infos.has("include_docs") ? infos.getString("include_docs") : "false");
searchPath = tvObject.getName().startsWith("get") ? ".rows.value" : "";
} else if (object instanceof UIControlDirective) {
dbo = (UIControlDirective) object;
do {
UIControlDirective directive = (UIControlDirective) dbo;
String rootDboName = "";
if (directive.getPage() != null) {
rootDboName = directive.getPage().getName();
} else if (directive.getMenu() != null) {
rootDboName = directive.getMenu().getName();
}
MobileSmartSourceType msst = directive.getSourceSmartType();
MobileSmartSource mss = msst.getSmartSource();
if (mss != null) {
dbo = mss.getDatabaseObject(rootDboName);
params.putAll(mss.getParameters());
searchPath = mss.getModelPath().replaceAll("\\?\\.", ".") + searchPath;
} else {
dbo = null;
}
} while (dbo != null && dbo instanceof UIControlDirective);
} else if (object instanceof UIForm) {
dbo = (UIForm) object;
searchPath = "";
} else if (object instanceof ApplicationComponent) {
dbo = (ApplicationComponent) object;
params.put("json", infos.toString());
searchPath = "";
} else if (object instanceof UIActionStack) {
dbo = (UIActionStack) object;
searchPath = "";
} else if (object instanceof IAction) {
if (object instanceof UIDynamicAction) {
dbo = (UIDynamicAction) object;
searchPath = "";
} else if (object instanceof UICustomAction) {
dbo = (UICustomAction) object;
searchPath = "";
}
} else if (object instanceof UISharedComponent) {
dbo = (UISharedComponent) object;
searchPath = "";
}
} catch (Exception e) {
e.printStackTrace();
}
}
data.put("databaseObject", dbo);
data.put("params", params);
data.put("searchPath", searchPath);
return data;
}
use of com.twinsoft.convertigo.beans.core.RequestableObject in project convertigo by convertigo.
the class MobilePickerComposite method getJsonModel.
private JSONObject getJsonModel(Map<String, Object> data, DatabaseObject databaseObject) throws Exception {
JSONObject jsonModel = new JSONObject();
Map<String, String> params;
DatabaseObject dbo;
String dataPath;
if (databaseObject == null) {
dbo = (DatabaseObject) data.get("databaseObject");
params = GenericUtils.cast(data.get("params"));
dataPath = (String) data.get("searchPath");
} else {
dbo = databaseObject;
params = new HashMap<String, String>();
dataPath = "";
}
if (dbo != null) {
// case of requestable
if (dbo instanceof RequestableObject) {
RequestableObject ro = (RequestableObject) dbo;
Project project = ro.getProject();
String responseEltName = ro.getXsdTypePrefix() + ro.getName() + "Response";
boolean isDocumentNode = JsonRoot.docNode.equals(project.getJsonRoot()) && dataPath.isEmpty();
XmlSchema schema = Engine.theApp.schemaManager.getSchemaForProject(project.getName());
XmlSchemaObject xso = SchemaMeta.getXmlSchemaObject(schema, ro);
if (xso != null) {
Document document = XmlSchemaUtils.getDomInstance(xso);
// System.out.println(XMLUtils.prettyPrintDOM(document));
String jsonString = XMLUtils.XmlToJson(document.getDocumentElement(), true, true);
JSONObject jsonObject = new JSONObject(jsonString);
String searchPath = "document." + responseEltName + ".response";
searchPath += isDocumentNode || !dataPath.startsWith(".document") ? dataPath : dataPath.replaceFirst("\\.document", "");
JSONObject jsonOutput = findJSONObject(jsonObject, searchPath);
jsonModel = isDocumentNode ? new JSONObject().put("document", jsonOutput) : jsonOutput;
}
} else if (dbo instanceof DesignDocument) {
DesignDocument dd = (DesignDocument) dbo;
Connector connector = dd.getConnector();
String ddoc = params.get("ddoc");
String view = params.get("view");
String viewName = ddoc + "/" + view;
String includeDocs = params.get("include_docs");
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
ConnectorEditor connectorEditor = ConvertigoPlugin.getDefault().getConnectorEditor(connector);
if (connectorEditor == null) {
try {
connectorEditor = (ConnectorEditor) activePage.openEditor(new ConnectorEditorInput(connector), "com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor");
} catch (PartInitException e) {
ConvertigoPlugin.logException(e, "Error while loading the connector editor '" + connector.getName() + "'");
}
}
if (connectorEditor != null) {
// activate connector's editor
activePage.activate(connectorEditor);
// set transaction's parameters
Transaction transaction = connector.getTransactionByName(CouchDbConnector.internalView);
((GetViewTransaction) transaction).setViewname(viewName);
((GetViewTransaction) transaction).setQ_include_docs(includeDocs);
Variable view_reduce = ((GetViewTransaction) transaction).getVariable(CouchParam.prefix + "reduce");
view_reduce.setValueOrNull(false);
// execute view transaction
connectorEditor.getDocument(CouchDbConnector.internalView, false);
}
}
});
} else // case of UIForm
if (dbo instanceof UIForm) {
// JSONObject jsonObject = new JSONObject("{\"controls\":{\"['area']\":{\"value\":\"\"}}}");
JSONObject jsonObject = new JSONObject(((UIForm) dbo).computeJsonModel());
String searchPath = dataPath;
JSONObject jsonOutput = findJSONObject(jsonObject, searchPath);
jsonModel = jsonOutput;
} else // case of UIACtionStack
if (dbo instanceof UIActionStack) {
JSONObject jsonObject = new JSONObject(((UIActionStack) dbo).computeJsonModel());
String searchPath = dataPath;
JSONObject jsonOutput = findJSONObject(jsonObject, searchPath);
jsonModel = jsonOutput;
} else // case of UIDynamicAction or UICustomAction
if (dbo instanceof IAction) {
JSONObject jsonObject = new JSONObject();
if (dbo instanceof UIDynamicAction) {
UIDynamicAction uida = (UIDynamicAction) dbo;
jsonObject = new JSONObject(uida.computeJsonModel());
IonBean ionBean = uida.getIonBean();
if (ionBean != null) {
String name = ionBean.getName();
if ("CallSequenceAction".equals(name)) {
String qname = ionBean.getProperty("requestable").getValue().toString();
DatabaseObject sequence = Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
if (sequence != null) {
JSONObject targetJsonModel = getJsonModel(data, sequence);
if (jsonObject.has("out")) {
jsonObject.put("out", targetJsonModel);
}
}
} else if ("CallFullSyncAction".equals(name)) {
String qname = ionBean.getProperty("requestable").getValue().toString();
String verb = ionBean.getProperty("verb").getValue().toString();
Connector connector = (Connector) Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
if (connector != null) {
XmlSchema schema = Engine.theApp.schemaManager.getSchemaForProject(connector.getProject().getName());
AbstractCouchDbTransaction act = null;
if ("all".equals(verb))
act = new AllDocsTransaction();
else if ("create".equals(verb))
act = new PutDatabaseTransaction();
else if ("destroy".equals(verb))
act = new DeleteDatabaseTransaction();
else if ("get".equals(verb))
act = new GetDocumentTransaction();
else if ("delete".equals(verb))
act = new DeleteDocumentTransaction();
else if ("delete_attachment".equals(verb))
act = new DeleteDocumentAttachmentTransaction();
else if ("post".equals(verb))
act = new PostDocumentTransaction();
else if ("put_attachment".equals(verb))
act = new PutDocumentAttachmentTransaction();
else if ("replicate_push".equals(verb))
act = new PostReplicateTransaction();
else if ("reset".equals(verb))
act = new ResetDatabaseTransaction();
else if ("view".equals(verb))
act = new GetViewTransaction();
if (act != null) {
QName typeQName = act.getComplexTypeAffectation();
XmlSchemaType xmlSchemaType = schema.getTypeByName(typeQName);
Document document = XmlSchemaUtils.getDomInstance(xmlSchemaType);
String jsonString = XMLUtils.XmlToJson(document.getDocumentElement(), true, true);
JSONObject jsonOutput = new JSONObject(jsonString).getJSONObject("document");
cleanJsonModel(jsonOutput);
jsonOutput.remove("_c8oMeta");
jsonOutput.remove("error");
jsonOutput.remove("reason");
if (jsonObject.has("out")) {
jsonObject.put("out", jsonOutput);
}
}
}
} else if ("FullSyncGetAction".equals(name)) {
String qname = ionBean.getProperty("requestable").getValue().toString();
String docid = ionBean.getProperty("_id").getValue().toString();
Connector connector = (Connector) Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
if (connector != null) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
ConnectorEditor connectorEditor = ConvertigoPlugin.getDefault().getConnectorEditor(connector);
if (connectorEditor == null) {
try {
connectorEditor = (ConnectorEditor) activePage.openEditor(new ConnectorEditorInput(connector), "com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor");
} catch (PartInitException e) {
ConvertigoPlugin.logException(e, "Error while loading the connector editor '" + connector.getName() + "'");
}
}
if (connectorEditor != null) {
// activate connector's editor
activePage.activate(connectorEditor);
// set transaction's parameters
Transaction transaction = connector.getTransactionByName(CouchDbConnector.internalDocument);
Variable var_docid = ((GetDocumentTransaction) transaction).getVariable(CouchParam.docid.param());
var_docid.setValueOrNull(docid);
// execute view transaction
connectorEditor.getDocument(CouchDbConnector.internalDocument, false);
}
}
});
}
} else if ("FullSyncViewAction".equals(name)) {
String fsview = ionBean.getProperty("fsview").getValue().toString();
String includeDocs = ionBean.getProperty("include_docs").getValue().toString();
String reduce = ionBean.getProperty("reduce").getValue().toString();
String qname = fsview.substring(0, fsview.lastIndexOf('.'));
DesignDocument dd = (DesignDocument) Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
Connector connector = dd.getConnector();
String viewName = dd.getName() + "/" + fsview.substring(fsview.lastIndexOf('.') + 1);
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
ConnectorEditor connectorEditor = ConvertigoPlugin.getDefault().getConnectorEditor(connector);
if (connectorEditor == null) {
try {
connectorEditor = (ConnectorEditor) activePage.openEditor(new ConnectorEditorInput(connector), "com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor");
} catch (PartInitException e) {
ConvertigoPlugin.logException(e, "Error while loading the connector editor '" + connector.getName() + "'");
}
}
if (connectorEditor != null) {
// activate connector's editor
activePage.activate(connectorEditor);
// set transaction's parameters
Transaction transaction = connector.getTransactionByName(CouchDbConnector.internalView);
((GetViewTransaction) transaction).setViewname(viewName);
((GetViewTransaction) transaction).setQ_include_docs(includeDocs);
Variable view_reduce = ((GetViewTransaction) transaction).getVariable(CouchParam.prefix + "reduce");
view_reduce.setValueOrNull(reduce);
// execute view transaction
connectorEditor.getDocument(CouchDbConnector.internalView, false);
}
}
});
} else if (name.startsWith("FullSync")) {
if (ionBean.getProperty("requestable") != null) {
String qname = ionBean.getProperty("requestable").getValue().toString();
DatabaseObject connector = Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
if (connector != null) {
XmlSchema schema = Engine.theApp.schemaManager.getSchemaForProject(connector.getProject().getName());
AbstractCouchDbTransaction act = null;
if ("FullSyncDeleteAction".equals(name))
act = new DeleteDocumentTransaction();
else if ("FullSyncDeleteAttachmentAction".equals(name))
act = new DeleteDocumentAttachmentTransaction();
else if ("FullSyncPostAction".equals(name))
act = new PostDocumentTransaction();
else if ("FullSyncPutAttachmentAction".equals(name))
act = new PutDocumentAttachmentTransaction();
if (act != null) {
QName typeQName = act.getComplexTypeAffectation();
XmlSchemaType xmlSchemaType = schema.getTypeByName(typeQName);
Document document = XmlSchemaUtils.getDomInstance(xmlSchemaType);
String jsonString = XMLUtils.XmlToJson(document.getDocumentElement(), true, true);
JSONObject jsonOutput = new JSONObject(jsonString).getJSONObject("document");
cleanJsonModel(jsonOutput);
jsonOutput.remove("_c8oMeta");
jsonOutput.remove("error");
jsonOutput.remove("reason");
if (jsonObject.has("out")) {
jsonObject.put("out", jsonOutput);
}
}
}
}
}
}
} else if (dbo instanceof UICustomAction) {
jsonObject = new JSONObject(((UICustomAction) dbo).computeJsonModel());
}
String searchPath = dataPath;
JSONObject jsonOutput = findJSONObject(jsonObject, searchPath);
jsonModel = jsonOutput;
} else // case of UISharedComponent
if (dbo instanceof UISharedComponent) {
JSONObject jsonObject = new JSONObject(((UISharedComponent) dbo).computeJsonModel());
String searchPath = dataPath;
JSONObject jsonOutput = findJSONObject(jsonObject, searchPath);
jsonModel = jsonOutput;
} else // case of ApplicationComponent
if (dbo instanceof ApplicationComponent) {
String json = params.get("json");
jsonModel = new JSONObject(json);
} else // should not happened
{
throw new Exception("DatabaseObject " + dbo.getClass().getName() + " not supported!");
}
}
return jsonModel;
}
use of com.twinsoft.convertigo.beans.core.RequestableObject in project convertigo by convertigo.
the class Engine method getDocument.
/**
* Retrieves the XML document according to the given context.
*
* @param requester
* the calling requester.
* @param context
* the request context.
*
* @return the generated XML document.
*/
public Document getDocument(Requester requester, Context context) throws EngineException {
Document outputDom = null;
String t = context.statistics.start(EngineStatistics.GET_DOCUMENT);
try {
Engine.logContext.trace("Engine.getDocument: started");
// Are we in the studio context?
if (isStudioMode()) {
Engine.logContext.debug("The requested object will be processed in the studio context.");
}
// Checking whether the asynchronous mode has been requested.
if ((context.isAsync) && (JobManager.jobExists(context.contextID))) {
Engine.logContext.debug("The requested object is working and is asynchronous; requesting job status...");
HttpServletRequest request = (HttpServletRequest) requester.inputData;
if (request.getParameter(Parameter.Abort.getName()) != null) {
Engine.logContext.debug("Job abortion has been required");
return JobManager.abortJob(context.contextID);
}
return JobManager.getJobStatus(context.contextID);
}
// Loading project
if (context.projectName == null)
throw new EngineException("The project name has been specified!");
// Checking whether the asynchronous mode has been requested.
if ((context.isAsync) && (JobManager.jobExists(context.contextID))) {
Engine.logContext.debug("The requested object is working and is asynchronous; requesting job status...");
HttpServletRequest request = (HttpServletRequest) requester.inputData;
if (request.getParameter(Parameter.Abort.getName()) != null) {
Engine.logContext.debug("Job abortion has been required");
return JobManager.abortJob(context.contextID);
}
return JobManager.getJobStatus(context.contextID);
}
// Loading project
if (context.projectName == null)
throw new EngineException("The project name has been specified!");
Project currentProject;
if ("system".equals(context.contextID)) {
context.project = currentProject = systemDatabaseObjectsManager.getOriginalProjectByName(context.getProjectName());
} else if (isStudioMode()) {
if (objectsProvider == null) {
throw new EngineException("Is the Projects view opened in the Studio? Failed to load: " + context.projectName);
}
currentProject = objectsProvider.getProject(context.projectName);
if (currentProject == null) {
throw new EngineException("No project has been opened in the Studio. A project should be opened in the Studio in order that the Convertigo engine can work.");
} else if (!currentProject.getName().equalsIgnoreCase(context.projectName)) {
throw new EngineException("The requested project (\"" + context.projectName + "\") does not match with the opened project (\"" + currentProject.getName() + "\") in the Studio.\nYou cannot make a request on a different project than the one opened in the Studio.");
}
Engine.logContext.debug("Using project from Studio");
context.project = currentProject;
} else {
if ((context.project == null) || (context.isNewSession)) {
Engine.logEngine.debug("New project requested: '" + context.projectName + "'");
context.project = Engine.theApp.databaseObjectsManager.getProjectByName(context.projectName);
Engine.logContext.debug("Project loaded: " + context.project.getName());
}
}
context.project.checkSymbols();
if (context.httpServletRequest != null && !RequestAttribute.corsOrigin.has(context.httpServletRequest)) {
String origin = HeaderName.Origin.getHeader(context.httpServletRequest);
String corsOrigin = HttpUtils.filterCorsOrigin(context.project.getCorsOrigin(), origin);
if (corsOrigin != null) {
context.setResponseHeader(HeaderName.AccessControlAllowOrigin.value(), corsOrigin);
context.setResponseHeader(HeaderName.AccessControlAllowCredentials.value(), "true");
Engine.logContext.trace("Add CORS header for: " + corsOrigin);
}
RequestAttribute.corsOrigin.set(context.httpServletRequest, corsOrigin == null ? "" : corsOrigin);
}
// Loading sequence
if (context.sequenceName != null) {
context.loadSequence();
} else {
// Loading connector
context.loadConnector();
// provided
if (context.transactionName == null) {
context.requestedObject = context.getConnector().getDefaultTransaction();
context.transaction = (Transaction) context.requestedObject;
context.transactionName = context.requestedObject.getName();
Engine.logContext.debug("Default transaction loaded: " + context.transactionName);
} else // Try to load overriden transaction
{
context.requestedObject = context.getConnector().getTransactionByName(context.transactionName);
context.transaction = (Transaction) context.requestedObject;
if (context.requestedObject == null) {
throw new EngineException("Unknown transaction \"" + context.transactionName + "\"");
}
Engine.logContext.debug("Transaction loaded: " + context.requestedObject.getName());
}
context.transaction.checkSymbols();
if (context.getConnector().isTasAuthenticationRequired()) {
if (context.tasSessionKey == null) {
throw new EngineException("A Carioca authentication is required in order to process the transaction.");
} else {
// Checking VIC information if needed
if (context.isRequestFromVic) {
Engine.logContext.debug("[Engine.getDocument()] Checking VIC session key");
String s = Crypto2.decodeFromHexString(context.tasSessionKey);
int i = s.indexOf(',');
if (i == -1)
throw new EngineException("Unable to decrypt the VIC session key (reason: #1)!");
try {
long t0 = Long.parseLong(s.substring(0, i));
Engine.logContext.debug("[VIC key check] t0=" + t0);
long t1 = System.currentTimeMillis();
Engine.logContext.debug("[VIC key check] t1=" + t1);
long d = Math.abs(t1 - t0);
Engine.logContext.debug("[VIC key check] d=" + d);
String user = s.substring(i + 1);
Engine.logContext.debug("[VIC key check] user: " + user);
long deltaT = 1000 * 60 * 10;
if (d > deltaT)
throw new EngineException("The VIC session key has expired.");
if (!user.equals(context.tasUserName))
throw new EngineException("Wrong user name!");
} catch (NumberFormatException e) {
throw new EngineException("Unable to decrypt the VIC session key (reason: #2)!");
}
Engine.logContext.debug("[VIC key check] VIC session key OK");
} else // Checking Carioca session key
if (context.isTrustedRequest) {
if (!context.tasSessionKeyVerified) {
Engine.logContext.debug("[Engine.getDocument()] Checking Carioca session key");
TWSKey twsKey = new TWSKey();
twsKey.CreateKey(1);
int cariocaSessionKeyLifeTime = 60;
try {
cariocaSessionKeyLifeTime = Integer.parseInt(EnginePropertiesManager.getProperty(EnginePropertiesManager.PropertyName.CARIOCA_SESSION_KEY_LIFE_TIME));
} catch (NumberFormatException e) {
Engine.logContext.warn("The Carioca session key life time value is not valid (not a number)! Setting default to 60s.");
}
Engine.logContext.debug("Carioca session key lifetime: " + cariocaSessionKeyLifeTime + " second(s)");
String result = checkCariocaSessionKey(context, context.tasSessionKey, context.tasServiceCode, 0, cariocaSessionKeyLifeTime);
if (result != null)
throw new EngineException(result);
Engine.logContext.debug("[ContextManager] Carioca session key OK");
context.tasSessionKeyVerified = true;
}
}
}
}
}
// Check requestable accessibility
requester.checkAccessibility();
// Check requestable access policy
requester.checkSecuredConnection();
// Check authenticated context requirement
requester.checkAuthenticatedContext();
requester.checkParentContext();
RequestableObject requestedObject = context.requestedObject;
String contextResponseExpiryDate = (String) context.get(Parameter.ResponseExpiryDate.getName());
String oldResponseExpiryDate = null;
if (contextResponseExpiryDate != null) {
oldResponseExpiryDate = requestedObject.getResponseExpiryDate();
requestedObject.setResponseExpiryDate(contextResponseExpiryDate);
context.remove(Parameter.ResponseExpiryDate.getName());
}
try {
if (context.isAsync) {
outputDom = JobManager.addJob(cacheManager, requestedObject, requester, context);
} else {
outputDom = cacheManager.getDocument(requester, context);
}
} finally {
if (oldResponseExpiryDate != null) {
requestedObject.setResponseExpiryDate(oldResponseExpiryDate);
}
onDocumentRetrieved(context, outputDom);
}
Element documentElement = outputDom.getDocumentElement();
documentElement.setAttribute("version", Version.fullProductVersion);
documentElement.setAttribute("context", context.name);
documentElement.setAttribute("contextId", context.contextID);
DatabaseObject lastDetectedObject = (DatabaseObject) context.lastDetectedObject;
if (lastDetectedObject != null) {
documentElement.setAttribute("screenclass", lastDetectedObject.getName());
// TODO :
// documentElement.setAttribute(lastDetectedObject.getClass().getName().toLowerCase(),
// lastDetectedObject.getName());
}
context.documentSignatureSent = System.currentTimeMillis();
documentElement.setAttribute("signature", Long.toString(context.documentSignatureSent));
// Add the user reference if any
if (context.userReference != null) {
documentElement.setAttribute("userReference", context.userReference);
}
} catch (EngineException e) {
String message = "[Engine.getDocument()] Context ID#" + context.contextID + " - Unable to build the XML document.";
message += "\n[" + e.getClass().getName() + "] " + e.getMessage();
if (System.getProperty("java.specification.version").compareTo("1.4") >= 0) {
Throwable eCause = e;
while ((eCause = eCause.getCause()) != null) {
if (!(eCause instanceof ConvertigoException)) {
message += "\n" + Log.getStackTrace(eCause);
} else {
message += "\n[" + eCause.getClass().getName() + "] " + eCause.getMessage();
}
}
}
Engine.logContext.error(message);
// Just re-throw the exception
throw (EngineException) e;
} catch (Throwable e) {
Engine.logEngine.error("Context ID#" + context.contextID + " - An unexpected error has occured while building the XML document.", e);
throw new EngineException("An unexpected error has occured while building the XML document." + "Please contact Convertigo support, providing the following information:", e);
} finally {
if (context.requestedObject != null) {
Engine.logContext.debug("Requested object is billable: " + context.requestedObject.isBillable());
if (context.requestedObject.isBillable()) {
// context.outputDocument!
if (context.outputDocument == null) {
Engine.logContext.warn("Billing aborted because the generated XML document is null");
} else {
String billingClassName = context.getConnector().getBillingClassName();
try {
Engine.logContext.debug("Billing class name required: " + billingClassName);
AbstractBiller biller = (AbstractBiller) Class.forName(billingClassName).getConstructor().newInstance();
Engine.logContext.debug("Executing the biller");
biller.insertBilling(context);
} catch (Throwable e) {
Engine.logContext.warn("Unable to execute the biller (the billing is thus ignored): [" + e.getClass().getName() + "] " + e.getMessage());
}
}
}
}
context.statistics.stop(t);
if (context.requestedObject != null) {
try {
Engine.theApp.billingManager.insertBilling(context);
} catch (Exception e) {
Engine.logContext.warn("Unable to insert billing ticket (the billing is thus ignored): [" + e.getClass().getName() + "] " + e.getMessage());
}
}
Engine.logContext.trace("Engine.getDocument: finished");
}
XMLUtils.logXml(outputDom, Engine.logContext, "Generated XML");
return outputDom;
}
Aggregations