use of com.webobjects.foundation.NSMutableArray in project wonder-slim by undur.
the class WOEventDisplayPage method refreshLoggingClicked.
public WOComponent refreshLoggingClicked() {
cache.removeAllObjects();
selectionPath = new NSMutableArray();
events = null;
webEvents = null;
eofEvents = null;
return null;
}
use of com.webobjects.foundation.NSMutableArray in project wonder-slim by undur.
the class ERXLocalizer method frameworkSearchPath.
public static NSArray<String> frameworkSearchPath() {
if (frameworkSearchPath == null) {
frameworkSearchPath = ERXProperties.arrayForKey("er.extensions.ERXLocalizer.frameworkSearchPath");
if (frameworkSearchPath == null) {
NSMutableArray<String> defaultValue = new NSMutableArray<>();
for (Enumeration<NSBundle> e = NSBundle.frameworkBundles().objectEnumerator(); e.hasMoreElements(); ) {
NSBundle bundle = e.nextElement();
String name = bundle.name();
// Check the Properties and Add it Automatically
String propertyName = "er.extensions." + name + ".hasLocalization";
boolean hasLocalization = ERXProperties.booleanForKeyWithDefault(propertyName, true);
if (name.equals("ERCoreBusinessLogic") || name.equals("ERDirectToWeb") || name.equals("ERExtensions")) {
// || name.startsWith("Java")
// do nothing yet, because will add later
} else if (hasLocalization) {
defaultValue.addObject(name);
}
}
if (NSBundle.bundleForName("ERCoreBusinessLogic") != null)
defaultValue.addObject("ERCoreBusinessLogic");
if (NSBundle.bundleForName("ERDirectToWeb") != null)
defaultValue.addObject("ERDirectToWeb");
if (NSBundle.bundleForName("ERExtensions") != null)
defaultValue.addObject("ERExtensions");
defaultValue.insertObjectAtIndex("app", 0);
frameworkSearchPath = defaultValue;
}
if (log.isDebugEnabled())
log.debug("FrameworkSearchPath: {}", frameworkSearchPath.componentsJoinedByString(" / "));
}
return frameworkSearchPath;
}
use of com.webobjects.foundation.NSMutableArray in project wonder-slim by undur.
the class ERXProperties method pathsForUserAndBundleProperties.
public static NSArray<String> pathsForUserAndBundleProperties(boolean reportLoggingEnabled) {
NSMutableArray<String> propertiesPaths = new NSMutableArray();
NSMutableArray<String> projectsInfo = new NSMutableArray();
/* Properties for frameworks */
NSArray frameworkNames = (NSArray) NSBundle.frameworkBundles().valueForKey("name");
Enumeration e = frameworkNames.reverseObjectEnumerator();
while (e.hasMoreElements()) {
String frameworkName = (String) e.nextElement();
String propertyPath = pathForResourceNamed("Properties", frameworkName, null);
addIfPresent(frameworkName + ".framework", propertyPath, propertiesPaths, projectsInfo);
/**
* Properties.dev -- per-Framework-dev properties
* This adds support for Properties.dev in your Frameworks new load order will be
*/
String devPropertiesPath = ERXApplication.isDevelopmentModeSafe() ? ERXProperties.variantPropertiesInBundle("dev", frameworkName) : null;
addIfPresent(frameworkName + ".framework.dev", devPropertiesPath, propertiesPaths, projectsInfo);
/**
* Properties.<userName> -- per-Framework-per-User properties
*/
String userPropertiesPath = ERXProperties.variantPropertiesInBundle(NSProperties.getProperty("user.name"), frameworkName);
addIfPresent(frameworkName + ".framework.user", userPropertiesPath, propertiesPaths, projectsInfo);
}
NSBundle mainBundle = NSBundle.mainBundle();
if (mainBundle != null) {
String mainBundleName = mainBundle.name();
String appPath = pathForResourceNamed("Properties", "app", null);
addIfPresent(mainBundleName + ".app", appPath, propertiesPaths, projectsInfo);
}
/* WebObjects.properties in the user home directory */
String userHome = NSProperties.getProperty("user.home");
if (userHome != null && userHome.length() > 0) {
File file = new File(userHome, "WebObjects.properties");
if (file.exists() && file.isFile() && file.canRead()) {
try {
String userHomePath = file.getCanonicalPath();
addIfPresent("{$user.home}/WebObjects.properties", userHomePath, propertiesPaths, projectsInfo);
} catch (java.io.IOException ex) {
log.error("Failed to load the configuration file '{}'.", file, ex);
}
}
}
/* Optional properties files */
if (optionalConfigurationFiles() != null && optionalConfigurationFiles().count() > 0) {
for (Enumeration configEnumerator = optionalConfigurationFiles().objectEnumerator(); configEnumerator.hasMoreElements(); ) {
String configFile = (String) configEnumerator.nextElement();
File file = new File(configFile);
if (file.exists() && file.isFile() && file.canRead()) {
try {
String optionalPath = file.getCanonicalPath();
addIfPresent("Optional Configuration", optionalPath, propertiesPaths, projectsInfo);
} catch (java.io.IOException ex) {
log.error("Failed to load configuration file '{}'.", file, ex);
}
} else {
log.error("The optional configuration file '{}' either does not exist or could not be read.", file);
}
}
}
optionalPropertiesLoader(NSProperties.getProperty("user.name"), propertiesPaths, projectsInfo);
/**
* /etc/WebObjects/AppName/Properties -- per-Application-per-Machine properties
*/
String applicationMachinePropertiesPath = ERXProperties.applicationMachinePropertiesPath("Properties");
addIfPresent("Application-Machine Properties", applicationMachinePropertiesPath, propertiesPaths, projectsInfo);
/**
* Properties.dev -- per-Application-dev properties
*/
String applicationDeveloperPropertiesPath = ERXProperties.applicationDeveloperProperties();
addIfPresent("Application-Developer Properties", applicationDeveloperPropertiesPath, propertiesPaths, projectsInfo);
/**
* Properties.<userName> -- per-Application-per-User properties
*/
String applicationUserPropertiesPath = ERXProperties.applicationUserProperties();
addIfPresent("Application-User Properties", applicationUserPropertiesPath, propertiesPaths, projectsInfo);
/* Report the result */
if (reportLoggingEnabled && projectsInfo.count() > 0 && log.isInfoEnabled()) {
StringBuilder message = new StringBuilder();
message.append("\n\n").append("ERXProperties has found the following Properties files: \n");
message.append(projectsInfo.componentsJoinedByString("\n"));
message.append('\n');
message.append("ERXProperties currently has the following properties:\n");
message.append(ERXProperties.logString(NSProperties._getProperties()));
log.info(message.toString());
}
return propertiesPaths.immutableClone();
}
use of com.webobjects.foundation.NSMutableArray in project wonder-slim by undur.
the class ERXProperties method optionalConfigurationFiles.
/**
* Gets an array of optionally defined configuration files. For each file, if it does not
* exist as an absolute path, ERXProperties will attempt to resolve it as an application resource
* and use that instead.
*
* @return array of configuration file names
*/
private static NSArray optionalConfigurationFiles() {
NSArray immutableOptionalConfigurationFiles = arrayForKey("er.extensions.ERXProperties.OptionalConfigurationFiles");
NSMutableArray optionalConfigurationFiles = null;
if (immutableOptionalConfigurationFiles != null) {
optionalConfigurationFiles = immutableOptionalConfigurationFiles.mutableClone();
for (int i = 0; i < optionalConfigurationFiles.count(); i++) {
String optionalConfigurationFile = (String) optionalConfigurationFiles.objectAtIndex(i);
if (!new File(optionalConfigurationFile).exists()) {
String resourcePropertiesPath = pathForResourceNamed(optionalConfigurationFile, "app", null);
if (resourcePropertiesPath != null) {
optionalConfigurationFiles.replaceObjectAtIndex(ERXProperties.getActualPath(resourcePropertiesPath), i);
}
}
}
}
return optionalConfigurationFiles;
}
use of com.webobjects.foundation.NSMutableArray in project wonder-slim by undur.
the class ERXWOBrowser method _fastTakeValuesFromRequest.
private void _fastTakeValuesFromRequest(WORequest worequest, WOContext wocontext) {
WOComponent wocomponent = wocontext.component();
if (_selections != null && !isDisabledInContext(wocontext) && wocontext.wasFormSubmitted()) {
String s = nameInContext(wocontext, wocomponent);
NSArray nsarray = worequest.formValuesForKey(s);
int i = nsarray != null ? nsarray.count() : 0;
NSMutableArray nsmutablearray = new NSMutableArray(i);
List vector = null;
if (i != 0) {
NSArray nsarray1 = null;
List vector1 = null;
if (_list != null) {
Object obj = _list.valueInComponent(wocomponent);
if (obj != null) {
if (obj instanceof NSArray) {
nsarray1 = (NSArray) obj;
} else if (obj instanceof List) {
vector1 = (List) obj;
nsmutablearray = null;
vector = new ArrayList(i);
} else {
throw new IllegalArgumentException("<" + getClass().getName() + "> Evaluating 'list' binding returned a " + obj.getClass().getName() + " when it should return either a com.webobjects.foundation.NSArray, or a java.lang.Vector .");
}
}
}
for (int j = 0; j < i; j++) {
String s1 = (String) nsarray.objectAtIndex(j);
int k = Integer.parseInt(s1);
if (nsarray1 != null) {
Object obj2 = nsarray1.objectAtIndex(k);
nsmutablearray.addObject(obj2);
} else {
Object obj3 = vector1.get(k);
vector.add(obj3);
}
}
}
Object newValue = (nsmutablearray != null ? nsmutablearray : vector);
setSelectedValue(newValue, wocomponent);
}
}
Aggregations