use of com.webobjects.foundation.NSForwardException in project wonder-slim by undur.
the class WOOgnlAssociation method valueInComponent.
@Override
public Object valueInComponent(WOComponent component) {
WOAssociation.Event event = _markStartOfEventIfNeeded("valueForKeyPath", keyPath(), component);
Object value = null;
try {
value = WOOgnl.factory().getValue(keyPath(), component);
} catch (Exception e) {
if (shouldThrowException()) {
throw new NSForwardException(e);
}
log.error("Exception invoking valueInComponent on WOOgnlAssociation with keyPath '{}'", keyPath(), e);
}
if (event != null) {
EOEventCenter.markEndOfEvent(event);
}
if (_debugEnabled) {
_logPullValue(value, component);
}
return value;
}
use of com.webobjects.foundation.NSForwardException in project wonder-slim by undur.
the class ERXAppRunner method initApp.
/**
* Initializes your WOApplication programmatically (for use in test cases and main methods).
*
* @param mainBundleName the name of your main bundle (or null to use mainBundleURL)
* @param mainBundleURL the URL to your main bundle (ignored if mainBundleName is set)
* @param applicationSubclass your Application subclass
* @param args the commandline arguments for your application
*/
public static void initApp(String mainBundleName, URL mainBundleURL, Class applicationSubclass, String[] args) {
if (_appInitialized) {
return;
}
try {
ERXApplication.setup(args);
if (mainBundleURL != null) {
System.setProperty("webobjects.user.dir", new File(mainBundleURL.getFile()).getCanonicalPath());
}
// Odds are you are only using this method for test cases and development mode
System.setProperty("er.extensions.ERXApplication.developmentMode", "true");
ERXApplication.primeApplication(mainBundleName, mainBundleURL, applicationSubclass.getName());
// NSNotificationCenter.defaultCenter().postNotification(new NSNotification(ERXApplication.ApplicationDidCreateNotification, WOApplication.application()));
} catch (IOException e) {
throw new NSForwardException(e);
}
_appInitialized = true;
}
use of com.webobjects.foundation.NSForwardException in project wonder-slim by undur.
the class ERXStyleSheet method md5Hex.
/**
* Partial rip from ERXStringUtilities
*
* FIXME: Could use cleanup // Hugi 2021-11-12
*/
@Deprecated
private static String md5Hex(String str) {
Objects.requireNonNull(str);
try {
MessageDigest md5 = java.security.MessageDigest.getInstance("MD5");
byte[] buf = new byte[50 * 1024];
int numRead;
final ByteArrayInputStream in = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
while ((numRead = in.read(buf)) != -1) {
md5.update(buf, 0, numRead);
}
return HexFormat.of().formatHex(md5.digest());
} catch (java.security.NoSuchAlgorithmException | IOException e) {
throw new NSForwardException(e);
}
}
use of com.webobjects.foundation.NSForwardException in project wonder-slim by undur.
the class AjaxModalContainer method appendToResponse.
@Override
public void appendToResponse(WOResponse response, WOContext context) {
WOComponent component = context.component();
String linkID = (String) valueForBinding("id", component);
if (linkID == null) {
linkID = ERXWOContext.safeIdentifierName(context, false);
}
String containerID = (String) valueForBinding("containerID", linkID + "Container", component);
response.appendContentString("<a");
String href = (String) valueForBinding("href", component);
if (href == null) {
String directActionName = stringValueForBinding("directActionName", component);
if (directActionName != null) {
NSDictionary queryDictionary = (NSDictionary) valueForBinding("queryDictionary", component);
boolean secure = booleanValueForBinding("secure", ERXRequest.isRequestSecure(context.request()), component);
if (secure) {
boolean generatingCompleteURLs = context.doesGenerateCompleteURLs();
if (!generatingCompleteURLs) {
context.generateCompleteURLs();
}
try {
href = context._directActionURL(directActionName, queryDictionary, secure, 0, false);
ERXMutableURL u = new ERXMutableURL(href);
u.addQueryParameter(String.valueOf(System.currentTimeMillis()), null);
href = u.toExternalForm();
} catch (MalformedURLException e) {
throw new NSForwardException(e);
} finally {
if (!generatingCompleteURLs) {
context.generateRelativeURLs();
}
}
} else {
href = context.directActionURLForActionNamed(directActionName, queryDictionary);
}
}
}
boolean isAjax = booleanValueForBinding("ajax", false, component);
if (href == null) {
if (isAjax) {
if (valueForBinding("id", component) == null) {
throw new IllegalArgumentException("If ajax = 'true', you must also bind 'id'.");
}
href = AjaxUtils.ajaxComponentActionUrl(context);
} else if (associations().objectForKey("action") != null) {
// don't use ajax request handler here
href = context.componentActionURL();
}
if (href == null) {
href = "#" + containerID;
}
}
appendTagAttributeToResponse(response, "href", href);
String relAttributeValue = "ibox";
Object height = valueForBinding("height", component);
Object width = valueForBinding("width", component);
Object closeLabel = valueForBinding("closeLabel", component);
if (height != null) {
relAttributeValue += "&height=" + URLEncoder.encode(height.toString(), Charset.forName(WOMessage.defaultURLEncoding()));
}
if (width != null) {
relAttributeValue += "&width=" + URLEncoder.encode(width.toString(), Charset.forName(WOMessage.defaultURLEncoding()));
}
if (closeLabel != null) {
relAttributeValue += "&closeLabel=" + URLEncoder.encode(closeLabel.toString(), Charset.forName(WOMessage.defaultURLEncoding()));
}
if (booleanValueForBinding("locked", false, component)) {
relAttributeValue += "&locked=true";
}
// don't escape the ampersands
response._appendTagAttributeAndValue("rel", relAttributeValue, false);
appendTagAttributeToResponse(response, "title", valueForBinding("title", component));
appendTagAttributeToResponse(response, "value", valueForBinding("value", component));
appendTagAttributeToResponse(response, "class", valueForBinding("class", component));
appendTagAttributeToResponse(response, "style", valueForBinding("style", component));
appendTagAttributeToResponse(response, "id", linkID);
response.appendContentString(">");
if (!href.startsWith("#") && !isAjax && childrenElements() != null && childrenElements().count() > 0) {
appendChildrenToResponse(response, context);
} else {
Object label = valueForBinding("label", "", component);
response.appendContentString(label.toString());
}
response.appendContentString("</a>");
if (AjaxUtils.isAjaxRequest(context.request())) {
NSMutableDictionary userInfo = ERXWOContext.contextDictionary();
if (!userInfo.containsKey("er.ajax.AjaxModalContainer.init")) {
AjaxUtils.appendScriptHeader(response);
response.appendContentString("iBox.init()");
AjaxUtils.appendScriptFooter(response);
userInfo.setObjectForKey(Boolean.TRUE, "er.ajax.AjaxModalContainer.init");
}
}
if (booleanValueForBinding("open", false, component)) {
if (AjaxUtils.isAjaxRequest(context.request())) {
// PROTOTYPE FUNCTIONS
response.appendContentString("<script>iBox.handleTag.bind($wi('" + linkID + "'))()</script>");
} else {
// PROTOTYPE FUNCTIONS
response.appendContentString("<script>Event.observe(window, 'load', iBox.handleTag.bind($wi('" + linkID + "')))</script>");
}
}
if (href.startsWith("#")) {
response.appendContentString("<div");
appendTagAttributeToResponse(response, "id", containerID);
appendTagAttributeToResponse(response, "style", "display:none;");
response.appendContentString(">");
appendChildrenToResponse(response, context);
response.appendContentString("</div>");
}
super.appendToResponse(response, context);
}
use of com.webobjects.foundation.NSForwardException in project wonder-slim by undur.
the class ERXResourceManager method _initAppBundle.
private static WODeployedBundle _initAppBundle() {
Object obj = null;
try {
WODeployedBundle wodeployedbundle = WODeployedBundle.deployedBundle();
obj = wodeployedbundle.projectBundle();
if (obj != null) {
log.warn("Application project found: Will locate resources in '{}' rather than '{}'.", ((WOProjectBundle) obj).projectPath(), wodeployedbundle.bundlePath());
} else {
obj = wodeployedbundle;
}
} catch (Exception exception) {
log.error("<WOResourceManager> Unable to initialize AppProjectBundle for reason:", exception);
throw NSForwardException._runtimeExceptionForThrowable(exception);
}
return (WODeployedBundle) obj;
}
Aggregations