use of com.twinsoft.convertigo.engine.EnginePropertiesManager.PropertyName in project convertigo by convertigo.
the class DatabaseCacheManager method onEvent.
@Override
public void onEvent(PropertyChangeEvent event) {
super.onEvent(event);
PropertyName name = event.getKey();
if (name.equals(PropertyName.CACHE_MANAGER_USE_WEAK)) {
useWeakCache = EnginePropertiesManager.getPropertyAsBoolean(PropertyName.CACHE_MANAGER_USE_WEAK);
if (!useWeakCache) {
weakEntry = null;
}
}
}
use of com.twinsoft.convertigo.engine.EnginePropertiesManager.PropertyName in project convertigo by convertigo.
the class List method getServiceResult.
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
Element rootElement = document.getDocumentElement();
Role[] roles = Engine.authenticatedSessionManager.getRoles(request.getSession());
for (PropertyCategory propertyCategory : PropertyCategory.getSortedValues()) {
if (propertyCategory.isVisible() && (AuthenticatedSessionManager.hasRole(roles, Role.WEB_ADMIN) || AuthenticatedSessionManager.hasRole(roles, propertyCategory.viewRoles()))) {
Element elementCategory = document.createElement("category");
elementCategory.setAttribute("name", propertyCategory.toString());
elementCategory.setAttribute("displayName", propertyCategory.getDisplayName());
rootElement.appendChild(elementCategory);
}
}
NodeList categories = document.getElementsByTagName("category");
for (PropertyName property : PropertyName.values()) {
if (property.isVisible()) {
Element categoryElement = (Element) XMLUtils.findNodeByAttributeValue(categories, "name", property.getCategory().name());
if (categoryElement != null) {
String value = EnginePropertiesManager.getProperty(property);
String originalValue = EnginePropertiesManager.getOriginalProperty(property);
switch(property.getType()) {
case PasswordHash:
if ("0".equals(value)) {
value = "";
}
case PasswordPlain:
if (value.length() > 0) {
originalValue = value = "••••••••••••••••";
} else {
originalValue = "";
}
break;
default:
break;
}
Element propertyElement = document.createElement("property");
propertyElement.setAttribute("name", property.name());
propertyElement.setAttribute("type", property.getType().name());
propertyElement.setAttribute("description", property.getDescription());
propertyElement.setAttribute("value", value);
propertyElement.setAttribute("originalValue", originalValue);
propertyElement.setAttribute("isAdvanced", Boolean.toString(property.isAdvance()));
categoryElement.appendChild(propertyElement);
if (property.getType() == PropertyType.Combo) {
for (ComboEnum ce : property.getCombo()) {
String display = ce.getDisplay();
if (display != null) {
Element comboValueElement = document.createElement("item");
comboValueElement.setAttribute("value", ce.getValue());
Text comboValueText = document.createTextNode(display);
comboValueElement.appendChild(comboValueText);
propertyElement.appendChild(comboValueElement);
}
}
}
}
}
}
}
use of com.twinsoft.convertigo.engine.EnginePropertiesManager.PropertyName in project convertigo by convertigo.
the class Update method getServiceResult.
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
Element rootElement = document.getDocumentElement();
Document post = null;
post = XMLUtils.parseDOM(request.getInputStream());
NodeList nl = post.getElementsByTagName("property");
Role[] roles = Engine.authenticatedSessionManager.getRoles(request.getSession());
for (int i = 0; i < nl.getLength(); i++) {
String propKey = ((Element) nl.item(i)).getAttribute("key");
PropertyName property = PropertyName.valueOf(propKey);
if (property.isVisible()) {
if (!AuthenticatedSessionManager.hasRole(roles, Role.WEB_ADMIN) && !AuthenticatedSessionManager.hasRole(roles, property.getCategory().configRoles())) {
throw new AuthenticationException("Authentication failure: user has not sufficient rights!");
}
}
if (property == PropertyName.SECURITY_FILTER) {
if (!SecurityFilter.isAccept(request)) {
throw new InvalidParameterException("Turn on '" + property.getDescription() + "' will block you current session, not allowed.");
}
}
}
for (int i = 0; i < nl.getLength(); i++) {
String propKey = ((Element) nl.item(i)).getAttribute("key");
PropertyName property = PropertyName.valueOf(propKey);
if (property.isVisible()) {
String propValue = ((Element) nl.item(i)).getAttribute("value");
if (PropertyName.TEST_PLATFORM_PASSWORD.equals(property) || PropertyName.ADMIN_PASSWORD.equals(property)) {
AuthenticatedSessionManager.validatePassword(propValue);
}
EnginePropertiesManager.setProperty(property, propValue);
Engine.logAdmin.info("The engine property '" + propKey + "' has been updated to '" + propValue + "'");
}
}
EnginePropertiesManager.saveProperties();
Element update = document.createElement("update");
update.setAttribute("status", "ok");
rootElement.appendChild(update);
}
use of com.twinsoft.convertigo.engine.EnginePropertiesManager.PropertyName in project convertigo by convertigo.
the class SecurityFilter method onEvent.
@Override
public void onEvent(PropertyChangeEvent event) {
PropertyName name = event.getKey();
if (name == PropertyName.SECURITY_FILTER) {
Engine.logSecurityFilter.info("Property '" + name + "' changed to " + event.getValue());
boolean enabled = "true".equals(event.getValue());
parse(enabled);
}
}
use of com.twinsoft.convertigo.engine.EnginePropertiesManager.PropertyName in project convertigo by convertigo.
the class EnginePreferenceComposite method createContents.
protected void createContents() {
modifiedProperties = new HashMap<PropertyName, String>();
boolean all = (filterList == null);
if (!all) {
GridLayout mainLayout = new GridLayout(1, true);
mainLayout.marginTop = 0;
setLayout(mainLayout);
}
bar = new ExpandBar(this, SWT.VERTICAL);
bar.setData(SwtUtils.CSS_CLASS_KEY, "c8oEnginePreferenceExpandBar");
GridData gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
bar.setLayoutData(gridData);
for (PropertyCategory propertyCategory : PropertyCategory.getSortedValues()) {
if (propertyCategory.isVisible()) {
Composite container = new Composite(bar, SWT.NONE);
GridLayout layout = new GridLayout(1, true);
layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 2;
layout.verticalSpacing = 4;
container.setLayout(layout);
if (all || filterList.contains(propertyCategory.getDisplayName())) {
ExpandItem item = new ExpandItem(bar, SWT.NONE);
item.setText(propertyCategory.getDisplayName());
item.setControl(container);
containersMap.put(propertyCategory, container);
expandItemsMap.put(propertyCategory, item);
}
}
}
boolean toggleLineBackground = true;
for (final PropertyName property : PropertyName.values()) {
if (property.isVisible() && property.getCategory().isVisible()) {
toggleLineBackground = !toggleLineBackground;
Composite container = containersMap.get(property.getCategory());
if (container != null) {
Composite line = new Composite(container, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 2;
layout.verticalSpacing = 0;
line.setLayout(layout);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
line.setLayoutData(data);
if (toggleLineBackground) {
line.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
}
Label propertyLabel = new Label(line, SWT.WRAP);
data = new GridData(240, SWT.DEFAULT);
data.verticalAlignment = SWT.TOP;
propertyLabel.setText(property.getDescription());
propertyLabel.setLayoutData(data);
propertyLabel.setBackground(line.getBackground());
switch(property.getType()) {
case Text:
{
final Text propertyEditor = new Text(line, SWT.BORDER);
data = new GridData(GridData.FILL_HORIZONTAL);
data.verticalAlignment = SWT.TOP;
propertyEditor.setLayoutData(data);
String value = EnginePropertiesManager.getProperty(property);
String originalValue = EnginePropertiesManager.getOriginalProperty(property);
propertyEditor.setText(originalValue);
if (!originalValue.equals(value))
propertyEditor.setToolTipText(value);
propertyEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
modifiedProperties.put(property, propertyEditor.getText());
}
});
break;
}
case PasswordHash:
case PasswordPlain:
{
final Text propertyEditor = new Text(line, SWT.BORDER);
data = new GridData(GridData.FILL_HORIZONTAL);
data.verticalAlignment = SWT.TOP;
propertyEditor.setLayoutData(data);
String value = EnginePropertiesManager.getProperty(property);
propertyEditor.setText(value);
propertyEditor.setEchoChar('*');
propertyEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
modifiedProperties.put(property, "" + propertyEditor.getText());
}
});
break;
}
case Boolean:
{
final Button propertyEditor = new Button(line, SWT.CHECK);
propertyEditor.setBackground(line.getBackground());
data = new GridData();
data.verticalAlignment = SWT.TOP;
propertyEditor.setLayoutData(data);
boolean value = Boolean.parseBoolean(EnginePropertiesManager.getProperty(property));
propertyEditor.setSelection(value);
propertyEditor.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
modifiedProperties.put(property, "" + propertyEditor.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {
modifiedProperties.put(property, "" + propertyEditor.getSelection());
}
});
break;
}
case Combo:
{
final Combo propertyEditor = new Combo(line, SWT.SIMPLE | SWT.DROP_DOWN | SWT.READ_ONLY);
data = new GridData(GridData.FILL_HORIZONTAL);
data.verticalAlignment = SWT.TOP;
propertyEditor.setLayoutData(data);
String value = EnginePropertiesManager.getProperty(property);
String comboDisplay, comboValue;
int selectedIndex = 0;
int i = 0;
for (ComboEnum comboItem : property.getCombo()) {
comboDisplay = comboItem.getDisplay();
if (comboDisplay != null) {
comboValue = comboItem.getValue();
propertyEditor.add(comboDisplay);
propertyEditor.setData(comboDisplay, comboValue);
if (value.equals(comboValue)) {
selectedIndex = i;
}
i++;
}
}
propertyEditor.select(selectedIndex);
propertyEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
modifiedProperties.put(property, "" + propertyEditor.getData(propertyEditor.getText()));
}
});
break;
}
case Array:
{
final Text propertyEditor = new Text(line, SWT.BORDER | SWT.MULTI);
data = new GridData(GridData.FILL_HORIZONTAL);
data.verticalAlignment = SWT.TOP;
propertyEditor.setLayoutData(data);
String[] originalValue = EnginePropertiesManager.getOriginalPropertyAsStringArray(property);
for (String item : originalValue) {
propertyEditor.append(item + "\r\n");
}
String v1 = EnginePropertiesManager.getProperty(property);
String v2 = EnginePropertiesManager.getOriginalProperty(property);
if (!v1.equals(v2))
propertyEditor.setToolTipText(v1);
propertyEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
modifiedProperties.put(property, propertyEditor.getText());
}
});
break;
}
}
}
}
}
for (PropertyCategory propertyCategory : PropertyCategory.getSortedValues()) {
if (propertyCategory.isVisible()) {
Composite container = containersMap.get(propertyCategory);
if (container != null) {
ExpandItem item = expandItemsMap.get(propertyCategory);
item.setExpanded(!all);
item.setHeight(container.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
}
}
}
}
Aggregations