use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class DatabaseObjectTreeObject method treeObjectPropertyChanged.
public void treeObjectPropertyChanged(TreeObjectEvent treeObjectEvent) {
checkDone(treeObjectEvent);
TreeObject treeObject = (TreeObject) treeObjectEvent.getSource();
String propertyName = (String) treeObjectEvent.propertyName;
propertyName = ((propertyName == null) ? "" : propertyName);
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
if (this instanceof INamedSourceSelectorTreeObject) {
((INamedSourceSelectorTreeObject) this).getNamedSourceSelector().treeObjectPropertyChanged(treeObjectEvent);
}
// this is a pool
if (getObject() instanceof Pool) {
// handle bean's name changes
if ("name".equals(propertyName)) {
Pool pool = (Pool) getObject();
// case transaction name changed
if (treeObject instanceof TransactionTreeObject) {
Transaction transaction = (Transaction) treeObject.getObject();
if (transaction.getConnector().equals(pool.getConnector())) {
if (pool.getStartTransaction().equals(oldValue)) {
pool.setStartTransaction(newValue.toString());
hasBeenModified(true);
viewer.refresh();
}
}
}
// case screenclass name changed
if (treeObject instanceof ScreenClassTreeObject) {
ScreenClass sc = (ScreenClass) treeObject.getObject();
if (sc.getConnector().equals(pool.getConnector())) {
if (pool.getInitialScreenClass().equals(oldValue)) {
pool.setInitialScreenClass(newValue.toString());
hasBeenModified(true);
viewer.refresh();
}
}
}
}
}
// refresh editors (e.g labels in combobox)
getDescriptors();
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class HtmlConnector method checkForStateless.
public void checkForStateless() {
boolean trStateLess = false;
boolean trStateFull = false;
for (Transaction transaction : getTransactionsList()) {
HtmlTransaction htmlTransaction = (HtmlTransaction) transaction;
if (htmlTransaction.isStateFull())
trStateFull = true;
else
trStateLess = true;
}
if (trStateFull && !trStateLess)
Engine.logBeans.warn("(HtmlConnector) Connector '" + getName() + "' must define at least one stateless transaction!");
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class SaveHandlerTransaction method getServiceResult.
@Override
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
String qname = request.getParameter("qname");
String handlers = request.getParameter("handlers");
Element response = document.createElement("response");
DatabaseObject dbo = Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
if (!(dbo instanceof Transaction)) {
throw new Exception("The database object is not a transaction.");
}
// In case of transaction, save its handlers content
((Transaction) dbo).handlers = handlers;
response.setAttribute("status", "success");
response.setAttribute("message", "Handler transaction updated.");
document.getDocumentElement().appendChild(response);
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class GetTestPlatform method getServiceResult.
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
Element root = document.getDocumentElement();
String projectName = request.getParameter("projectName");
Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
Element e_project = createDatabaseObjectElement(document, project);
Connector defaultConnector = project.getDefaultConnector();
e_project.setAttribute("defaultConnector", defaultConnector.getName());
e_project.setAttribute("defaultTransaction", defaultConnector.getDefaultTransaction().getName());
boolean bTpHiddenRole = Engine.authenticatedSessionManager.hasRole(request.getSession(), Role.TEST_PLATFORM_HIDDEN);
boolean bTpPrivateRole = Engine.authenticatedSessionManager.hasRole(request.getSession(), Role.TEST_PLATFORM_PRIVATE);
for (Connector connector : project.getConnectorsList()) {
Element e_connector = createDatabaseObjectElement(document, connector);
for (Transaction transaction : connector.getTransactionsList()) {
// WEB_ADMIN role is allowed to execute all requestables
if (transaction.isPublicAccessibility() || (transaction.isHiddenAccessibility() && bTpHiddenRole) || bTpPrivateRole) {
e_connector.appendChild(createRequestableElement(document, transaction));
}
}
e_project.appendChild(e_connector);
}
for (Sequence sequence : project.getSequencesList()) {
// WEB_ADMIN role is allowed to execute all requestables
if (sequence.isPublicAccessibility() || (sequence.isHiddenAccessibility() && bTpHiddenRole) || bTpPrivateRole) {
e_project.appendChild(createRequestableElement(document, sequence));
}
}
MobileApplication mobileApplication = project.getMobileApplication();
if (mobileApplication != null && (mobileApplication.getAccessibility() == Accessibility.Public || (mobileApplication.getAccessibility() == Accessibility.Hidden && bTpHiddenRole) || bTpPrivateRole)) {
Element e_mobileApplication = createDatabaseObjectElement(document, mobileApplication);
String applicationID = mobileApplication.getComputedApplicationId();
e_mobileApplication.setAttribute("applicationID", applicationID);
String endpoint = mobileApplication.getComputedEndpoint(request);
e_mobileApplication.setAttribute("endpoint", endpoint);
String version = mobileApplication.getComputedApplicationVersion();
e_mobileApplication.setAttribute("applicationVersion", version);
e_project.appendChild(e_mobileApplication);
for (MobilePlatform platform : mobileApplication.getMobilePlatformList()) {
Element e_device = createDatabaseObjectElement(document, platform);
e_device.setAttribute("classname", platform.getClass().getSimpleName());
e_device.setAttribute("displayName", CachedIntrospector.getBeanInfo(platform.getClass()).getBeanDescriptor().getDisplayName());
e_device.setAttribute("packageType", platform.getPackageType());
e_device.setAttribute("revision", "computing...");
e_mobileApplication.appendChild(e_device);
}
try {
String mobileProjectName = mobileApplication.getComputedApplicationName();
e_mobileApplication.setAttribute("mobileProjectName", mobileProjectName);
} catch (Exception e) {
Engine.logAdmin.error("Failed to retrieve the application mobile name", e);
}
IApplicationComponent app = mobileApplication.getApplicationComponent();
String msg = app != null ? app.getUnbuiltMessage() : null;
if (msg != null) {
e_mobileApplication.setAttribute("unbuiltMessage", msg);
}
}
root.appendChild(e_project);
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class CacheManager method getDocument.
public Document getDocument(Requester requester, Context context) throws EngineException {
Document response = null;
CacheEntry cacheEntry;
String supervision = null;
if (context.isStubRequested) {
String stubFileName = null;
if (context.requestedObject instanceof Transaction) {
stubFileName = context.requestedObject.getProject().getDirPath() + "/stubs/" + context.requestedObject.getParent().getName() + "." + context.requestedObject.getName() + ".xml";
} else if (context.requestedObject instanceof Sequence) {
stubFileName = context.requestedObject.getProject().getDirPath() + "/stubs/" + context.requestedObject.getName() + ".xml";
}
try {
response = XMLUtils.parseDOM(stubFileName);
response.getDocumentElement().setAttribute("fromStub", "true");
} catch (Exception e) {
Engine.logCacheManager.error("Error while parsing " + stubFileName + " file");
throw new EngineException("Unable to load response from Stub", e);
}
} else {
context.requestedObject.parseInputDocument(context);
if (context.httpServletRequest != null) {
try {
supervision = context.httpServletRequest.getParameter(Parameter.Supervision.getName());
} catch (Exception e) {
Engine.logCacheManager.warn("Error while getting '" + Parameter.Supervision.getName() + "' parameter, probably in async job ?");
}
}
long expiryDate = context.requestedObject.getResponseExpiryDateInMillis();
// Cache not enabled
if (EnginePropertiesManager.getPropertyAsBoolean(PropertyName.DISABLE_CACHE)) {
Engine.logCacheManager.debug("Cache not enabled explicitly");
response = context.requestedObject.run(requester, context);
response.getDocumentElement().setAttribute("fromcache", "false");
response.getDocumentElement().setAttribute("fromStub", "false");
} else // Not cached transaction
if (expiryDate <= 0) {
Engine.logCacheManager.trace("The response is not cachable");
response = context.requestedObject.run(requester, context);
response.getDocumentElement().setAttribute("fromcache", "false");
response.getDocumentElement().setAttribute("fromStub", "false");
} else // Cached transaction
{
String requestString = context.requestedObject.getRequestString(context);
if (context.noCache) {
Engine.logCacheManager.debug("Ignoring cache for request: " + requestString);
try {
cacheEntry = (CacheEntry) getCacheEntry(requestString);
if (cacheEntry != null) {
removeStoredResponse(cacheEntry);
}
cacheEntry = null;
} catch (Exception e) {
Engine.logCacheManager.error("Unable to remove the stored response from the cache repository!", e);
}
} else {
Engine.logCacheManager.debug("Searched request string: " + requestString);
try {
cacheEntry = (CacheEntry) getCacheEntry(requestString);
} catch (Exception e) {
Engine.logCacheManager.error("Unable to find the cache entry!", e);
cacheEntry = null;
}
Engine.logCacheManager.debug("Found cache entry: " + cacheEntry);
if (cacheEntry != null) {
if (cacheEntryHasExpired(cacheEntry)) {
Engine.logCacheManager.debug("Response [" + cacheEntry.toString() + "] has expired! Removing the current response and requesting a new response...");
try {
removeStoredResponse(cacheEntry);
cacheEntry = null;
} catch (Exception e) {
Engine.logCacheManager.error("Unable to remove the stored response from the cache repository!", e);
}
} else if ((cacheEntry.sheetUrl == null) && (context.isXsltRequest) && (context.requestedObject.getSheetLocation() == Transaction.SHEET_LOCATION_FROM_LAST_DETECTED_OBJECT_OF_REQUESTABLE)) {
Engine.logCacheManager.debug("Ignoring cache for request: " + requestString + " because a XSLT procees has been required and no sheet information has been stored into the cache entry.");
try {
removeStoredResponse(cacheEntry);
cacheEntry = null;
} catch (Exception e) {
Engine.logCacheManager.error("(CacheManager) Unable to remove the stored response from the cache repository!", e);
}
} else {
context.cacheEntry = cacheEntry;
// Update the statistics events
context.requestedObject.setStatisticsOfRequestFromCache();
String t = context.statistics.start(EngineStatistics.GENERATE_DOM);
try {
response = getStoredResponse(requester, cacheEntry);
if (response != null) {
response.getDocumentElement().setAttribute("fromcache", "true");
response.getDocumentElement().setAttribute("fromStub", "false");
ProcessingInstruction pi = response.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + context.requestedObject.getEncodingCharSet() + "\"");
response.insertBefore(pi, response.getFirstChild());
// response has been overridden - needed by billings!
context.outputDocument = response;
if (context.requestedObject != null) {
context.requestedObject.onCachedResponse();
}
} else {
Engine.logCacheManager.debug("Response from cache is null: removing the cache entry.");
removeStoredResponse(cacheEntry);
}
} catch (Exception e) {
Engine.logCacheManager.error("Unable to get the stored response from the cache repository!", e);
response = null;
} finally {
context.statistics.stop(t);
}
}
}
}
if (response == null) {
response = context.requestedObject.run(requester, context);
if (Engine.logCacheManager.isTraceEnabled())
Engine.logCacheManager.trace("Cache manager: document returned:\n" + XMLUtils.prettyPrintDOM(response));
response.getDocumentElement().setAttribute("fromcache", "false");
response.getDocumentElement().setAttribute("fromStub", "false");
// disabled the cache feature...
if (supervision != null) {
Engine.logCacheManager.debug("Supervision mode => disable caching");
context.isCacheEnabled = false;
}
if (context.isCacheEnabled) {
try {
response.getDocumentElement().setAttribute("expires", new Date(expiryDate).toString());
cacheEntry = storeResponse(response, requestString, expiryDate);
context.cacheEntry = cacheEntry;
Engine.logCacheManager.info("The expiration Date " + new Date(expiryDate).toString());
} catch (Exception e) {
Engine.logCacheManager.error("(CacheManager) Unable to store the response into the cache repository!", e);
}
} else {
Engine.logCacheManager.debug("Cache has been disabled!");
}
}
}
}
if (context.removeNamespaces) {
try {
Engine.logEngine.debug("Removing namespaces...");
response = XMLUtils.copyDocumentWithoutNamespace(response);
if (Engine.logEngine.isDebugEnabled()) {
String result = XMLUtils.prettyPrintDOM(response);
Engine.logEngine.debug("Namespaces removed:\n" + result);
}
} catch (ParserConfigurationException e) {
Engine.logCacheManager.error("(CacheManager) Failed to remove namespaces!", e);
}
}
if ("true".equals(response.getDocumentElement().getAttribute("fromcache")) && context.parentContext == null) {
HttpUtils.terminateNewSession(context.httpSession);
}
return response;
}
Aggregations