use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.
the class FileCacheManager method getStoredResponseFromRepository.
protected Document getStoredResponseFromRepository(Requester requester, CacheEntry cacheEntry) throws EngineException {
FileCacheEntry fileCacheEntry = (FileCacheEntry) cacheEntry;
Engine.logCacheManager.debug("cacheEntry=[" + cacheEntry.toString() + "]");
try {
File file = new File(fileCacheEntry.fileName);
Document document = XMLUtils.parseDOM(file);
Engine.logCacheManager.debug("Response built from the cache");
return document;
} catch (FileNotFoundException e) {
Engine.logCacheManager.warn("Unable to find the response [" + cacheEntry.toString() + "] into the cache; the stored response is invalidated.");
return null;
} catch (Exception e) {
throw new EngineException("Unable to get the response [" + cacheEntry.toString() + "] from the cache!", e);
}
}
use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.
the class FileCacheManager method init.
@Override
public void init() throws EngineException {
File cacheDir = new File(EnginePropertiesManager.getProperty(PropertyName.CACHE_MANAGER_FILECACHE_DIRECTORY));
try {
if (cacheDir.exists() && !cacheDir.isDirectory()) {
Engine.logEngine.error("(FileCacheManager) The 'file cache directory' must be a directory : " + cacheDir);
} else {
cacheDir.mkdirs();
File testWrite = new File(cacheDir, ".testWrite");
if (testWrite.createNewFile()) {
testWrite.delete();
Engine.CACHE_PATH = cacheDir.getCanonicalPath();
} else {
Engine.logEngine.error("(FileCacheManager) Failed to write to : " + testWrite);
}
}
} catch (Exception e) {
Engine.logEngine.error("(FileCacheManager) Failed to write to : " + cacheDir, e);
}
super.init();
}
use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.
the class FileCacheManager method storeResponseToRepository.
protected synchronized CacheEntry storeResponseToRepository(Document response, String requestString, long expiryDate) throws EngineException {
long index = getNextIndex();
String fileName = Engine.CACHE_PATH + "/" + Long.toHexString(index) + ".xml";
try {
makeDirectory();
XMLUtils.saveXml(response, fileName, true);
FileCacheEntry cacheEntry = new FileCacheEntry();
cacheEntry.requestString = requestString;
cacheEntry.fileName = fileName;
cacheEntry.expiryDate = expiryDate;
Engine.logCacheManager.debug("The response has been stored: [" + cacheEntry + "]");
return cacheEntry;
} catch (IOException e) {
throw new EngineException("Unable to store the response! (requestString: " + requestString + ", file: " + fileName + ")", e);
}
}
use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.
the class FileCacheManager method saveCacheIndex.
protected void saveCacheIndex() throws EngineException {
String indexFileName = Engine.CACHE_PATH + "/index.dat";
File file = new File(indexFileName);
File backupFile = null;
if (file.exists()) {
backupFile = new File(Engine.CACHE_PATH + "/index.sav");
if (backupFile.exists()) {
if (!backupFile.delete()) {
Engine.logCacheManager.warn("Unable to delete the backup cache index file: " + backupFile);
}
}
if (!file.renameTo(backupFile)) {
Engine.logCacheManager.warn("Unable to backup the cache index: " + file + " to " + backupFile);
}
}
try {
makeDirectory();
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(indexFileName))) {
objectOutputStream.writeObject(cacheIndex);
objectOutputStream.flush();
}
} catch (Exception e) {
throw new EngineException("Unable to save the cache index.", e);
}
if (backupFile != null) {
if (!backupFile.delete()) {
Engine.logCacheManager.warn("Unable to delete the backup cache index file.");
}
}
}
use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.
the class NgxUIComponentTreeObject method handlesBeanNameChanged.
protected void handlesBeanNameChanged(TreeObjectEvent treeObjectEvent) {
DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
int update = treeObjectEvent.update;
if (update != TreeObjectEvent.UPDATE_NONE) {
// Case a UIStackVariable has been renamed
if (databaseObject instanceof UIStackVariable) {
UIStackVariable variable = (UIStackVariable) databaseObject;
UIActionStack stack = variable.getSharedAction();
if (stack != null) {
// rename variable for InvokeAction
if (getObject() instanceof UIDynamicInvoke) {
UIDynamicInvoke udi = (UIDynamicInvoke) getObject();
if (udi.getSharedActionQName().equals(stack.getQName())) {
boolean isLocalProject = variable.getProject().equals(udi.getProject());
boolean isSameValue = variable.getName().equals(oldValue);
boolean shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
if (!isSameValue && shouldUpdate) {
Iterator<UIComponent> it = udi.getUIComponentList().iterator();
while (it.hasNext()) {
UIComponent component = (UIComponent) it.next();
if (component instanceof UIControlVariable) {
UIControlVariable uicv = (UIControlVariable) component;
if (uicv.getName().equals(oldValue)) {
try {
uicv.setName((String) newValue);
uicv.hasChanged = true;
hasBeenModified(true);
viewer.refresh();
markMainAsDirty(udi);
notifyDataseObjectPropertyChanged(uicv, "name", oldValue, newValue, new HashSet<Object>());
break;
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' variable for InvokeAction !");
}
}
}
}
}
}
}
}
} else // Case a UICompVariable has been renamed
if (databaseObject instanceof UICompVariable) {
UICompVariable variable = (UICompVariable) databaseObject;
UISharedComponent comp = variable.getSharedComponent();
if (comp != null) {
// rename variable for UseShared
if (getObject() instanceof UIUseShared) {
UIUseShared uus = (UIUseShared) getObject();
if (uus.getSharedComponentQName().equals(comp.getQName())) {
boolean isLocalProject = variable.getProject().equals(uus.getProject());
boolean isSameValue = variable.getName().equals(oldValue);
boolean shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
if (!isSameValue && shouldUpdate) {
Iterator<UIComponent> it = uus.getUIComponentList().iterator();
while (it.hasNext()) {
UIComponent component = (UIComponent) it.next();
if (component instanceof UIUseVariable) {
UIUseVariable uicv = (UIUseVariable) component;
if (uicv.getName().equals(oldValue)) {
try {
uicv.setName((String) newValue);
uicv.hasChanged = true;
hasBeenModified(true);
viewer.refresh();
markMainAsDirty(uus);
notifyDataseObjectPropertyChanged(uicv, "name", oldValue, newValue, new HashSet<Object>());
break;
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' variable for UseShared !");
}
}
}
}
}
}
}
}
} else // Case a UICompEvent has been renamed
if (databaseObject instanceof UICompEvent) {
UICompEvent event = (UICompEvent) databaseObject;
UISharedComponent comp = event.getSharedComponent();
if (comp != null) {
// rename control event for UseShared
if (getObject() instanceof UIUseShared) {
UIUseShared uus = (UIUseShared) getObject();
if (uus.getSharedComponentQName().equals(comp.getQName())) {
boolean isLocalProject = event.getProject().equals(uus.getProject());
boolean isSameValue = event.getName().equals(oldValue);
boolean shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
if (!isSameValue && shouldUpdate) {
Iterator<UIComponent> it = uus.getUIComponentList().iterator();
while (it.hasNext()) {
UIComponent component = (UIComponent) it.next();
if (component instanceof UIControlEvent) {
UIControlEvent uice = (UIControlEvent) component;
if (uice.getEventName().equals(oldValue)) {
try {
uice.setEventName((String) newValue);
uice.hasChanged = true;
hasBeenModified(true);
viewer.refresh();
markMainAsDirty(uus);
notifyDataseObjectPropertyChanged(uice, "eventName", oldValue, newValue, new HashSet<Object>());
break;
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' event for UseShared !");
}
}
}
}
}
}
}
}
} else // Case a RequestableVariable has been renamed
if (databaseObject instanceof RequestableVariable) {
RequestableVariable variable = (RequestableVariable) databaseObject;
DatabaseObject parent = variable.getParent();
if (getObject() instanceof UIDynamicAction) {
UIDynamicAction uia = (UIDynamicAction) getObject();
IonBean ionBean = uia.getIonBean();
if (ionBean != null) {
// rename variable for CallSequenceAction
if (ionBean.getName().equals("CallSequenceAction")) {
Object p_val = ionBean.getProperty("requestable").getValue();
if (!p_val.equals(false)) {
if (parent.getQName().equals(p_val.toString())) {
boolean isLocalProject = variable.getProject().equals(uia.getProject());
boolean isSameValue = variable.getName().equals(oldValue);
boolean shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
if (!isSameValue && shouldUpdate) {
Iterator<UIComponent> it = uia.getUIComponentList().iterator();
while (it.hasNext()) {
UIComponent component = (UIComponent) it.next();
if (component instanceof UIControlVariable) {
UIControlVariable uicv = (UIControlVariable) component;
if (uicv.getName().equals(oldValue)) {
try {
uicv.setName((String) newValue);
uicv.hasChanged = true;
hasBeenModified(true);
viewer.refresh();
markMainAsDirty(uia);
notifyDataseObjectPropertyChanged(uicv, "name", oldValue, newValue, new HashSet<Object>());
break;
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' variable for CallSequenceAction !");
}
}
}
}
}
}
}
}
}
}
}
}
}
Aggregations