repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
OpenLiberty/open-liberty
dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/internal/HttpEndpointImpl.java
HttpEndpointImpl.shutdownFramework
@FFDCIgnore(Exception.class) final void shutdownFramework() { Tr.audit(tc, "httpChain.error.shutdown", name); try { Bundle bundle = bundleContext.getBundle(Constants.SYSTEM_BUNDLE_LOCATION); if (bundle != null) bundle.stop(); } catch (Exception e) { // do not FFDC this. // exceptions during bundle stop occur if framework is already stopping or stopped } }
java
@FFDCIgnore(Exception.class) final void shutdownFramework() { Tr.audit(tc, "httpChain.error.shutdown", name); try { Bundle bundle = bundleContext.getBundle(Constants.SYSTEM_BUNDLE_LOCATION); if (bundle != null) bundle.stop(); } catch (Exception e) { // do not FFDC this. // exceptions during bundle stop occur if framework is already stopping or stopped } }
[ "@", "FFDCIgnore", "(", "Exception", ".", "class", ")", "final", "void", "shutdownFramework", "(", ")", "{", "Tr", ".", "audit", "(", "tc", ",", "\"httpChain.error.shutdown\"", ",", "name", ")", ";", "try", "{", "Bundle", "bundle", "=", "bundleContext", ".", "getBundle", "(", "Constants", ".", "SYSTEM_BUNDLE_LOCATION", ")", ";", "if", "(", "bundle", "!=", "null", ")", "bundle", ".", "stop", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// do not FFDC this.", "// exceptions during bundle stop occur if framework is already stopping or stopped", "}", "}" ]
When an error occurs during startup and the config variable fail.on.error.enabled is true, then this method is used to stop the root bundle thus bringing down the OSGi framework.
[ "When", "an", "error", "occurs", "during", "startup", "and", "the", "config", "variable", "fail", ".", "on", ".", "error", ".", "enabled", "is", "true", "then", "this", "method", "is", "used", "to", "stop", "the", "root", "bundle", "thus", "bringing", "down", "the", "OSGi", "framework", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/internal/HttpEndpointImpl.java#L392-L405
train
OpenLiberty/open-liberty
dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/internal/HttpEndpointImpl.java
HttpEndpointImpl.setSslOptions
@Trivial @Reference(name = "sslOptions", service = ChannelConfiguration.class, policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY, cardinality = ReferenceCardinality.OPTIONAL) protected void setSslOptions(ServiceReference<ChannelConfiguration> service) { if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { Tr.event(this, tc, "set ssl options " + service.getProperty("id"), this); } this.sslOptions.setReference(service); if (endpointConfig != null) { performAction(updateAction); } }
java
@Trivial @Reference(name = "sslOptions", service = ChannelConfiguration.class, policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY, cardinality = ReferenceCardinality.OPTIONAL) protected void setSslOptions(ServiceReference<ChannelConfiguration> service) { if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { Tr.event(this, tc, "set ssl options " + service.getProperty("id"), this); } this.sslOptions.setReference(service); if (endpointConfig != null) { performAction(updateAction); } }
[ "@", "Trivial", "@", "Reference", "(", "name", "=", "\"sslOptions\"", ",", "service", "=", "ChannelConfiguration", ".", "class", ",", "policy", "=", "ReferencePolicy", ".", "DYNAMIC", ",", "policyOption", "=", "ReferencePolicyOption", ".", "GREEDY", ",", "cardinality", "=", "ReferenceCardinality", ".", "OPTIONAL", ")", "protected", "void", "setSslOptions", "(", "ServiceReference", "<", "ChannelConfiguration", ">", "service", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEventEnabled", "(", ")", ")", "{", "Tr", ".", "event", "(", "this", ",", "tc", ",", "\"set ssl options \"", "+", "service", ".", "getProperty", "(", "\"id\"", ")", ",", "this", ")", ";", "}", "this", ".", "sslOptions", ".", "setReference", "(", "service", ")", ";", "if", "(", "endpointConfig", "!=", "null", ")", "{", "performAction", "(", "updateAction", ")", ";", "}", "}" ]
The specific sslOptions is selected by a filter set through metatype that matches a specific user-configured option set or falls back to a default. @param service
[ "The", "specific", "sslOptions", "is", "selected", "by", "a", "filter", "set", "through", "metatype", "that", "matches", "a", "specific", "user", "-", "configured", "option", "set", "or", "falls", "back", "to", "a", "default", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/internal/HttpEndpointImpl.java#L496-L510
train
OpenLiberty/open-liberty
dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/internal/HttpEndpointImpl.java
HttpEndpointImpl.setRemoteIp
@Trivial @Reference(name = "remoteIp", service = ChannelConfiguration.class, policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY, cardinality = ReferenceCardinality.MANDATORY) protected void setRemoteIp(ChannelConfiguration config) { if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { Tr.event(this, tc, "set remote ip " + config.getProperty("id"), this); } this.remoteIpConfig = config; if (remoteIpConfig != null) { performAction(updateAction); } }
java
@Trivial @Reference(name = "remoteIp", service = ChannelConfiguration.class, policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY, cardinality = ReferenceCardinality.MANDATORY) protected void setRemoteIp(ChannelConfiguration config) { if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { Tr.event(this, tc, "set remote ip " + config.getProperty("id"), this); } this.remoteIpConfig = config; if (remoteIpConfig != null) { performAction(updateAction); } }
[ "@", "Trivial", "@", "Reference", "(", "name", "=", "\"remoteIp\"", ",", "service", "=", "ChannelConfiguration", ".", "class", ",", "policy", "=", "ReferencePolicy", ".", "DYNAMIC", ",", "policyOption", "=", "ReferencePolicyOption", ".", "GREEDY", ",", "cardinality", "=", "ReferenceCardinality", ".", "MANDATORY", ")", "protected", "void", "setRemoteIp", "(", "ChannelConfiguration", "config", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEventEnabled", "(", ")", ")", "{", "Tr", ".", "event", "(", "this", ",", "tc", ",", "\"set remote ip \"", "+", "config", ".", "getProperty", "(", "\"id\"", ")", ",", "this", ")", ";", "}", "this", ".", "remoteIpConfig", "=", "config", ";", "if", "(", "remoteIpConfig", "!=", "null", ")", "{", "performAction", "(", "updateAction", ")", ";", "}", "}" ]
The specific remoteIpOptions is selected by a filter set through metatype that matches a specific user-configured option set or falls back to a default. @param service
[ "The", "specific", "remoteIpOptions", "is", "selected", "by", "a", "filter", "set", "through", "metatype", "that", "matches", "a", "specific", "user", "-", "configured", "option", "set", "or", "falls", "back", "to", "a", "default", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/internal/HttpEndpointImpl.java#L618-L632
train
OpenLiberty/open-liberty
dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/internal/HttpEndpointImpl.java
HttpEndpointImpl.setExecutorService
@Reference(name = "executorService", service = ExecutorService.class, policy = ReferencePolicy.DYNAMIC) protected void setExecutorService(ServiceReference<ExecutorService> executorService) { this.executorService.setReference(executorService); }
java
@Reference(name = "executorService", service = ExecutorService.class, policy = ReferencePolicy.DYNAMIC) protected void setExecutorService(ServiceReference<ExecutorService> executorService) { this.executorService.setReference(executorService); }
[ "@", "Reference", "(", "name", "=", "\"executorService\"", ",", "service", "=", "ExecutorService", ".", "class", ",", "policy", "=", "ReferencePolicy", ".", "DYNAMIC", ")", "protected", "void", "setExecutorService", "(", "ServiceReference", "<", "ExecutorService", ">", "executorService", ")", "{", "this", ".", "executorService", ".", "setReference", "(", "executorService", ")", ";", "}" ]
DS method for setting the required dynamic executor service reference. @param bundle
[ "DS", "method", "for", "setting", "the", "required", "dynamic", "executor", "service", "reference", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/internal/HttpEndpointImpl.java#L678-L681
train
OpenLiberty/open-liberty
dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/internal/HttpEndpointImpl.java
HttpEndpointImpl.performAction
@Trivial private void performAction(Runnable action, boolean addToQueue) { ExecutorService exec = executorService.getService(); if (exec == null) { // If we can't find the executor service, we have to run it in place. action.run(); } else { // If we can find the executor service, we'll add the action to the queue. // If the actionFuture is null (no pending actions) and the configFuture is null (no // pending configuration updates), we'll submit the actionsRunner to the executor // service to drain the queue // // configFuture is used to avoid bouncing the endpoint multiple times because of a // single configuration update. // // actionFuture is only set to a non-null value by kicking off the executor service here. // actionsRunner syncs on actionQueue, so we can't add any new actions while we are // draining the queue. When the queue is empty, actionFuture is explicitly set to null. // // Long story short, it prevents us from kicking off multiple executors which could run in // random order. if (addToQueue) { synchronized (actionQueue) { actionQueue.add(action); if ((actionFuture == null) && (configFuture == null)) { actionFuture = exec.submit(actionsRunner); } } } else { // Schedule immediately exec.submit(action); } } }
java
@Trivial private void performAction(Runnable action, boolean addToQueue) { ExecutorService exec = executorService.getService(); if (exec == null) { // If we can't find the executor service, we have to run it in place. action.run(); } else { // If we can find the executor service, we'll add the action to the queue. // If the actionFuture is null (no pending actions) and the configFuture is null (no // pending configuration updates), we'll submit the actionsRunner to the executor // service to drain the queue // // configFuture is used to avoid bouncing the endpoint multiple times because of a // single configuration update. // // actionFuture is only set to a non-null value by kicking off the executor service here. // actionsRunner syncs on actionQueue, so we can't add any new actions while we are // draining the queue. When the queue is empty, actionFuture is explicitly set to null. // // Long story short, it prevents us from kicking off multiple executors which could run in // random order. if (addToQueue) { synchronized (actionQueue) { actionQueue.add(action); if ((actionFuture == null) && (configFuture == null)) { actionFuture = exec.submit(actionsRunner); } } } else { // Schedule immediately exec.submit(action); } } }
[ "@", "Trivial", "private", "void", "performAction", "(", "Runnable", "action", ",", "boolean", "addToQueue", ")", "{", "ExecutorService", "exec", "=", "executorService", ".", "getService", "(", ")", ";", "if", "(", "exec", "==", "null", ")", "{", "// If we can't find the executor service, we have to run it in place.", "action", ".", "run", "(", ")", ";", "}", "else", "{", "// If we can find the executor service, we'll add the action to the queue.", "// If the actionFuture is null (no pending actions) and the configFuture is null (no", "// pending configuration updates), we'll submit the actionsRunner to the executor", "// service to drain the queue", "//", "// configFuture is used to avoid bouncing the endpoint multiple times because of a", "// single configuration update.", "//", "// actionFuture is only set to a non-null value by kicking off the executor service here.", "// actionsRunner syncs on actionQueue, so we can't add any new actions while we are", "// draining the queue. When the queue is empty, actionFuture is explicitly set to null.", "//", "// Long story short, it prevents us from kicking off multiple executors which could run in", "// random order.", "if", "(", "addToQueue", ")", "{", "synchronized", "(", "actionQueue", ")", "{", "actionQueue", ".", "add", "(", "action", ")", ";", "if", "(", "(", "actionFuture", "==", "null", ")", "&&", "(", "configFuture", "==", "null", ")", ")", "{", "actionFuture", "=", "exec", ".", "submit", "(", "actionsRunner", ")", ";", "}", "}", "}", "else", "{", "// Schedule immediately", "exec", ".", "submit", "(", "action", ")", ";", "}", "}", "}" ]
Schedule an activity to run off the SCR action thread, if the ExecutorService is available @param action Runnable action to execute @param addToQueue Set to false if the action should be scheduled independently of the actionQueue
[ "Schedule", "an", "activity", "to", "run", "off", "the", "SCR", "action", "thread", "if", "the", "ExecutorService", "is", "available" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/internal/HttpEndpointImpl.java#L748-L782
train
OpenLiberty/open-liberty
dev/com.ibm.ws.threading/src/com/ibm/ws/threading/internal/ThroughputDistribution.java
ThroughputDistribution.reset
synchronized void reset(double value, int updated) { ewma = value; ewmaStddev = value * SINGLE_VALUE_STDDEV; ewmaVariance = ewmaStddev * ewmaStddev; consecutiveOutliers = 0; lastUpdate = updated; }
java
synchronized void reset(double value, int updated) { ewma = value; ewmaStddev = value * SINGLE_VALUE_STDDEV; ewmaVariance = ewmaStddev * ewmaStddev; consecutiveOutliers = 0; lastUpdate = updated; }
[ "synchronized", "void", "reset", "(", "double", "value", ",", "int", "updated", ")", "{", "ewma", "=", "value", ";", "ewmaStddev", "=", "value", "*", "SINGLE_VALUE_STDDEV", ";", "ewmaVariance", "=", "ewmaStddev", "*", "ewmaStddev", ";", "consecutiveOutliers", "=", "0", ";", "lastUpdate", "=", "updated", ";", "}" ]
Reset the distribution by throwing away all history and adding a single data point. @param value the single data point that makes up the distribution
[ "Reset", "the", "distribution", "by", "throwing", "away", "all", "history", "and", "adding", "a", "single", "data", "point", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.threading/src/com/ibm/ws/threading/internal/ThroughputDistribution.java#L95-L101
train
OpenLiberty/open-liberty
dev/com.ibm.ws.threading/src/com/ibm/ws/threading/internal/ThroughputDistribution.java
ThroughputDistribution.addDataPoint
synchronized void addDataPoint(double value, int updated) { // 8/10/2012: Force the standard deviation to 1/3 of the first data point // 8/11:2012: Force it to 1/6th of the first data point (more accurate) if (ewmaVariance == Double.NEGATIVE_INFINITY) { reset(value, updated); return; } double delta = value - ewma; double increment = ALPHA * delta; ewma += increment; ewmaVariance = (1 - ALPHA) * (ewmaVariance + delta * increment); ewmaStddev = Math.sqrt(ewmaVariance); lastUpdate = updated; }
java
synchronized void addDataPoint(double value, int updated) { // 8/10/2012: Force the standard deviation to 1/3 of the first data point // 8/11:2012: Force it to 1/6th of the first data point (more accurate) if (ewmaVariance == Double.NEGATIVE_INFINITY) { reset(value, updated); return; } double delta = value - ewma; double increment = ALPHA * delta; ewma += increment; ewmaVariance = (1 - ALPHA) * (ewmaVariance + delta * increment); ewmaStddev = Math.sqrt(ewmaVariance); lastUpdate = updated; }
[ "synchronized", "void", "addDataPoint", "(", "double", "value", ",", "int", "updated", ")", "{", "// 8/10/2012: Force the standard deviation to 1/3 of the first data point", "// 8/11:2012: Force it to 1/6th of the first data point (more accurate)", "if", "(", "ewmaVariance", "==", "Double", ".", "NEGATIVE_INFINITY", ")", "{", "reset", "(", "value", ",", "updated", ")", ";", "return", ";", "}", "double", "delta", "=", "value", "-", "ewma", ";", "double", "increment", "=", "ALPHA", "*", "delta", ";", "ewma", "+=", "increment", ";", "ewmaVariance", "=", "(", "1", "-", "ALPHA", ")", "*", "(", "ewmaVariance", "+", "delta", "*", "increment", ")", ";", "ewmaStddev", "=", "Math", ".", "sqrt", "(", "ewmaVariance", ")", ";", "lastUpdate", "=", "updated", ";", "}" ]
Add a throughput observation to the distribution, setting lastUpdate @param value the observed throughput
[ "Add", "a", "throughput", "observation", "to", "the", "distribution", "setting", "lastUpdate" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.threading/src/com/ibm/ws/threading/internal/ThroughputDistribution.java#L143-L159
train
OpenLiberty/open-liberty
dev/com.ibm.websphere.javaee.el.3.0/src/javax/el/Util.java
Util.handleThrowable
static void handleThrowable(Throwable t) { if (t instanceof ThreadDeath) { throw (ThreadDeath) t; } if (t instanceof VirtualMachineError) { throw (VirtualMachineError) t; } // All other instances of Throwable will be silently swallowed }
java
static void handleThrowable(Throwable t) { if (t instanceof ThreadDeath) { throw (ThreadDeath) t; } if (t instanceof VirtualMachineError) { throw (VirtualMachineError) t; } // All other instances of Throwable will be silently swallowed }
[ "static", "void", "handleThrowable", "(", "Throwable", "t", ")", "{", "if", "(", "t", "instanceof", "ThreadDeath", ")", "{", "throw", "(", "ThreadDeath", ")", "t", ";", "}", "if", "(", "t", "instanceof", "VirtualMachineError", ")", "{", "throw", "(", "VirtualMachineError", ")", "t", ";", "}", "// All other instances of Throwable will be silently swallowed", "}" ]
Checks whether the supplied Throwable is one that needs to be rethrown and swallows all others. @param t the Throwable to check
[ "Checks", "whether", "the", "supplied", "Throwable", "is", "one", "that", "needs", "to", "be", "rethrown", "and", "swallows", "all", "others", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.websphere.javaee.el.3.0/src/javax/el/Util.java#L48-L56
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.authentication.builtin/src/com/ibm/ws/security/authentication/internal/cache/Cache.java
Cache.isEvictionRequired
protected boolean isEvictionRequired() { boolean evictionRequired = false; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { int size = primaryTable.size() + secondaryTable.size() + tertiaryTable.size(); Tr.debug(tc, "The current cache size is " + size + "( " + primaryTable.size() + ", " + secondaryTable.size() + ", " + tertiaryTable.size() + ")"); } if (entryLimit != 0 && entryLimit != Integer.MAX_VALUE) { int size = primaryTable.size() + secondaryTable.size() + tertiaryTable.size(); // If the cache size is greater than its limit, time to purge... if (size > entryLimit) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "The cache size is " + size + "( " + primaryTable.size() + ", " + secondaryTable.size() + ", " + tertiaryTable.size() + ") which is greater than the cache limit of " + entryLimit + "."); evictionRequired = true; } } return evictionRequired; }
java
protected boolean isEvictionRequired() { boolean evictionRequired = false; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { int size = primaryTable.size() + secondaryTable.size() + tertiaryTable.size(); Tr.debug(tc, "The current cache size is " + size + "( " + primaryTable.size() + ", " + secondaryTable.size() + ", " + tertiaryTable.size() + ")"); } if (entryLimit != 0 && entryLimit != Integer.MAX_VALUE) { int size = primaryTable.size() + secondaryTable.size() + tertiaryTable.size(); // If the cache size is greater than its limit, time to purge... if (size > entryLimit) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "The cache size is " + size + "( " + primaryTable.size() + ", " + secondaryTable.size() + ", " + tertiaryTable.size() + ") which is greater than the cache limit of " + entryLimit + "."); evictionRequired = true; } } return evictionRequired; }
[ "protected", "boolean", "isEvictionRequired", "(", ")", "{", "boolean", "evictionRequired", "=", "false", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "int", "size", "=", "primaryTable", ".", "size", "(", ")", "+", "secondaryTable", ".", "size", "(", ")", "+", "tertiaryTable", ".", "size", "(", ")", ";", "Tr", ".", "debug", "(", "tc", ",", "\"The current cache size is \"", "+", "size", "+", "\"( \"", "+", "primaryTable", ".", "size", "(", ")", "+", "\", \"", "+", "secondaryTable", ".", "size", "(", ")", "+", "\", \"", "+", "tertiaryTable", ".", "size", "(", ")", "+", "\")\"", ")", ";", "}", "if", "(", "entryLimit", "!=", "0", "&&", "entryLimit", "!=", "Integer", ".", "MAX_VALUE", ")", "{", "int", "size", "=", "primaryTable", ".", "size", "(", ")", "+", "secondaryTable", ".", "size", "(", ")", "+", "tertiaryTable", ".", "size", "(", ")", ";", "// If the cache size is greater than its limit, time to purge...", "if", "(", "size", ">", "entryLimit", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "Tr", ".", "debug", "(", "tc", ",", "\"The cache size is \"", "+", "size", "+", "\"( \"", "+", "primaryTable", ".", "size", "(", ")", "+", "\", \"", "+", "secondaryTable", ".", "size", "(", ")", "+", "\", \"", "+", "tertiaryTable", ".", "size", "(", ")", "+", "\") which is greater than the cache limit of \"", "+", "entryLimit", "+", "\".\"", ")", ";", "evictionRequired", "=", "true", ";", "}", "}", "return", "evictionRequired", ";", "}" ]
Determine if the cache is &quot;full&quot; and entries need to be evicted.
[ "Determine", "if", "the", "cache", "is", "&quot", ";", "full&quot", ";", "and", "entries", "need", "to", "be", "evicted", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.authentication.builtin/src/com/ibm/ws/security/authentication/internal/cache/Cache.java#L190-L209
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/ee6/MyFacesContainerInitializer.java
MyFacesContainerInitializer.isDelegatedFacesServlet
private boolean isDelegatedFacesServlet(String className) { if (className == null) { // The class name can be null if this is e.g., a JSP mapped to // a servlet. return false; } try { Class<?> clazz = Class.forName(className); return DELEGATED_FACES_SERVLET_CLASS.isAssignableFrom(clazz); } catch (ClassNotFoundException cnfe) { return false; } }
java
private boolean isDelegatedFacesServlet(String className) { if (className == null) { // The class name can be null if this is e.g., a JSP mapped to // a servlet. return false; } try { Class<?> clazz = Class.forName(className); return DELEGATED_FACES_SERVLET_CLASS.isAssignableFrom(clazz); } catch (ClassNotFoundException cnfe) { return false; } }
[ "private", "boolean", "isDelegatedFacesServlet", "(", "String", "className", ")", "{", "if", "(", "className", "==", "null", ")", "{", "// The class name can be null if this is e.g., a JSP mapped to", "// a servlet.", "return", "false", ";", "}", "try", "{", "Class", "<", "?", ">", "clazz", "=", "Class", ".", "forName", "(", "className", ")", ";", "return", "DELEGATED_FACES_SERVLET_CLASS", ".", "isAssignableFrom", "(", "clazz", ")", ";", "}", "catch", "(", "ClassNotFoundException", "cnfe", ")", "{", "return", "false", ";", "}", "}" ]
Checks if the class represented by className implements DelegatedFacesServlet. @param className @return
[ "Checks", "if", "the", "class", "represented", "by", "className", "implements", "DelegatedFacesServlet", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/ee6/MyFacesContainerInitializer.java#L287-L305
train
OpenLiberty/open-liberty
dev/com.ibm.ws.monitor/src/com/ibm/ws/pmi/server/PmiRegistry.java
PmiRegistry.unregisterModule
public static synchronized void unregisterModule(PmiModule instance) { if (disabled) return; if (instance == null) // || instance.getPath().length<=1) return; return; // check if the path has null in it. if a module is unregistered twice // the path will have null String[] path = instance.getPath(); if (path == null || path.length == 0) return; for (int k = 0; k < path.length; k++) { if (path[k] == null) return; } if (tc.isEntryEnabled()) Tr.entry(tc, "unregisterModule: " + instance.getModuleID() + ", " + instance.getName()); // unregister itself String[] parentPath = new String[path.length - 1]; System.arraycopy(path, 0, parentPath, 0, parentPath.length); // locate parent ModuleItem parent = moduleRoot.find(parentPath, 0); if (parent != null) { // remove "instance" from parent parent.remove(parent.find(path[path.length - 1])); // do not remove the empty parent group in custom pmi // in custom PMI groups/instances are explicitly created and // should be remove explicitly // in pre-custom groups are create IMPLICITYLY when needed if (instance.isCustomModule()) return; // check if parent is empty if (parent.children == null || parent.children.size() == 0) { if (parent.getInstance() != null) { String[] mypath = parent.getInstance().getPath(); // TODO: ask Wenjian about this? // exclude WEBAPP_MODULE because it is created explicitly and // should be removed explictly by calling PmiFactory.removePmiModule if (!(mypath.length == 2 && (mypath[0].equals(WEBSERVICES_MODULE)))) { // recursive call?: unregisterModule (parent.getInstance()); parent.getInstance().unregister(); } } } } if (tc.isEntryEnabled()) Tr.exit(tc, "unregisterModule"); }
java
public static synchronized void unregisterModule(PmiModule instance) { if (disabled) return; if (instance == null) // || instance.getPath().length<=1) return; return; // check if the path has null in it. if a module is unregistered twice // the path will have null String[] path = instance.getPath(); if (path == null || path.length == 0) return; for (int k = 0; k < path.length; k++) { if (path[k] == null) return; } if (tc.isEntryEnabled()) Tr.entry(tc, "unregisterModule: " + instance.getModuleID() + ", " + instance.getName()); // unregister itself String[] parentPath = new String[path.length - 1]; System.arraycopy(path, 0, parentPath, 0, parentPath.length); // locate parent ModuleItem parent = moduleRoot.find(parentPath, 0); if (parent != null) { // remove "instance" from parent parent.remove(parent.find(path[path.length - 1])); // do not remove the empty parent group in custom pmi // in custom PMI groups/instances are explicitly created and // should be remove explicitly // in pre-custom groups are create IMPLICITYLY when needed if (instance.isCustomModule()) return; // check if parent is empty if (parent.children == null || parent.children.size() == 0) { if (parent.getInstance() != null) { String[] mypath = parent.getInstance().getPath(); // TODO: ask Wenjian about this? // exclude WEBAPP_MODULE because it is created explicitly and // should be removed explictly by calling PmiFactory.removePmiModule if (!(mypath.length == 2 && (mypath[0].equals(WEBSERVICES_MODULE)))) { // recursive call?: unregisterModule (parent.getInstance()); parent.getInstance().unregister(); } } } } if (tc.isEntryEnabled()) Tr.exit(tc, "unregisterModule"); }
[ "public", "static", "synchronized", "void", "unregisterModule", "(", "PmiModule", "instance", ")", "{", "if", "(", "disabled", ")", "return", ";", "if", "(", "instance", "==", "null", ")", "// || instance.getPath().length<=1) return;", "return", ";", "// check if the path has null in it. if a module is unregistered twice", "// the path will have null", "String", "[", "]", "path", "=", "instance", ".", "getPath", "(", ")", ";", "if", "(", "path", "==", "null", "||", "path", ".", "length", "==", "0", ")", "return", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "path", ".", "length", ";", "k", "++", ")", "{", "if", "(", "path", "[", "k", "]", "==", "null", ")", "return", ";", "}", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "entry", "(", "tc", ",", "\"unregisterModule: \"", "+", "instance", ".", "getModuleID", "(", ")", "+", "\", \"", "+", "instance", ".", "getName", "(", ")", ")", ";", "// unregister itself", "String", "[", "]", "parentPath", "=", "new", "String", "[", "path", ".", "length", "-", "1", "]", ";", "System", ".", "arraycopy", "(", "path", ",", "0", ",", "parentPath", ",", "0", ",", "parentPath", ".", "length", ")", ";", "// locate parent", "ModuleItem", "parent", "=", "moduleRoot", ".", "find", "(", "parentPath", ",", "0", ")", ";", "if", "(", "parent", "!=", "null", ")", "{", "// remove \"instance\" from parent", "parent", ".", "remove", "(", "parent", ".", "find", "(", "path", "[", "path", ".", "length", "-", "1", "]", ")", ")", ";", "// do not remove the empty parent group in custom pmi", "// in custom PMI groups/instances are explicitly created and", "// should be remove explicitly", "// in pre-custom groups are create IMPLICITYLY when needed", "if", "(", "instance", ".", "isCustomModule", "(", ")", ")", "return", ";", "// check if parent is empty", "if", "(", "parent", ".", "children", "==", "null", "||", "parent", ".", "children", ".", "size", "(", ")", "==", "0", ")", "{", "if", "(", "parent", ".", "getInstance", "(", ")", "!=", "null", ")", "{", "String", "[", "]", "mypath", "=", "parent", ".", "getInstance", "(", ")", ".", "getPath", "(", ")", ";", "// TODO: ask Wenjian about this?", "// exclude WEBAPP_MODULE because it is created explicitly and", "// should be removed explictly by calling PmiFactory.removePmiModule", "if", "(", "!", "(", "mypath", ".", "length", "==", "2", "&&", "(", "mypath", "[", "0", "]", ".", "equals", "(", "WEBSERVICES_MODULE", ")", ")", ")", ")", "{", "// recursive call?: unregisterModule (parent.getInstance());", "parent", ".", "getInstance", "(", ")", ".", "unregister", "(", ")", ";", "}", "}", "}", "}", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "exit", "(", "tc", ",", "\"unregisterModule\"", ")", ";", "}" ]
remove module - never remove TYPE_MODULE.
[ "remove", "module", "-", "never", "remove", "TYPE_MODULE", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.monitor/src/com/ibm/ws/pmi/server/PmiRegistry.java#L265-L316
train
OpenLiberty/open-liberty
dev/com.ibm.ws.monitor/src/com/ibm/ws/pmi/server/PmiRegistry.java
PmiRegistry.getModuleAggregate
protected static ModuleAggregate getModuleAggregate(String moduleID) { ModuleAggregate aggregate = (ModuleAggregate) moduleAggregates.get(moduleID); if (aggregate != null) return aggregate; // need to create it - synchronized synchronized (moduleAggregates) { aggregate = (ModuleAggregate) moduleAggregates.get(moduleID); if (aggregate != null) return aggregate; PmiModuleConfig config = getConfig(moduleID); if (config == null) return null; aggregate = new ModuleAggregate(moduleID); moduleAggregates.put(moduleID, aggregate); return aggregate; } }
java
protected static ModuleAggregate getModuleAggregate(String moduleID) { ModuleAggregate aggregate = (ModuleAggregate) moduleAggregates.get(moduleID); if (aggregate != null) return aggregate; // need to create it - synchronized synchronized (moduleAggregates) { aggregate = (ModuleAggregate) moduleAggregates.get(moduleID); if (aggregate != null) return aggregate; PmiModuleConfig config = getConfig(moduleID); if (config == null) return null; aggregate = new ModuleAggregate(moduleID); moduleAggregates.put(moduleID, aggregate); return aggregate; } }
[ "protected", "static", "ModuleAggregate", "getModuleAggregate", "(", "String", "moduleID", ")", "{", "ModuleAggregate", "aggregate", "=", "(", "ModuleAggregate", ")", "moduleAggregates", ".", "get", "(", "moduleID", ")", ";", "if", "(", "aggregate", "!=", "null", ")", "return", "aggregate", ";", "// need to create it - synchronized", "synchronized", "(", "moduleAggregates", ")", "{", "aggregate", "=", "(", "ModuleAggregate", ")", "moduleAggregates", ".", "get", "(", "moduleID", ")", ";", "if", "(", "aggregate", "!=", "null", ")", "return", "aggregate", ";", "PmiModuleConfig", "config", "=", "getConfig", "(", "moduleID", ")", ";", "if", "(", "config", "==", "null", ")", "return", "null", ";", "aggregate", "=", "new", "ModuleAggregate", "(", "moduleID", ")", ";", "moduleAggregates", ".", "put", "(", "moduleID", ",", "aggregate", ")", ";", "return", "aggregate", ";", "}", "}" ]
create it if not there - synchronized
[ "create", "it", "if", "not", "there", "-", "synchronized" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.monitor/src/com/ibm/ws/pmi/server/PmiRegistry.java#L347-L363
train
OpenLiberty/open-liberty
dev/com.ibm.ws.monitor/src/com/ibm/ws/pmi/server/PmiRegistry.java
PmiRegistry.findModuleItem
public static ModuleItem findModuleItem(String[] path) { if (disabled) return null; if (path == null || path[0].equals(APPSERVER_MODULE)) { return moduleRoot; } return moduleRoot.find(path, 0); }
java
public static ModuleItem findModuleItem(String[] path) { if (disabled) return null; if (path == null || path[0].equals(APPSERVER_MODULE)) { return moduleRoot; } return moduleRoot.find(path, 0); }
[ "public", "static", "ModuleItem", "findModuleItem", "(", "String", "[", "]", "path", ")", "{", "if", "(", "disabled", ")", "return", "null", ";", "if", "(", "path", "==", "null", "||", "path", "[", "0", "]", ".", "equals", "(", "APPSERVER_MODULE", ")", ")", "{", "return", "moduleRoot", ";", "}", "return", "moduleRoot", ".", "find", "(", "path", ",", "0", ")", ";", "}" ]
find a ModuleItem
[ "find", "a", "ModuleItem" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.monitor/src/com/ibm/ws/pmi/server/PmiRegistry.java#L411-L418
train
OpenLiberty/open-liberty
dev/com.ibm.ws.monitor/src/com/ibm/ws/pmi/server/PmiRegistry.java
PmiRegistry.getInstrumentationLevel
public static StatLevelSpec[] getInstrumentationLevel(StatDescriptor sd, boolean recursive) { if (disabled) return null; ModuleItem item = findModuleItem(sd.getPath()); if (item == null) { // wrong moduleName return null; } else { if (!recursive) { StatLevelSpec[] pld = new StatLevelSpec[1]; PmiModule instance = item.getInstance(); if (instance != null) { pld[0] = new StatLevelSpec(sd.getPath(), instance.getEnabled()); return pld; } else { return null; } } else { ArrayList res = item.getStatLevelSpec(recursive); StatLevelSpec[] pld = new StatLevelSpec[res.size()]; for (int i = 0; i < pld.length; i++) pld[i] = (StatLevelSpec) res.get(i); return pld; } } }
java
public static StatLevelSpec[] getInstrumentationLevel(StatDescriptor sd, boolean recursive) { if (disabled) return null; ModuleItem item = findModuleItem(sd.getPath()); if (item == null) { // wrong moduleName return null; } else { if (!recursive) { StatLevelSpec[] pld = new StatLevelSpec[1]; PmiModule instance = item.getInstance(); if (instance != null) { pld[0] = new StatLevelSpec(sd.getPath(), instance.getEnabled()); return pld; } else { return null; } } else { ArrayList res = item.getStatLevelSpec(recursive); StatLevelSpec[] pld = new StatLevelSpec[res.size()]; for (int i = 0; i < pld.length; i++) pld[i] = (StatLevelSpec) res.get(i); return pld; } } }
[ "public", "static", "StatLevelSpec", "[", "]", "getInstrumentationLevel", "(", "StatDescriptor", "sd", ",", "boolean", "recursive", ")", "{", "if", "(", "disabled", ")", "return", "null", ";", "ModuleItem", "item", "=", "findModuleItem", "(", "sd", ".", "getPath", "(", ")", ")", ";", "if", "(", "item", "==", "null", ")", "{", "// wrong moduleName", "return", "null", ";", "}", "else", "{", "if", "(", "!", "recursive", ")", "{", "StatLevelSpec", "[", "]", "pld", "=", "new", "StatLevelSpec", "[", "1", "]", ";", "PmiModule", "instance", "=", "item", ".", "getInstance", "(", ")", ";", "if", "(", "instance", "!=", "null", ")", "{", "pld", "[", "0", "]", "=", "new", "StatLevelSpec", "(", "sd", ".", "getPath", "(", ")", ",", "instance", ".", "getEnabled", "(", ")", ")", ";", "return", "pld", ";", "}", "else", "{", "return", "null", ";", "}", "}", "else", "{", "ArrayList", "res", "=", "item", ".", "getStatLevelSpec", "(", "recursive", ")", ";", "StatLevelSpec", "[", "]", "pld", "=", "new", "StatLevelSpec", "[", "res", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pld", ".", "length", ";", "i", "++", ")", "pld", "[", "i", "]", "=", "(", "StatLevelSpec", ")", "res", ".", "get", "(", "i", ")", ";", "return", "pld", ";", "}", "}", "}" ]
6.0 API
[ "6", ".", "0", "API" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.monitor/src/com/ibm/ws/pmi/server/PmiRegistry.java#L664-L690
train
OpenLiberty/open-liberty
dev/com.ibm.ws.monitor/src/com/ibm/ws/pmi/server/PmiRegistry.java
PmiRegistry.getInstrumentationLevel
public static int getInstrumentationLevel(String[] path) { if (disabled) return LEVEL_UNDEFINED; DataDescriptor dd = new DataDescriptor(path); ModuleItem item = findModuleItem(dd); if (item == null) { // wrong moduleName return LEVEL_UNDEFINED; } else { return item.getInstance().getInstrumentationLevel(); } }
java
public static int getInstrumentationLevel(String[] path) { if (disabled) return LEVEL_UNDEFINED; DataDescriptor dd = new DataDescriptor(path); ModuleItem item = findModuleItem(dd); if (item == null) { // wrong moduleName return LEVEL_UNDEFINED; } else { return item.getInstance().getInstrumentationLevel(); } }
[ "public", "static", "int", "getInstrumentationLevel", "(", "String", "[", "]", "path", ")", "{", "if", "(", "disabled", ")", "return", "LEVEL_UNDEFINED", ";", "DataDescriptor", "dd", "=", "new", "DataDescriptor", "(", "path", ")", ";", "ModuleItem", "item", "=", "findModuleItem", "(", "dd", ")", ";", "if", "(", "item", "==", "null", ")", "{", "// wrong moduleName", "return", "LEVEL_UNDEFINED", ";", "}", "else", "{", "return", "item", ".", "getInstance", "(", ")", ".", "getInstrumentationLevel", "(", ")", ";", "}", "}" ]
get instrumenation level based on the path during runtime
[ "get", "instrumenation", "level", "based", "on", "the", "path", "during", "runtime" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.monitor/src/com/ibm/ws/pmi/server/PmiRegistry.java#L819-L829
train
OpenLiberty/open-liberty
dev/com.ibm.ws.monitor/src/com/ibm/ws/pmi/server/PmiRegistry.java
PmiRegistry.getInstrumentationLevelString
public static String getInstrumentationLevelString() { if (disabled) return null; Map modules = moduleRoot.children; if (modules == null) { return ""; } else { PerfLevelDescriptor[] plds = new PerfLevelDescriptor[modules.size()]; Iterator values = modules.values().iterator(); int i = 0; while (values.hasNext()) { PmiModule instance = ((ModuleItem) values.next()).getInstance(); plds[i++] = new PerfLevelDescriptor(instance.getPath(), instance.getInstrumentationLevel(), instance.getModuleID()); } return PmiUtil.getStringFromPerfLevelSpecs(plds); } }
java
public static String getInstrumentationLevelString() { if (disabled) return null; Map modules = moduleRoot.children; if (modules == null) { return ""; } else { PerfLevelDescriptor[] plds = new PerfLevelDescriptor[modules.size()]; Iterator values = modules.values().iterator(); int i = 0; while (values.hasNext()) { PmiModule instance = ((ModuleItem) values.next()).getInstance(); plds[i++] = new PerfLevelDescriptor(instance.getPath(), instance.getInstrumentationLevel(), instance.getModuleID()); } return PmiUtil.getStringFromPerfLevelSpecs(plds); } }
[ "public", "static", "String", "getInstrumentationLevelString", "(", ")", "{", "if", "(", "disabled", ")", "return", "null", ";", "Map", "modules", "=", "moduleRoot", ".", "children", ";", "if", "(", "modules", "==", "null", ")", "{", "return", "\"\"", ";", "}", "else", "{", "PerfLevelDescriptor", "[", "]", "plds", "=", "new", "PerfLevelDescriptor", "[", "modules", ".", "size", "(", ")", "]", ";", "Iterator", "values", "=", "modules", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "int", "i", "=", "0", ";", "while", "(", "values", ".", "hasNext", "(", ")", ")", "{", "PmiModule", "instance", "=", "(", "(", "ModuleItem", ")", "values", ".", "next", "(", ")", ")", ".", "getInstance", "(", ")", ";", "plds", "[", "i", "++", "]", "=", "new", "PerfLevelDescriptor", "(", "instance", ".", "getPath", "(", ")", ",", "instance", ".", "getInstrumentationLevel", "(", ")", ",", "instance", ".", "getModuleID", "(", ")", ")", ";", "}", "return", "PmiUtil", ".", "getStringFromPerfLevelSpecs", "(", "plds", ")", ";", "}", "}" ]
return the top level modules's PerfLevelDescriptor in String
[ "return", "the", "top", "level", "modules", "s", "PerfLevelDescriptor", "in", "String" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.monitor/src/com/ibm/ws/pmi/server/PmiRegistry.java#L845-L863
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.jwt/src/com/ibm/websphere/security/jwt/JwtBuilder.java
JwtBuilder.audience
public JwtBuilder audience(List<String> newaudiences) throws InvalidClaimException { // this.AUDIENCE // if (newaudiences != null && !newaudiences.isEmpty()) { // // ArrayList<String> audiences = new ArrayList<String>(); // for (String aud : newaudiences) { // if (aud != null && !aud.trim().isEmpty() // && !audiences.contains(aud)) { // audiences.add(aud); // } // } // if (audiences.isEmpty()) { // String err = Tr.formatMessage(tc, // "JWT_INVALID_CLAIM_VALUE_ERR", new Object[] { // Claims.AUDIENCE, newaudiences }); // throw new InvalidClaimException(err); // } // // this.audiences = new ArrayList<String>(audiences); // claims.put(Claims.AUDIENCE, audiences); // } else { // String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_VALUE_ERR", // new Object[] { Claims.AUDIENCE, newaudiences }); // throw new InvalidClaimException(err); // } builder = builder.audience(newaudiences); return this; }
java
public JwtBuilder audience(List<String> newaudiences) throws InvalidClaimException { // this.AUDIENCE // if (newaudiences != null && !newaudiences.isEmpty()) { // // ArrayList<String> audiences = new ArrayList<String>(); // for (String aud : newaudiences) { // if (aud != null && !aud.trim().isEmpty() // && !audiences.contains(aud)) { // audiences.add(aud); // } // } // if (audiences.isEmpty()) { // String err = Tr.formatMessage(tc, // "JWT_INVALID_CLAIM_VALUE_ERR", new Object[] { // Claims.AUDIENCE, newaudiences }); // throw new InvalidClaimException(err); // } // // this.audiences = new ArrayList<String>(audiences); // claims.put(Claims.AUDIENCE, audiences); // } else { // String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_VALUE_ERR", // new Object[] { Claims.AUDIENCE, newaudiences }); // throw new InvalidClaimException(err); // } builder = builder.audience(newaudiences); return this; }
[ "public", "JwtBuilder", "audience", "(", "List", "<", "String", ">", "newaudiences", ")", "throws", "InvalidClaimException", "{", "// this.AUDIENCE", "// if (newaudiences != null && !newaudiences.isEmpty()) {", "//", "// ArrayList<String> audiences = new ArrayList<String>();", "// for (String aud : newaudiences) {", "// if (aud != null && !aud.trim().isEmpty()", "// && !audiences.contains(aud)) {", "// audiences.add(aud);", "// }", "// }", "// if (audiences.isEmpty()) {", "// String err = Tr.formatMessage(tc,", "// \"JWT_INVALID_CLAIM_VALUE_ERR\", new Object[] {", "// Claims.AUDIENCE, newaudiences });", "// throw new InvalidClaimException(err);", "// }", "// // this.audiences = new ArrayList<String>(audiences);", "// claims.put(Claims.AUDIENCE, audiences);", "// } else {", "// String err = Tr.formatMessage(tc, \"JWT_INVALID_CLAIM_VALUE_ERR\",", "// new Object[] { Claims.AUDIENCE, newaudiences });", "// throw new InvalidClaimException(err);", "// }", "builder", "=", "builder", ".", "audience", "(", "newaudiences", ")", ";", "return", "this", ";", "}" ]
Sets audience claim. This claim in the JWT identifies the recipients that the token is intended for. @param newaudiences This is a list of Strings and will be used to set the "aud" claim in the {@code JwtToken} @return {@code JwtBuilder} object @throws InvalidClaimException Thrown if the newaudiences is {@code null}, or empty
[ "Sets", "audience", "claim", ".", "This", "claim", "in", "the", "JWT", "identifies", "the", "recipients", "that", "the", "token", "is", "intended", "for", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.jwt/src/com/ibm/websphere/security/jwt/JwtBuilder.java#L184-L211
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.jwt/src/com/ibm/websphere/security/jwt/JwtBuilder.java
JwtBuilder.signWith
public JwtBuilder signWith(String algorithm, Key key) throws KeyException { builder = builder.signWith(algorithm, key); return this; }
java
public JwtBuilder signWith(String algorithm, Key key) throws KeyException { builder = builder.signWith(algorithm, key); return this; }
[ "public", "JwtBuilder", "signWith", "(", "String", "algorithm", ",", "Key", "key", ")", "throws", "KeyException", "{", "builder", "=", "builder", ".", "signWith", "(", "algorithm", ",", "key", ")", ";", "return", "this", ";", "}" ]
Signing key and algorithm information. @param algorithm This String value represents the signing algorithm. This information will be used to sign the {@code JwtToken} @param key The private key {@code Key} to use for signing JWTs. @return {@code JwtBuilder} object @throws KeyException Thrown if the key is {@code null} or if algorithm is {@code null} or empty
[ "Signing", "key", "and", "algorithm", "information", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.jwt/src/com/ibm/websphere/security/jwt/JwtBuilder.java#L327-L330
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.jwt/src/com/ibm/websphere/security/jwt/JwtBuilder.java
JwtBuilder.claim
public JwtBuilder claim(String name, Object value) throws InvalidClaimException { // if (isValidClaim(name, value)) { // if (name.equals(Claims.AUDIENCE)) { // if (value instanceof ArrayList) { // this.audience((ArrayList) value); // } else if (value instanceof String) { // String[] auds = ((String) value).split(" "); // ArrayList<String> audList = new ArrayList<String>(); // for (String aud : auds) { // if (!aud.isEmpty()) { // audList.add(aud.trim()); // } // } // if (!audList.isEmpty()) { // this.audience(audList); // } // } else { // String msg = Tr.formatMessage(tc, // "JWT_INVALID_CLAIM_VALUE_TYPE", // new Object[] { Claims.AUDIENCE }); // throw new InvalidClaimException(msg); // } // } else if (name.equals(Claims.EXPIRATION)) { // if (value instanceof Long) { // this.expirationTime((Long) value); // } else if (value instanceof Integer) { // this.expirationTime(((Integer) value).longValue()); // } else { // String msg = Tr.formatMessage(tc, // "JWT_INVALID_CLAIM_VALUE_TYPE", // new Object[] { Claims.EXPIRATION }); // throw new InvalidClaimException(msg); // } // } else if (name.equals(Claims.ISSUED_AT)) { // if (value instanceof Long) { // this.issueTime((Long) value); // } else if (value instanceof Integer) { // this.expirationTime(((Integer) value).longValue()); // } else { // String msg = Tr.formatMessage(tc, // "JWT_INVALID_CLAIM_VALUE_TYPE", // new Object[] { Claims.ISSUED_AT }); // throw new InvalidClaimException(msg); // } // } else if (name.equals(Claims.NOT_BEFORE)) { // if (value instanceof Long) { // this.notBefore((Long) value); // } else if (value instanceof Integer) { // this.expirationTime(((Integer) value).longValue()); // } else { // String msg = Tr.formatMessage(tc, // "JWT_INVALID_CLAIM_VALUE_TYPE", // new Object[] { Claims.NOT_BEFORE }); // throw new InvalidClaimException(msg); // } // } else if (name.equals(Claims.ISSUER) || name.equals(Claims.SUBJECT)) { // if (value instanceof String) { // if (name.equals(Claims.ISSUER)) { // this.issuer((String) value); // } else { // this.subject((String) value); // } // } else { // String msg = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_VALUE_TYPE", new Object[] { name }); // throw new InvalidClaimException(msg); // } // } else { // claims.put(name, value); // } // } builder = builder.claim(name, value); return this; }
java
public JwtBuilder claim(String name, Object value) throws InvalidClaimException { // if (isValidClaim(name, value)) { // if (name.equals(Claims.AUDIENCE)) { // if (value instanceof ArrayList) { // this.audience((ArrayList) value); // } else if (value instanceof String) { // String[] auds = ((String) value).split(" "); // ArrayList<String> audList = new ArrayList<String>(); // for (String aud : auds) { // if (!aud.isEmpty()) { // audList.add(aud.trim()); // } // } // if (!audList.isEmpty()) { // this.audience(audList); // } // } else { // String msg = Tr.formatMessage(tc, // "JWT_INVALID_CLAIM_VALUE_TYPE", // new Object[] { Claims.AUDIENCE }); // throw new InvalidClaimException(msg); // } // } else if (name.equals(Claims.EXPIRATION)) { // if (value instanceof Long) { // this.expirationTime((Long) value); // } else if (value instanceof Integer) { // this.expirationTime(((Integer) value).longValue()); // } else { // String msg = Tr.formatMessage(tc, // "JWT_INVALID_CLAIM_VALUE_TYPE", // new Object[] { Claims.EXPIRATION }); // throw new InvalidClaimException(msg); // } // } else if (name.equals(Claims.ISSUED_AT)) { // if (value instanceof Long) { // this.issueTime((Long) value); // } else if (value instanceof Integer) { // this.expirationTime(((Integer) value).longValue()); // } else { // String msg = Tr.formatMessage(tc, // "JWT_INVALID_CLAIM_VALUE_TYPE", // new Object[] { Claims.ISSUED_AT }); // throw new InvalidClaimException(msg); // } // } else if (name.equals(Claims.NOT_BEFORE)) { // if (value instanceof Long) { // this.notBefore((Long) value); // } else if (value instanceof Integer) { // this.expirationTime(((Integer) value).longValue()); // } else { // String msg = Tr.formatMessage(tc, // "JWT_INVALID_CLAIM_VALUE_TYPE", // new Object[] { Claims.NOT_BEFORE }); // throw new InvalidClaimException(msg); // } // } else if (name.equals(Claims.ISSUER) || name.equals(Claims.SUBJECT)) { // if (value instanceof String) { // if (name.equals(Claims.ISSUER)) { // this.issuer((String) value); // } else { // this.subject((String) value); // } // } else { // String msg = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_VALUE_TYPE", new Object[] { name }); // throw new InvalidClaimException(msg); // } // } else { // claims.put(name, value); // } // } builder = builder.claim(name, value); return this; }
[ "public", "JwtBuilder", "claim", "(", "String", "name", ",", "Object", "value", ")", "throws", "InvalidClaimException", "{", "// if (isValidClaim(name, value)) {", "// if (name.equals(Claims.AUDIENCE)) {", "// if (value instanceof ArrayList) {", "// this.audience((ArrayList) value);", "// } else if (value instanceof String) {", "// String[] auds = ((String) value).split(\" \");", "// ArrayList<String> audList = new ArrayList<String>();", "// for (String aud : auds) {", "// if (!aud.isEmpty()) {", "// audList.add(aud.trim());", "// }", "// }", "// if (!audList.isEmpty()) {", "// this.audience(audList);", "// }", "// } else {", "// String msg = Tr.formatMessage(tc,", "// \"JWT_INVALID_CLAIM_VALUE_TYPE\",", "// new Object[] { Claims.AUDIENCE });", "// throw new InvalidClaimException(msg);", "// }", "// } else if (name.equals(Claims.EXPIRATION)) {", "// if (value instanceof Long) {", "// this.expirationTime((Long) value);", "// } else if (value instanceof Integer) {", "// this.expirationTime(((Integer) value).longValue());", "// } else {", "// String msg = Tr.formatMessage(tc,", "// \"JWT_INVALID_CLAIM_VALUE_TYPE\",", "// new Object[] { Claims.EXPIRATION });", "// throw new InvalidClaimException(msg);", "// }", "// } else if (name.equals(Claims.ISSUED_AT)) {", "// if (value instanceof Long) {", "// this.issueTime((Long) value);", "// } else if (value instanceof Integer) {", "// this.expirationTime(((Integer) value).longValue());", "// } else {", "// String msg = Tr.formatMessage(tc,", "// \"JWT_INVALID_CLAIM_VALUE_TYPE\",", "// new Object[] { Claims.ISSUED_AT });", "// throw new InvalidClaimException(msg);", "// }", "// } else if (name.equals(Claims.NOT_BEFORE)) {", "// if (value instanceof Long) {", "// this.notBefore((Long) value);", "// } else if (value instanceof Integer) {", "// this.expirationTime(((Integer) value).longValue());", "// } else {", "// String msg = Tr.formatMessage(tc,", "// \"JWT_INVALID_CLAIM_VALUE_TYPE\",", "// new Object[] { Claims.NOT_BEFORE });", "// throw new InvalidClaimException(msg);", "// }", "// } else if (name.equals(Claims.ISSUER) || name.equals(Claims.SUBJECT)) {", "// if (value instanceof String) {", "// if (name.equals(Claims.ISSUER)) {", "// this.issuer((String) value);", "// } else {", "// this.subject((String) value);", "// }", "// } else {", "// String msg = Tr.formatMessage(tc, \"JWT_INVALID_CLAIM_VALUE_TYPE\", new Object[] { name });", "// throw new InvalidClaimException(msg);", "// }", "// } else {", "// claims.put(name, value);", "// }", "// }", "builder", "=", "builder", ".", "claim", "(", "name", ",", "value", ")", ";", "return", "this", ";", "}" ]
Sets the specified claim. @param name This is a String and represents the name of the claim @param value This is an Object and represents the value of the claim @return {@code JwtBuilder} object @throws InvalidClaimException Thrown if the claim is {@code null}, or the value is {@code null} or the value is not the correct type for the claim
[ "Sets", "the", "specified", "claim", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.jwt/src/com/ibm/websphere/security/jwt/JwtBuilder.java#L364-L437
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.jwt/src/com/ibm/websphere/security/jwt/JwtBuilder.java
JwtBuilder.claim
public JwtBuilder claim(Map<String, Object> map) throws InvalidClaimException { // if (map == null) { // String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIMS_ERR");// "JWT_INVALID_CLAIMS_ERR"; // throw new InvalidClaimException(err); // } builder = builder.claim(map); return this; //return copyClaimsMap(map); // claims.putAll(map); // return this; }
java
public JwtBuilder claim(Map<String, Object> map) throws InvalidClaimException { // if (map == null) { // String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIMS_ERR");// "JWT_INVALID_CLAIMS_ERR"; // throw new InvalidClaimException(err); // } builder = builder.claim(map); return this; //return copyClaimsMap(map); // claims.putAll(map); // return this; }
[ "public", "JwtBuilder", "claim", "(", "Map", "<", "String", ",", "Object", ">", "map", ")", "throws", "InvalidClaimException", "{", "// if (map == null) {", "// String err = Tr.formatMessage(tc, \"JWT_INVALID_CLAIMS_ERR\");// \"JWT_INVALID_CLAIMS_ERR\";", "// throw new InvalidClaimException(err);", "// }", "builder", "=", "builder", ".", "claim", "(", "map", ")", ";", "return", "this", ";", "//return copyClaimsMap(map);", "// claims.putAll(map);", "// return this;", "}" ]
Sets the specified claims. @param map This is a Map and represents the collection of claim name and claim value pairs to be set in the JWT. @return {@code JwtBuilder} object @throws InvalidClaimException Thrown if the claim is {@code null}, or the value is {@code null} or the value is not the correct type for the claim
[ "Sets", "the", "specified", "claims", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.jwt/src/com/ibm/websphere/security/jwt/JwtBuilder.java#L451-L462
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.jwt/src/com/ibm/websphere/security/jwt/JwtBuilder.java
JwtBuilder.claimFrom
public JwtBuilder claimFrom(String jsonOrJwt, String claim) throws InvalidClaimException, InvalidTokenException { // if (JwtUtils.isNullEmpty(claim)) { // String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_ERR", // new Object[] { claim }); // throw new InvalidClaimException(err); // } // if (isValidToken(jsonOrJwt)) { // String decoded = jsonOrJwt; // if (JwtUtils.isBase64Encoded(jsonOrJwt)) { // decoded = JwtUtils.decodeFromBase64String(jsonOrJwt); // } // boolean isJson = JwtUtils.isJson(decoded); // // if (!isJson) { // String jwtPayload = JwtUtils.getPayload(jsonOrJwt); // decoded = JwtUtils.decodeFromBase64String(jwtPayload); // } // // // } else { // // // either decoded payload from jwt or encoded/decoded json string // // if (JwtUtils.isBase64Encoded(jsonOrJwt)) { // // decoded = JwtUtils.decodeFromBase64String(jsonOrJwt); // // } // // } // // if (decoded != null) { // Object claimValue = null; // try { // if ((claimValue = JwtUtils.claimFromJsonObject(decoded, // claim)) != null) { // claims.put(claim, claimValue); // } // } catch (IOException e) { // String err = Tr.formatMessage(tc, "JWT_INVALID_TOKEN_ERR"); // throw new InvalidTokenException(err); // } // } // } builder = builder.claimFrom(jsonOrJwt, claim); return this; }
java
public JwtBuilder claimFrom(String jsonOrJwt, String claim) throws InvalidClaimException, InvalidTokenException { // if (JwtUtils.isNullEmpty(claim)) { // String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_ERR", // new Object[] { claim }); // throw new InvalidClaimException(err); // } // if (isValidToken(jsonOrJwt)) { // String decoded = jsonOrJwt; // if (JwtUtils.isBase64Encoded(jsonOrJwt)) { // decoded = JwtUtils.decodeFromBase64String(jsonOrJwt); // } // boolean isJson = JwtUtils.isJson(decoded); // // if (!isJson) { // String jwtPayload = JwtUtils.getPayload(jsonOrJwt); // decoded = JwtUtils.decodeFromBase64String(jwtPayload); // } // // // } else { // // // either decoded payload from jwt or encoded/decoded json string // // if (JwtUtils.isBase64Encoded(jsonOrJwt)) { // // decoded = JwtUtils.decodeFromBase64String(jsonOrJwt); // // } // // } // // if (decoded != null) { // Object claimValue = null; // try { // if ((claimValue = JwtUtils.claimFromJsonObject(decoded, // claim)) != null) { // claims.put(claim, claimValue); // } // } catch (IOException e) { // String err = Tr.formatMessage(tc, "JWT_INVALID_TOKEN_ERR"); // throw new InvalidTokenException(err); // } // } // } builder = builder.claimFrom(jsonOrJwt, claim); return this; }
[ "public", "JwtBuilder", "claimFrom", "(", "String", "jsonOrJwt", ",", "String", "claim", ")", "throws", "InvalidClaimException", ",", "InvalidTokenException", "{", "// if (JwtUtils.isNullEmpty(claim)) {", "// String err = Tr.formatMessage(tc, \"JWT_INVALID_CLAIM_ERR\",", "// new Object[] { claim });", "// throw new InvalidClaimException(err);", "// }", "// if (isValidToken(jsonOrJwt)) {", "// String decoded = jsonOrJwt;", "// if (JwtUtils.isBase64Encoded(jsonOrJwt)) {", "// decoded = JwtUtils.decodeFromBase64String(jsonOrJwt);", "// }", "// boolean isJson = JwtUtils.isJson(decoded);", "//", "// if (!isJson) {", "// String jwtPayload = JwtUtils.getPayload(jsonOrJwt);", "// decoded = JwtUtils.decodeFromBase64String(jwtPayload);", "// }", "//", "// // } else {", "// // // either decoded payload from jwt or encoded/decoded json string", "// // if (JwtUtils.isBase64Encoded(jsonOrJwt)) {", "// // decoded = JwtUtils.decodeFromBase64String(jsonOrJwt);", "// // }", "// // }", "//", "// if (decoded != null) {", "// Object claimValue = null;", "// try {", "// if ((claimValue = JwtUtils.claimFromJsonObject(decoded,", "// claim)) != null) {", "// claims.put(claim, claimValue);", "// }", "// } catch (IOException e) {", "// String err = Tr.formatMessage(tc, \"JWT_INVALID_TOKEN_ERR\");", "// throw new InvalidTokenException(err);", "// }", "// }", "// }", "builder", "=", "builder", ".", "claimFrom", "(", "jsonOrJwt", ",", "claim", ")", ";", "return", "this", ";", "}" ]
Retrieves the specified claim from the given json or jwt string. @param jsonOrJwt This is a String and represents either base 64 encoded or decoded JWT payload in the json format or base 64 encoded JWT @return {@code JwtBuilder} object @throws InvalidClaimException Thrown if the claim is {@code null} or empty @throws InvalidTokenException Thrown if the jsonOrJwt is {@code null} or if the api fails to process the string
[ "Retrieves", "the", "specified", "claim", "from", "the", "given", "json", "or", "jwt", "string", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.jwt/src/com/ibm/websphere/security/jwt/JwtBuilder.java#L542-L584
train
OpenLiberty/open-liberty
dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/jfapchannel/impl/rldispatcher/ReceiveListenerDataReceivedInvocation.java
ReceiveListenerDataReceivedInvocation.getThreadContext
protected Dispatchable getThreadContext() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getThreadContext"); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getThreadContext"); return null; }
java
protected Dispatchable getThreadContext() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getThreadContext"); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getThreadContext"); return null; }
[ "protected", "Dispatchable", "getThreadContext", "(", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "SibTr", ".", "entry", "(", "this", ",", "tc", ",", "\"getThreadContext\"", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "SibTr", ".", "exit", "(", "this", ",", "tc", ",", "\"getThreadContext\"", ")", ";", "return", "null", ";", "}" ]
Not needed for receive listener data invocations @return Returns null.
[ "Not", "needed", "for", "receive", "listener", "data", "invocations" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/jfapchannel/impl/rldispatcher/ReceiveListenerDataReceivedInvocation.java#L92-L98
train
OpenLiberty/open-liberty
dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/jfapchannel/impl/rldispatcher/ReceiveListenerDataReceivedInvocation.java
ReceiveListenerDataReceivedInvocation.invoke
protected synchronized void invoke() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "invoke"); try { // Pass details to implementor's conversation receive listener. if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) JFapUtils.debugTraceWsByteBuffer(this, tc, data, 16, "data passed to dataReceived method"); listener.dataReceived(data, segmentType, requestNumber, priority, allocatedFromPool, partOfExchange, conversation); } catch(Throwable t) { FFDCFilter.processException (t, "com.ibm.ws.sib.jfapchannel.impl.rldispatcher.ReceiveListenerDataReceivedInvocation", JFapChannelConstants.RLDATARECEIVEDINVOKE_INVOKE_01); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "exception thrown by dataReceived"); if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) SibTr.exception(this, tc, t); // User has thrown an exception from data received method. Probably // the best way to deal with this is to invalidate their connection. // That'll learn 'em. connection.invalidate(true, t, "exception thrown by dataReceived - "+t.getLocalizedMessage()); // D224570 } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "invoke"); }
java
protected synchronized void invoke() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "invoke"); try { // Pass details to implementor's conversation receive listener. if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) JFapUtils.debugTraceWsByteBuffer(this, tc, data, 16, "data passed to dataReceived method"); listener.dataReceived(data, segmentType, requestNumber, priority, allocatedFromPool, partOfExchange, conversation); } catch(Throwable t) { FFDCFilter.processException (t, "com.ibm.ws.sib.jfapchannel.impl.rldispatcher.ReceiveListenerDataReceivedInvocation", JFapChannelConstants.RLDATARECEIVEDINVOKE_INVOKE_01); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "exception thrown by dataReceived"); if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) SibTr.exception(this, tc, t); // User has thrown an exception from data received method. Probably // the best way to deal with this is to invalidate their connection. // That'll learn 'em. connection.invalidate(true, t, "exception thrown by dataReceived - "+t.getLocalizedMessage()); // D224570 } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "invoke"); }
[ "protected", "synchronized", "void", "invoke", "(", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "SibTr", ".", "entry", "(", "this", ",", "tc", ",", "\"invoke\"", ")", ";", "try", "{", "// Pass details to implementor's conversation receive listener.", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "JFapUtils", ".", "debugTraceWsByteBuffer", "(", "this", ",", "tc", ",", "data", ",", "16", ",", "\"data passed to dataReceived method\"", ")", ";", "listener", ".", "dataReceived", "(", "data", ",", "segmentType", ",", "requestNumber", ",", "priority", ",", "allocatedFromPool", ",", "partOfExchange", ",", "conversation", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "FFDCFilter", ".", "processException", "(", "t", ",", "\"com.ibm.ws.sib.jfapchannel.impl.rldispatcher.ReceiveListenerDataReceivedInvocation\"", ",", "JFapChannelConstants", ".", "RLDATARECEIVEDINVOKE_INVOKE_01", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "SibTr", ".", "debug", "(", "this", ",", "tc", ",", "\"exception thrown by dataReceived\"", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEventEnabled", "(", ")", ")", "SibTr", ".", "exception", "(", "this", ",", "tc", ",", "t", ")", ";", "// User has thrown an exception from data received method. Probably", "// the best way to deal with this is to invalidate their connection.", "// That'll learn 'em.", "connection", ".", "invalidate", "(", "true", ",", "t", ",", "\"exception thrown by dataReceived - \"", "+", "t", ".", "getLocalizedMessage", "(", ")", ")", ";", "// D224570", "}", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "SibTr", ".", "exit", "(", "this", ",", "tc", ",", "\"invoke\"", ")", ";", "}" ]
Invokes the dataReceived method. If the callback throws an exception than the connection associated with it is invalidated.
[ "Invokes", "the", "dataReceived", "method", ".", "If", "the", "callback", "throws", "an", "exception", "than", "the", "connection", "associated", "with", "it", "is", "invalidated", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/jfapchannel/impl/rldispatcher/ReceiveListenerDataReceivedInvocation.java#L105-L135
train
OpenLiberty/open-liberty
dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/jfapchannel/impl/rldispatcher/ReceiveListenerDataReceivedInvocation.java
ReceiveListenerDataReceivedInvocation.reset
protected synchronized void reset(Connection connection, ReceiveListener listener, WsByteBuffer data, int size, int segmentType, int requestNumber, int priority, boolean allocatedFromPool, boolean partOfExchange, Conversation conversation) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "reset", new Object[] { connection, listener, data, ""+size, ""+segmentType, ""+requestNumber, ""+priority, ""+allocatedFromPool, ""+partOfExchange, conversation }); this.connection = connection; this.listener = listener; this.data = data; this.size = size; this.segmentType = segmentType; this.requestNumber = requestNumber; this.priority = priority; this.allocatedFromPool = allocatedFromPool; this.partOfExchange = partOfExchange; this.conversation = conversation; setDispatchable(null); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "reset"); }
java
protected synchronized void reset(Connection connection, ReceiveListener listener, WsByteBuffer data, int size, int segmentType, int requestNumber, int priority, boolean allocatedFromPool, boolean partOfExchange, Conversation conversation) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "reset", new Object[] { connection, listener, data, ""+size, ""+segmentType, ""+requestNumber, ""+priority, ""+allocatedFromPool, ""+partOfExchange, conversation }); this.connection = connection; this.listener = listener; this.data = data; this.size = size; this.segmentType = segmentType; this.requestNumber = requestNumber; this.priority = priority; this.allocatedFromPool = allocatedFromPool; this.partOfExchange = partOfExchange; this.conversation = conversation; setDispatchable(null); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "reset"); }
[ "protected", "synchronized", "void", "reset", "(", "Connection", "connection", ",", "ReceiveListener", "listener", ",", "WsByteBuffer", "data", ",", "int", "size", ",", "int", "segmentType", ",", "int", "requestNumber", ",", "int", "priority", ",", "boolean", "allocatedFromPool", ",", "boolean", "partOfExchange", ",", "Conversation", "conversation", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "SibTr", ".", "entry", "(", "this", ",", "tc", ",", "\"reset\"", ",", "new", "Object", "[", "]", "{", "connection", ",", "listener", ",", "data", ",", "\"\"", "+", "size", ",", "\"\"", "+", "segmentType", ",", "\"\"", "+", "requestNumber", ",", "\"\"", "+", "priority", ",", "\"\"", "+", "allocatedFromPool", ",", "\"\"", "+", "partOfExchange", ",", "conversation", "}", ")", ";", "this", ".", "connection", "=", "connection", ";", "this", ".", "listener", "=", "listener", ";", "this", ".", "data", "=", "data", ";", "this", ".", "size", "=", "size", ";", "this", ".", "segmentType", "=", "segmentType", ";", "this", ".", "requestNumber", "=", "requestNumber", ";", "this", ".", "priority", "=", "priority", ";", "this", ".", "allocatedFromPool", "=", "allocatedFromPool", ";", "this", ".", "partOfExchange", "=", "partOfExchange", ";", "this", ".", "conversation", "=", "conversation", ";", "setDispatchable", "(", "null", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "SibTr", ".", "exit", "(", "this", ",", "tc", ",", "\"reset\"", ")", ";", "}" ]
Resets the state of this invocation object - used by the pooling code.
[ "Resets", "the", "state", "of", "this", "invocation", "object", "-", "used", "by", "the", "pooling", "code", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/jfapchannel/impl/rldispatcher/ReceiveListenerDataReceivedInvocation.java#L138-L177
train
OpenLiberty/open-liberty
dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/jfapchannel/impl/rldispatcher/ReceiveListenerDataReceivedInvocation.java
ReceiveListenerDataReceivedInvocation.repool
protected synchronized void repool() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "repool"); // begin F181705.5 connection = null; listener = null; data = null; conversation = null; // end F181705.5 owningPool.add(this); setDispatchable(null); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "repool"); }
java
protected synchronized void repool() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "repool"); // begin F181705.5 connection = null; listener = null; data = null; conversation = null; // end F181705.5 owningPool.add(this); setDispatchable(null); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "repool"); }
[ "protected", "synchronized", "void", "repool", "(", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "SibTr", ".", "entry", "(", "this", ",", "tc", ",", "\"repool\"", ")", ";", "// begin F181705.5", "connection", "=", "null", ";", "listener", "=", "null", ";", "data", "=", "null", ";", "conversation", "=", "null", ";", "// end F181705.5", "owningPool", ".", "add", "(", "this", ")", ";", "setDispatchable", "(", "null", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "SibTr", ".", "exit", "(", "this", ",", "tc", ",", "\"repool\"", ")", ";", "}" ]
Returns this object to its associated object pool.
[ "Returns", "this", "object", "to", "its", "associated", "object", "pool", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/jfapchannel/impl/rldispatcher/ReceiveListenerDataReceivedInvocation.java#L180-L194
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.openidconnect.clients.common/src/com/ibm/ws/security/openidconnect/clients/common/OidcClientUtil.java
OidcClientUtil.setCookieForRequestParameter
public static void setCookieForRequestParameter(HttpServletRequest request, HttpServletResponse response, String id, String state, boolean isHttpsRequest, ConvergedClientConfig clientCfg) { //OidcClientConfigImpl clientCfg = activatedOidcClientImpl.getOidcClientConfig(request, id); Map<String, String[]> map = request.getParameterMap(); // at least it gets state parameter JsonObject jsonObject = new JsonObject(); Set<Map.Entry<String, String[]>> entries = map.entrySet(); for (Map.Entry<String, String[]> entry : entries) { String key = entry.getKey(); if (Constants.ACCESS_TOKEN.equals(key) || Constants.ID_TOKEN.equals(key)) { continue; } String[] strs = entry.getValue(); if (strs != null && strs.length > 0) { jsonObject.addProperty(key, strs[0]); } } String requestParameters = jsonObject.toString(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "requestParameters:" + requestParameters); } String encodedReqParams = null; try { encodedReqParams = Base64Coder.toString(Base64Coder.base64Encode(requestParameters.getBytes(ClientConstants.CHARSET))); } catch (UnsupportedEncodingException e) { //This should not happen, we are using UTF-8 if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "get unexpected exception", e); } } String encodedHash = null; if (encodedReqParams != null) { encodedHash = calculateOidcCodeCookieValue(encodedReqParams, clientCfg); } Cookie c = OidcClientUtil.createCookie(ClientConstants.WAS_OIDC_CODE, encodedHash, request); if (clientCfg.isHttpsRequired() && isHttpsRequest) { c.setSecure(true); } response.addCookie(c); }
java
public static void setCookieForRequestParameter(HttpServletRequest request, HttpServletResponse response, String id, String state, boolean isHttpsRequest, ConvergedClientConfig clientCfg) { //OidcClientConfigImpl clientCfg = activatedOidcClientImpl.getOidcClientConfig(request, id); Map<String, String[]> map = request.getParameterMap(); // at least it gets state parameter JsonObject jsonObject = new JsonObject(); Set<Map.Entry<String, String[]>> entries = map.entrySet(); for (Map.Entry<String, String[]> entry : entries) { String key = entry.getKey(); if (Constants.ACCESS_TOKEN.equals(key) || Constants.ID_TOKEN.equals(key)) { continue; } String[] strs = entry.getValue(); if (strs != null && strs.length > 0) { jsonObject.addProperty(key, strs[0]); } } String requestParameters = jsonObject.toString(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "requestParameters:" + requestParameters); } String encodedReqParams = null; try { encodedReqParams = Base64Coder.toString(Base64Coder.base64Encode(requestParameters.getBytes(ClientConstants.CHARSET))); } catch (UnsupportedEncodingException e) { //This should not happen, we are using UTF-8 if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "get unexpected exception", e); } } String encodedHash = null; if (encodedReqParams != null) { encodedHash = calculateOidcCodeCookieValue(encodedReqParams, clientCfg); } Cookie c = OidcClientUtil.createCookie(ClientConstants.WAS_OIDC_CODE, encodedHash, request); if (clientCfg.isHttpsRequired() && isHttpsRequest) { c.setSecure(true); } response.addCookie(c); }
[ "public", "static", "void", "setCookieForRequestParameter", "(", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ",", "String", "id", ",", "String", "state", ",", "boolean", "isHttpsRequest", ",", "ConvergedClientConfig", "clientCfg", ")", "{", "//OidcClientConfigImpl clientCfg = activatedOidcClientImpl.getOidcClientConfig(request, id);", "Map", "<", "String", ",", "String", "[", "]", ">", "map", "=", "request", ".", "getParameterMap", "(", ")", ";", "// at least it gets state parameter", "JsonObject", "jsonObject", "=", "new", "JsonObject", "(", ")", ";", "Set", "<", "Map", ".", "Entry", "<", "String", ",", "String", "[", "]", ">", ">", "entries", "=", "map", ".", "entrySet", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", "[", "]", ">", "entry", ":", "entries", ")", "{", "String", "key", "=", "entry", ".", "getKey", "(", ")", ";", "if", "(", "Constants", ".", "ACCESS_TOKEN", ".", "equals", "(", "key", ")", "||", "Constants", ".", "ID_TOKEN", ".", "equals", "(", "key", ")", ")", "{", "continue", ";", "}", "String", "[", "]", "strs", "=", "entry", ".", "getValue", "(", ")", ";", "if", "(", "strs", "!=", "null", "&&", "strs", ".", "length", ">", "0", ")", "{", "jsonObject", ".", "addProperty", "(", "key", ",", "strs", "[", "0", "]", ")", ";", "}", "}", "String", "requestParameters", "=", "jsonObject", ".", "toString", "(", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "Tr", ".", "debug", "(", "tc", ",", "\"requestParameters:\"", "+", "requestParameters", ")", ";", "}", "String", "encodedReqParams", "=", "null", ";", "try", "{", "encodedReqParams", "=", "Base64Coder", ".", "toString", "(", "Base64Coder", ".", "base64Encode", "(", "requestParameters", ".", "getBytes", "(", "ClientConstants", ".", "CHARSET", ")", ")", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "//This should not happen, we are using UTF-8", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "Tr", ".", "debug", "(", "tc", ",", "\"get unexpected exception\"", ",", "e", ")", ";", "}", "}", "String", "encodedHash", "=", "null", ";", "if", "(", "encodedReqParams", "!=", "null", ")", "{", "encodedHash", "=", "calculateOidcCodeCookieValue", "(", "encodedReqParams", ",", "clientCfg", ")", ";", "}", "Cookie", "c", "=", "OidcClientUtil", ".", "createCookie", "(", "ClientConstants", ".", "WAS_OIDC_CODE", ",", "encodedHash", ",", "request", ")", ";", "if", "(", "clientCfg", ".", "isHttpsRequired", "(", ")", "&&", "isHttpsRequest", ")", "{", "c", ".", "setSecure", "(", "true", ")", ";", "}", "response", ".", "addCookie", "(", "c", ")", ";", "}" ]
set the code cookie during authentication
[ "set", "the", "code", "cookie", "during", "authentication" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.openidconnect.clients.common/src/com/ibm/ws/security/openidconnect/clients/common/OidcClientUtil.java#L382-L420
train
OpenLiberty/open-liberty
dev/com.ibm.ws.org.apache.cxf.cxf.rt.frontend.jaxrs.3.2/src/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
JAXRSUtils.getStructuredParams
public static MultivaluedMap<String, String> getStructuredParams(String query, String sep, boolean decode, boolean decodePlus) { MultivaluedMap<String, String> map = new MetadataMap<>(new LinkedHashMap<String, List<String>>()); getStructuredParams(map, query, sep, decode, decodePlus); return map; }
java
public static MultivaluedMap<String, String> getStructuredParams(String query, String sep, boolean decode, boolean decodePlus) { MultivaluedMap<String, String> map = new MetadataMap<>(new LinkedHashMap<String, List<String>>()); getStructuredParams(map, query, sep, decode, decodePlus); return map; }
[ "public", "static", "MultivaluedMap", "<", "String", ",", "String", ">", "getStructuredParams", "(", "String", "query", ",", "String", "sep", ",", "boolean", "decode", ",", "boolean", "decodePlus", ")", "{", "MultivaluedMap", "<", "String", ",", "String", ">", "map", "=", "new", "MetadataMap", "<>", "(", "new", "LinkedHashMap", "<", "String", ",", "List", "<", "String", ">", ">", "(", ")", ")", ";", "getStructuredParams", "(", "map", ",", "query", ",", "sep", ",", "decode", ",", "decodePlus", ")", ";", "return", "map", ";", "}" ]
Retrieve map of query parameters from the passed in message @param message @return a Map of query parameters.
[ "Retrieve", "map", "of", "query", "parameters", "from", "the", "passed", "in", "message" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.org.apache.cxf.cxf.rt.frontend.jaxrs.3.2/src/org/apache/cxf/jaxrs/utils/JAXRSUtils.java#L1285-L1294
train
OpenLiberty/open-liberty
dev/com.ibm.ws.org.apache.cxf.cxf.rt.frontend.jaxrs.3.2/src/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
JAXRSUtils.intersectMimeTypes
public static List<MediaType> intersectMimeTypes(List<MediaType> requiredMediaTypes, List<MediaType> userMediaTypes, boolean addRequiredParamsIfPossible) { return intersectMimeTypes(requiredMediaTypes, userMediaTypes, addRequiredParamsIfPossible, false); }
java
public static List<MediaType> intersectMimeTypes(List<MediaType> requiredMediaTypes, List<MediaType> userMediaTypes, boolean addRequiredParamsIfPossible) { return intersectMimeTypes(requiredMediaTypes, userMediaTypes, addRequiredParamsIfPossible, false); }
[ "public", "static", "List", "<", "MediaType", ">", "intersectMimeTypes", "(", "List", "<", "MediaType", ">", "requiredMediaTypes", ",", "List", "<", "MediaType", ">", "userMediaTypes", ",", "boolean", "addRequiredParamsIfPossible", ")", "{", "return", "intersectMimeTypes", "(", "requiredMediaTypes", ",", "userMediaTypes", ",", "addRequiredParamsIfPossible", ",", "false", ")", ";", "}" ]
intersect two mime types @param mimeTypesA @param mimeTypesB @return return a list of intersected mime types
[ "intersect", "two", "mime", "types" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.org.apache.cxf.cxf.rt.frontend.jaxrs.3.2/src/org/apache/cxf/jaxrs/utils/JAXRSUtils.java#L1543-L1547
train
OpenLiberty/open-liberty
dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java
MetricRegistryImpl.addNameToApplicationMap
protected void addNameToApplicationMap(String name) { String appName = getApplicationName(); // If it is a base metric, the name will be null if (appName == null) return; ConcurrentLinkedQueue<String> list = applicationMap.get(appName); if (list == null) { ConcurrentLinkedQueue<String> newList = new ConcurrentLinkedQueue<String>(); list = applicationMap.putIfAbsent(appName, newList); if (list == null) list = newList; } list.add(name); }
java
protected void addNameToApplicationMap(String name) { String appName = getApplicationName(); // If it is a base metric, the name will be null if (appName == null) return; ConcurrentLinkedQueue<String> list = applicationMap.get(appName); if (list == null) { ConcurrentLinkedQueue<String> newList = new ConcurrentLinkedQueue<String>(); list = applicationMap.putIfAbsent(appName, newList); if (list == null) list = newList; } list.add(name); }
[ "protected", "void", "addNameToApplicationMap", "(", "String", "name", ")", "{", "String", "appName", "=", "getApplicationName", "(", ")", ";", "// If it is a base metric, the name will be null", "if", "(", "appName", "==", "null", ")", "return", ";", "ConcurrentLinkedQueue", "<", "String", ">", "list", "=", "applicationMap", ".", "get", "(", "appName", ")", ";", "if", "(", "list", "==", "null", ")", "{", "ConcurrentLinkedQueue", "<", "String", ">", "newList", "=", "new", "ConcurrentLinkedQueue", "<", "String", ">", "(", ")", ";", "list", "=", "applicationMap", ".", "putIfAbsent", "(", "appName", ",", "newList", ")", ";", "if", "(", "list", "==", "null", ")", "list", "=", "newList", ";", "}", "list", ".", "add", "(", "name", ")", ";", "}" ]
Adds the metric name to an application map. This map is not a complete list of metrics owned by an application, produced metrics are managed in the MetricsExtension @param name
[ "Adds", "the", "metric", "name", "to", "an", "application", "map", ".", "This", "map", "is", "not", "a", "complete", "list", "of", "metrics", "owned", "by", "an", "application", "produced", "metrics", "are", "managed", "in", "the", "MetricsExtension" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java#L180-L194
train
OpenLiberty/open-liberty
dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java
MetricRegistryImpl.getNames
@Override public SortedSet<String> getNames() { return Collections.unmodifiableSortedSet(new TreeSet<String>(metrics.keySet())); }
java
@Override public SortedSet<String> getNames() { return Collections.unmodifiableSortedSet(new TreeSet<String>(metrics.keySet())); }
[ "@", "Override", "public", "SortedSet", "<", "String", ">", "getNames", "(", ")", "{", "return", "Collections", ".", "unmodifiableSortedSet", "(", "new", "TreeSet", "<", "String", ">", "(", "metrics", ".", "keySet", "(", ")", ")", ")", ";", "}" ]
Returns a set of the names of all the metrics in the registry. @return the names of all the metrics
[ "Returns", "a", "set", "of", "the", "names", "of", "all", "the", "metrics", "in", "the", "registry", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java#L319-L322
train
OpenLiberty/open-liberty
dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java
MetricRegistryImpl.getCounters
@Override public SortedMap<String, Counter> getCounters(MetricFilter filter) { return getMetrics(Counter.class, filter); }
java
@Override public SortedMap<String, Counter> getCounters(MetricFilter filter) { return getMetrics(Counter.class, filter); }
[ "@", "Override", "public", "SortedMap", "<", "String", ",", "Counter", ">", "getCounters", "(", "MetricFilter", "filter", ")", "{", "return", "getMetrics", "(", "Counter", ".", "class", ",", "filter", ")", ";", "}" ]
Returns a map of all the counters in the registry and their names which match the given filter. @param filter the metric filter to match @return all the counters in the registry
[ "Returns", "a", "map", "of", "all", "the", "counters", "in", "the", "registry", "and", "their", "names", "which", "match", "the", "given", "filter", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java#L362-L365
train
OpenLiberty/open-liberty
dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java
MetricRegistryImpl.getHistograms
@Override public SortedMap<String, Histogram> getHistograms(MetricFilter filter) { return getMetrics(Histogram.class, filter); }
java
@Override public SortedMap<String, Histogram> getHistograms(MetricFilter filter) { return getMetrics(Histogram.class, filter); }
[ "@", "Override", "public", "SortedMap", "<", "String", ",", "Histogram", ">", "getHistograms", "(", "MetricFilter", "filter", ")", "{", "return", "getMetrics", "(", "Histogram", ".", "class", ",", "filter", ")", ";", "}" ]
Returns a map of all the histograms in the registry and their names which match the given filter. @param filter the metric filter to match @return all the histograms in the registry
[ "Returns", "a", "map", "of", "all", "the", "histograms", "in", "the", "registry", "and", "their", "names", "which", "match", "the", "given", "filter", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java#L384-L387
train
OpenLiberty/open-liberty
dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java
MetricRegistryImpl.getMeters
@Override public SortedMap<String, Meter> getMeters(MetricFilter filter) { return getMetrics(Meter.class, filter); }
java
@Override public SortedMap<String, Meter> getMeters(MetricFilter filter) { return getMetrics(Meter.class, filter); }
[ "@", "Override", "public", "SortedMap", "<", "String", ",", "Meter", ">", "getMeters", "(", "MetricFilter", "filter", ")", "{", "return", "getMetrics", "(", "Meter", ".", "class", ",", "filter", ")", ";", "}" ]
Returns a map of all the meters in the registry and their names which match the given filter. @param filter the metric filter to match @return all the meters in the registry
[ "Returns", "a", "map", "of", "all", "the", "meters", "in", "the", "registry", "and", "their", "names", "which", "match", "the", "given", "filter", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java#L405-L408
train
OpenLiberty/open-liberty
dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java
MetricRegistryImpl.getTimers
@Override public SortedMap<String, Timer> getTimers(MetricFilter filter) { return getMetrics(Timer.class, filter); }
java
@Override public SortedMap<String, Timer> getTimers(MetricFilter filter) { return getMetrics(Timer.class, filter); }
[ "@", "Override", "public", "SortedMap", "<", "String", ",", "Timer", ">", "getTimers", "(", "MetricFilter", "filter", ")", "{", "return", "getMetrics", "(", "Timer", ".", "class", ",", "filter", ")", ";", "}" ]
Returns a map of all the timers in the registry and their names which match the given filter. @param filter the metric filter to match @return all the timers in the registry
[ "Returns", "a", "map", "of", "all", "the", "timers", "in", "the", "registry", "and", "their", "names", "which", "match", "the", "given", "filter", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java#L426-L429
train
OpenLiberty/open-liberty
dev/com.ibm.ws.channelfw/src/com/ibm/io/async/LookupTable.java
LookupTable.addElement
public synchronized int addElement(E theElement) { if (theElement == null) { return -1; } if (elementCount == currentCapacity) { // try to expand the table to handle the new value, if that fails // then it will throw an illegalstate exception expandTable(); } int theIndex = occupiedSlots.nextClearBit(0); if (theIndex < 0 || theIndex > currentCapacity - 1) { throw new IllegalStateException("No space available for element"); } theElementArray[theIndex] = theElement; elementCount++; occupiedSlots.set(theIndex); return theIndex; }
java
public synchronized int addElement(E theElement) { if (theElement == null) { return -1; } if (elementCount == currentCapacity) { // try to expand the table to handle the new value, if that fails // then it will throw an illegalstate exception expandTable(); } int theIndex = occupiedSlots.nextClearBit(0); if (theIndex < 0 || theIndex > currentCapacity - 1) { throw new IllegalStateException("No space available for element"); } theElementArray[theIndex] = theElement; elementCount++; occupiedSlots.set(theIndex); return theIndex; }
[ "public", "synchronized", "int", "addElement", "(", "E", "theElement", ")", "{", "if", "(", "theElement", "==", "null", ")", "{", "return", "-", "1", ";", "}", "if", "(", "elementCount", "==", "currentCapacity", ")", "{", "// try to expand the table to handle the new value, if that fails", "// then it will throw an illegalstate exception", "expandTable", "(", ")", ";", "}", "int", "theIndex", "=", "occupiedSlots", ".", "nextClearBit", "(", "0", ")", ";", "if", "(", "theIndex", "<", "0", "||", "theIndex", ">", "currentCapacity", "-", "1", ")", "{", "throw", "new", "IllegalStateException", "(", "\"No space available for element\"", ")", ";", "}", "theElementArray", "[", "theIndex", "]", "=", "theElement", ";", "elementCount", "++", ";", "occupiedSlots", ".", "set", "(", "theIndex", ")", ";", "return", "theIndex", ";", "}" ]
Add an element to the LookupTable. Returns the index value which can be used to look up the element in the LookupTable. @param theElement the object to add to the LookupTable. Should not be null. @return an int holding the Index value which points to the object in the LookupTable. -1 if theElement is null.
[ "Add", "an", "element", "to", "the", "LookupTable", ".", "Returns", "the", "index", "value", "which", "can", "be", "used", "to", "look", "up", "the", "element", "in", "the", "LookupTable", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/io/async/LookupTable.java#L124-L141
train
OpenLiberty/open-liberty
dev/com.ibm.ws.channelfw/src/com/ibm/io/async/LookupTable.java
LookupTable.removeElement
public synchronized Object removeElement(int theIndex) { if (theIndex < 0 || theIndex > currentCapacity - 1) { throw new IllegalArgumentException("Index is out of range."); } Object theElement = theElementArray[theIndex]; if (theElement != null) { theElementArray[theIndex] = null; elementCount--; occupiedSlots.clear(theIndex); } return theElement; }
java
public synchronized Object removeElement(int theIndex) { if (theIndex < 0 || theIndex > currentCapacity - 1) { throw new IllegalArgumentException("Index is out of range."); } Object theElement = theElementArray[theIndex]; if (theElement != null) { theElementArray[theIndex] = null; elementCount--; occupiedSlots.clear(theIndex); } return theElement; }
[ "public", "synchronized", "Object", "removeElement", "(", "int", "theIndex", ")", "{", "if", "(", "theIndex", "<", "0", "||", "theIndex", ">", "currentCapacity", "-", "1", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Index is out of range.\"", ")", ";", "}", "Object", "theElement", "=", "theElementArray", "[", "theIndex", "]", ";", "if", "(", "theElement", "!=", "null", ")", "{", "theElementArray", "[", "theIndex", "]", "=", "null", ";", "elementCount", "--", ";", "occupiedSlots", ".", "clear", "(", "theIndex", ")", ";", "}", "return", "theElement", ";", "}" ]
Remove the object from the LookupTable which is referenced by the supplied Index value. @param theIndex an int containing the index value of the element to remove from the LookupTable @return the Object which was removed from the LookupTable - null if no object was removed.
[ "Remove", "the", "object", "from", "the", "LookupTable", "which", "is", "referenced", "by", "the", "supplied", "Index", "value", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/io/async/LookupTable.java#L153-L164
train
OpenLiberty/open-liberty
dev/com.ibm.ws.channelfw/src/com/ibm/io/async/LookupTable.java
LookupTable.findElement
public int findElement(Object element) { for (int i = 0; i < currentCapacity; i++) { if (element == theElementArray[i]) { return i; } } return -1; }
java
public int findElement(Object element) { for (int i = 0; i < currentCapacity; i++) { if (element == theElementArray[i]) { return i; } } return -1; }
[ "public", "int", "findElement", "(", "Object", "element", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "currentCapacity", ";", "i", "++", ")", "{", "if", "(", "element", "==", "theElementArray", "[", "i", "]", ")", "{", "return", "i", ";", "}", "}", "return", "-", "1", ";", "}" ]
Finds a supplied object in the LookupTable and returns its index. @param element the object to find in the LookupTable. This is a SLOW operation as it scans the whole table. @return the Index of the Object in the LookupTable. -1 if the object is not in the LookupTable.
[ "Finds", "a", "supplied", "object", "in", "the", "LookupTable", "and", "returns", "its", "index", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/io/async/LookupTable.java#L175-L183
train
OpenLiberty/open-liberty
dev/com.ibm.ws.channelfw/src/com/ibm/io/async/LookupTable.java
LookupTable.expandTable
@SuppressWarnings("unchecked") private void expandTable() { int newCapacity = currentCapacity + increment; if (newCapacity < currentCapacity) { throw new IllegalStateException( "Attempt to expand LookupTable beyond maximum capacity"); } E[] theNewArray = (E[]) new Object[newCapacity]; System.arraycopy(this.theElementArray, 0, theNewArray, 0, currentCapacity); theElementArray = theNewArray; currentCapacity = newCapacity; }
java
@SuppressWarnings("unchecked") private void expandTable() { int newCapacity = currentCapacity + increment; if (newCapacity < currentCapacity) { throw new IllegalStateException( "Attempt to expand LookupTable beyond maximum capacity"); } E[] theNewArray = (E[]) new Object[newCapacity]; System.arraycopy(this.theElementArray, 0, theNewArray, 0, currentCapacity); theElementArray = theNewArray; currentCapacity = newCapacity; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "expandTable", "(", ")", "{", "int", "newCapacity", "=", "currentCapacity", "+", "increment", ";", "if", "(", "newCapacity", "<", "currentCapacity", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Attempt to expand LookupTable beyond maximum capacity\"", ")", ";", "}", "E", "[", "]", "theNewArray", "=", "(", "E", "[", "]", ")", "new", "Object", "[", "newCapacity", "]", ";", "System", ".", "arraycopy", "(", "this", ".", "theElementArray", ",", "0", ",", "theNewArray", ",", "0", ",", "currentCapacity", ")", ";", "theElementArray", "=", "theNewArray", ";", "currentCapacity", "=", "newCapacity", ";", "}" ]
Expands the lookup table to accommodate more elements. Does this by adding the expansion increment to the current capacity.
[ "Expands", "the", "lookup", "table", "to", "accommodate", "more", "elements", ".", "Does", "this", "by", "adding", "the", "expansion", "increment", "to", "the", "current", "capacity", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/io/async/LookupTable.java#L205-L216
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.initialize
public void initialize(Map<String, Object> configProps) throws WIMException { reposId = (String) configProps.get(KEY_ID); reposRealm = (String) configProps.get(REALM); if (String.valueOf(configProps.get(ConfigConstants.CONFIG_PROP_SUPPORT_CHANGE_LOG)).equalsIgnoreCase(ConfigConstants.CONFIG_SUPPORT_CHANGE_LOG_NATIVE)) { //Construct a change handler depending on the type of LDAP repository changeHandler = ChangeHandlerFactory.getChangeHandler(iLdapConn); } iLdapConfigMgr = new LdapConfigManager(); iLdapConfigMgr.initialize(configProps); iLdapConn = new LdapConnection(iLdapConfigMgr); iLdapConn.initialize(configProps); isActiveDirectory = iLdapConfigMgr.isActiveDirectory(); }
java
public void initialize(Map<String, Object> configProps) throws WIMException { reposId = (String) configProps.get(KEY_ID); reposRealm = (String) configProps.get(REALM); if (String.valueOf(configProps.get(ConfigConstants.CONFIG_PROP_SUPPORT_CHANGE_LOG)).equalsIgnoreCase(ConfigConstants.CONFIG_SUPPORT_CHANGE_LOG_NATIVE)) { //Construct a change handler depending on the type of LDAP repository changeHandler = ChangeHandlerFactory.getChangeHandler(iLdapConn); } iLdapConfigMgr = new LdapConfigManager(); iLdapConfigMgr.initialize(configProps); iLdapConn = new LdapConnection(iLdapConfigMgr); iLdapConn.initialize(configProps); isActiveDirectory = iLdapConfigMgr.isActiveDirectory(); }
[ "public", "void", "initialize", "(", "Map", "<", "String", ",", "Object", ">", "configProps", ")", "throws", "WIMException", "{", "reposId", "=", "(", "String", ")", "configProps", ".", "get", "(", "KEY_ID", ")", ";", "reposRealm", "=", "(", "String", ")", "configProps", ".", "get", "(", "REALM", ")", ";", "if", "(", "String", ".", "valueOf", "(", "configProps", ".", "get", "(", "ConfigConstants", ".", "CONFIG_PROP_SUPPORT_CHANGE_LOG", ")", ")", ".", "equalsIgnoreCase", "(", "ConfigConstants", ".", "CONFIG_SUPPORT_CHANGE_LOG_NATIVE", ")", ")", "{", "//Construct a change handler depending on the type of LDAP repository", "changeHandler", "=", "ChangeHandlerFactory", ".", "getChangeHandler", "(", "iLdapConn", ")", ";", "}", "iLdapConfigMgr", "=", "new", "LdapConfigManager", "(", ")", ";", "iLdapConfigMgr", ".", "initialize", "(", "configProps", ")", ";", "iLdapConn", "=", "new", "LdapConnection", "(", "iLdapConfigMgr", ")", ";", "iLdapConn", ".", "initialize", "(", "configProps", ")", ";", "isActiveDirectory", "=", "iLdapConfigMgr", ".", "isActiveDirectory", "(", ")", ";", "}" ]
Function that is invoked when the LdapAdapter is initialized. It extracts the repository configuration details and sets itself up with the required properties. @param configProps
[ "Function", "that", "is", "invoked", "when", "the", "LdapAdapter", "is", "initialized", ".", "It", "extracts", "the", "repository", "configuration", "details", "and", "sets", "itself", "up", "with", "the", "required", "properties", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L234-L250
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.getCallerUniqueName
private String getCallerUniqueName() throws WIMApplicationException { String uniqueName = null; Subject subject = null; WSCredential cred = null; try { /* Get the subject */ if ((subject = WSSubject.getRunAsSubject()) == null) { subject = WSSubject.getCallerSubject(); } /* Get the credential */ if (subject != null) { Iterator<WSCredential> iter = subject.getPublicCredentials(WSCredential.class).iterator(); if (iter.hasNext()) { cred = iter.next(); } } /* Get the unique name */ if (cred == null) return null; else uniqueName = cred.getUniqueSecurityName(); } //throw exception in case there is some issue while retrieving authentication details from subject catch (Exception excp) { excp.getMessage(); return null; } //return unique name obtained from subject return uniqueName; }
java
private String getCallerUniqueName() throws WIMApplicationException { String uniqueName = null; Subject subject = null; WSCredential cred = null; try { /* Get the subject */ if ((subject = WSSubject.getRunAsSubject()) == null) { subject = WSSubject.getCallerSubject(); } /* Get the credential */ if (subject != null) { Iterator<WSCredential> iter = subject.getPublicCredentials(WSCredential.class).iterator(); if (iter.hasNext()) { cred = iter.next(); } } /* Get the unique name */ if (cred == null) return null; else uniqueName = cred.getUniqueSecurityName(); } //throw exception in case there is some issue while retrieving authentication details from subject catch (Exception excp) { excp.getMessage(); return null; } //return unique name obtained from subject return uniqueName; }
[ "private", "String", "getCallerUniqueName", "(", ")", "throws", "WIMApplicationException", "{", "String", "uniqueName", "=", "null", ";", "Subject", "subject", "=", "null", ";", "WSCredential", "cred", "=", "null", ";", "try", "{", "/* Get the subject */", "if", "(", "(", "subject", "=", "WSSubject", ".", "getRunAsSubject", "(", ")", ")", "==", "null", ")", "{", "subject", "=", "WSSubject", ".", "getCallerSubject", "(", ")", ";", "}", "/* Get the credential */", "if", "(", "subject", "!=", "null", ")", "{", "Iterator", "<", "WSCredential", ">", "iter", "=", "subject", ".", "getPublicCredentials", "(", "WSCredential", ".", "class", ")", ".", "iterator", "(", ")", ";", "if", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "cred", "=", "iter", ".", "next", "(", ")", ";", "}", "}", "/* Get the unique name */", "if", "(", "cred", "==", "null", ")", "return", "null", ";", "else", "uniqueName", "=", "cred", ".", "getUniqueSecurityName", "(", ")", ";", "}", "//throw exception in case there is some issue while retrieving authentication details from subject", "catch", "(", "Exception", "excp", ")", "{", "excp", ".", "getMessage", "(", ")", ";", "return", "null", ";", "}", "//return unique name obtained from subject", "return", "uniqueName", ";", "}" ]
Helper function returns the caller's unique name. Created to use for logging the calls to clear cache with clearAll mode. @return Caller's principalName @throws WIMApplicationException
[ "Helper", "function", "returns", "the", "caller", "s", "unique", "name", ".", "Created", "to", "use", "for", "logging", "the", "calls", "to", "clear", "cache", "with", "clearAll", "mode", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L865-L897
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.createEntityFromLdapEntry
private Entity createEntityFromLdapEntry(Object parentDO, String propName, LdapEntry ldapEntry, List<String> propNames) throws WIMException { final String METHODNAME = "createEntityFromLdapEntry"; String outEntityType = ldapEntry.getType(); Entity outEntity = null; // For changed entities, when change type is delete, it is possible that // the type of entity (which maps to the LDAP entry's objectclass is not // available. if (outEntityType != null) { if (outEntityType.equalsIgnoreCase(SchemaConstants.DO_PERSON)) outEntity = new Person(); else if (outEntityType.equalsIgnoreCase(SchemaConstants.DO_PERSON_ACCOUNT)) outEntity = new PersonAccount(); else if (outEntityType.equalsIgnoreCase(SchemaConstants.DO_GROUP)) outEntity = new Group(); else outEntity = new Entity(); } else { outEntity = new Entity(); } if (parentDO instanceof Root) { if (SchemaConstants.DO_ENTITIES.equalsIgnoreCase(propName)) ((Root) parentDO).getEntities().add(outEntity); } else if (parentDO instanceof Entity) { if (SchemaConstants.DO_GROUP.equalsIgnoreCase(propName)) { /* * May get back plain entities if objectclass for group entity and * group filters don't match up identically. */ if (outEntity instanceof Group) { ((Entity) parentDO).getGroups().add((Group) outEntity); } else { if (tc.isDebugEnabled()) { Tr.debug(tc, METHODNAME + " Expected group entity. Group will excluded from group membership. Entity is " + outEntity, ldapEntry); } } } else if (SchemaConstants.DO_MEMBERS.equalsIgnoreCase(propName)) { ((Group) parentDO).getMembers().add(outEntity); } else if (SchemaConstants.DO_CHILDREN.equalsIgnoreCase(propName)) { ((Entity) parentDO).getChildren().add(outEntity); } } IdentifierType outId = new IdentifierType(); outEntity.setIdentifier(outId); outId.setUniqueName(ldapEntry.getUniqueName()); outId.setExternalId(ldapEntry.getExtId()); outId.setExternalName(ldapEntry.getDN()); outId.setRepositoryId(reposId); String changeType = ldapEntry.getChangeType(); if (changeType != null) { outEntity.setChangeType(changeType); if (SchemaConstants.CHANGETYPE_DELETE.equals(changeType) == false) { populateEntity(outEntity, propNames, ldapEntry.getAttributes()); } } else { populateEntity(outEntity, propNames, ldapEntry.getAttributes()); } return outEntity; }
java
private Entity createEntityFromLdapEntry(Object parentDO, String propName, LdapEntry ldapEntry, List<String> propNames) throws WIMException { final String METHODNAME = "createEntityFromLdapEntry"; String outEntityType = ldapEntry.getType(); Entity outEntity = null; // For changed entities, when change type is delete, it is possible that // the type of entity (which maps to the LDAP entry's objectclass is not // available. if (outEntityType != null) { if (outEntityType.equalsIgnoreCase(SchemaConstants.DO_PERSON)) outEntity = new Person(); else if (outEntityType.equalsIgnoreCase(SchemaConstants.DO_PERSON_ACCOUNT)) outEntity = new PersonAccount(); else if (outEntityType.equalsIgnoreCase(SchemaConstants.DO_GROUP)) outEntity = new Group(); else outEntity = new Entity(); } else { outEntity = new Entity(); } if (parentDO instanceof Root) { if (SchemaConstants.DO_ENTITIES.equalsIgnoreCase(propName)) ((Root) parentDO).getEntities().add(outEntity); } else if (parentDO instanceof Entity) { if (SchemaConstants.DO_GROUP.equalsIgnoreCase(propName)) { /* * May get back plain entities if objectclass for group entity and * group filters don't match up identically. */ if (outEntity instanceof Group) { ((Entity) parentDO).getGroups().add((Group) outEntity); } else { if (tc.isDebugEnabled()) { Tr.debug(tc, METHODNAME + " Expected group entity. Group will excluded from group membership. Entity is " + outEntity, ldapEntry); } } } else if (SchemaConstants.DO_MEMBERS.equalsIgnoreCase(propName)) { ((Group) parentDO).getMembers().add(outEntity); } else if (SchemaConstants.DO_CHILDREN.equalsIgnoreCase(propName)) { ((Entity) parentDO).getChildren().add(outEntity); } } IdentifierType outId = new IdentifierType(); outEntity.setIdentifier(outId); outId.setUniqueName(ldapEntry.getUniqueName()); outId.setExternalId(ldapEntry.getExtId()); outId.setExternalName(ldapEntry.getDN()); outId.setRepositoryId(reposId); String changeType = ldapEntry.getChangeType(); if (changeType != null) { outEntity.setChangeType(changeType); if (SchemaConstants.CHANGETYPE_DELETE.equals(changeType) == false) { populateEntity(outEntity, propNames, ldapEntry.getAttributes()); } } else { populateEntity(outEntity, propNames, ldapEntry.getAttributes()); } return outEntity; }
[ "private", "Entity", "createEntityFromLdapEntry", "(", "Object", "parentDO", ",", "String", "propName", ",", "LdapEntry", "ldapEntry", ",", "List", "<", "String", ">", "propNames", ")", "throws", "WIMException", "{", "final", "String", "METHODNAME", "=", "\"createEntityFromLdapEntry\"", ";", "String", "outEntityType", "=", "ldapEntry", ".", "getType", "(", ")", ";", "Entity", "outEntity", "=", "null", ";", "// For changed entities, when change type is delete, it is possible that", "// the type of entity (which maps to the LDAP entry's objectclass is not", "// available.", "if", "(", "outEntityType", "!=", "null", ")", "{", "if", "(", "outEntityType", ".", "equalsIgnoreCase", "(", "SchemaConstants", ".", "DO_PERSON", ")", ")", "outEntity", "=", "new", "Person", "(", ")", ";", "else", "if", "(", "outEntityType", ".", "equalsIgnoreCase", "(", "SchemaConstants", ".", "DO_PERSON_ACCOUNT", ")", ")", "outEntity", "=", "new", "PersonAccount", "(", ")", ";", "else", "if", "(", "outEntityType", ".", "equalsIgnoreCase", "(", "SchemaConstants", ".", "DO_GROUP", ")", ")", "outEntity", "=", "new", "Group", "(", ")", ";", "else", "outEntity", "=", "new", "Entity", "(", ")", ";", "}", "else", "{", "outEntity", "=", "new", "Entity", "(", ")", ";", "}", "if", "(", "parentDO", "instanceof", "Root", ")", "{", "if", "(", "SchemaConstants", ".", "DO_ENTITIES", ".", "equalsIgnoreCase", "(", "propName", ")", ")", "(", "(", "Root", ")", "parentDO", ")", ".", "getEntities", "(", ")", ".", "add", "(", "outEntity", ")", ";", "}", "else", "if", "(", "parentDO", "instanceof", "Entity", ")", "{", "if", "(", "SchemaConstants", ".", "DO_GROUP", ".", "equalsIgnoreCase", "(", "propName", ")", ")", "{", "/*\n * May get back plain entities if objectclass for group entity and\n * group filters don't match up identically.\n */", "if", "(", "outEntity", "instanceof", "Group", ")", "{", "(", "(", "Entity", ")", "parentDO", ")", ".", "getGroups", "(", ")", ".", "add", "(", "(", "Group", ")", "outEntity", ")", ";", "}", "else", "{", "if", "(", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "Tr", ".", "debug", "(", "tc", ",", "METHODNAME", "+", "\" Expected group entity. Group will excluded from group membership. Entity is \"", "+", "outEntity", ",", "ldapEntry", ")", ";", "}", "}", "}", "else", "if", "(", "SchemaConstants", ".", "DO_MEMBERS", ".", "equalsIgnoreCase", "(", "propName", ")", ")", "{", "(", "(", "Group", ")", "parentDO", ")", ".", "getMembers", "(", ")", ".", "add", "(", "outEntity", ")", ";", "}", "else", "if", "(", "SchemaConstants", ".", "DO_CHILDREN", ".", "equalsIgnoreCase", "(", "propName", ")", ")", "{", "(", "(", "Entity", ")", "parentDO", ")", ".", "getChildren", "(", ")", ".", "add", "(", "outEntity", ")", ";", "}", "}", "IdentifierType", "outId", "=", "new", "IdentifierType", "(", ")", ";", "outEntity", ".", "setIdentifier", "(", "outId", ")", ";", "outId", ".", "setUniqueName", "(", "ldapEntry", ".", "getUniqueName", "(", ")", ")", ";", "outId", ".", "setExternalId", "(", "ldapEntry", ".", "getExtId", "(", ")", ")", ";", "outId", ".", "setExternalName", "(", "ldapEntry", ".", "getDN", "(", ")", ")", ";", "outId", ".", "setRepositoryId", "(", "reposId", ")", ";", "String", "changeType", "=", "ldapEntry", ".", "getChangeType", "(", ")", ";", "if", "(", "changeType", "!=", "null", ")", "{", "outEntity", ".", "setChangeType", "(", "changeType", ")", ";", "if", "(", "SchemaConstants", ".", "CHANGETYPE_DELETE", ".", "equals", "(", "changeType", ")", "==", "false", ")", "{", "populateEntity", "(", "outEntity", ",", "propNames", ",", "ldapEntry", ".", "getAttributes", "(", ")", ")", ";", "}", "}", "else", "{", "populateEntity", "(", "outEntity", ",", "propNames", ",", "ldapEntry", ".", "getAttributes", "(", ")", ")", ";", "}", "return", "outEntity", ";", "}" ]
Create an Entity object corresponding to the LdapEntry object returned by the LdapConnection object. @param parentDO @param propName @param ldapEntry @param propNames @return @throws WIMException
[ "Create", "an", "Entity", "object", "corresponding", "to", "the", "LdapEntry", "object", "returned", "by", "the", "LdapConnection", "object", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L909-L970
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.getString
@Trivial private String getString(boolean isOctet, Object ldapValue) { if (isOctet) { return LdapHelper.getOctetString((byte[]) ldapValue); } else { return ldapValue.toString(); } }
java
@Trivial private String getString(boolean isOctet, Object ldapValue) { if (isOctet) { return LdapHelper.getOctetString((byte[]) ldapValue); } else { return ldapValue.toString(); } }
[ "@", "Trivial", "private", "String", "getString", "(", "boolean", "isOctet", ",", "Object", "ldapValue", ")", "{", "if", "(", "isOctet", ")", "{", "return", "LdapHelper", ".", "getOctetString", "(", "(", "byte", "[", "]", ")", "ldapValue", ")", ";", "}", "else", "{", "return", "ldapValue", ".", "toString", "(", ")", ";", "}", "}" ]
Convert the value into an appropriate string value. @param isOctet @param ldapValue @return
[ "Convert", "the", "value", "into", "an", "appropriate", "string", "value", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L1082-L1089
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.getDateString
private String getDateString(Object ldapValue) throws WIMSystemException { return String.valueOf(getDateString(ldapValue, false)); }
java
private String getDateString(Object ldapValue) throws WIMSystemException { return String.valueOf(getDateString(ldapValue, false)); }
[ "private", "String", "getDateString", "(", "Object", "ldapValue", ")", "throws", "WIMSystemException", "{", "return", "String", ".", "valueOf", "(", "getDateString", "(", "ldapValue", ",", "false", ")", ")", ";", "}" ]
Convert the value into an appropriate date string value. @param ldapValue @return
[ "Convert", "the", "value", "into", "an", "appropriate", "date", "string", "value", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L1097-L1099
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.createIdentiferFromLdapEntry
@Trivial private IdentifierType createIdentiferFromLdapEntry(LdapEntry ldapEntry) throws WIMException { IdentifierType outId = new IdentifierType(); outId.setUniqueName(ldapEntry.getUniqueName()); outId.setExternalId(ldapEntry.getExtId()); outId.setExternalName(ldapEntry.getDN()); outId.setRepositoryId(reposId); return outId; }
java
@Trivial private IdentifierType createIdentiferFromLdapEntry(LdapEntry ldapEntry) throws WIMException { IdentifierType outId = new IdentifierType(); outId.setUniqueName(ldapEntry.getUniqueName()); outId.setExternalId(ldapEntry.getExtId()); outId.setExternalName(ldapEntry.getDN()); outId.setRepositoryId(reposId); return outId; }
[ "@", "Trivial", "private", "IdentifierType", "createIdentiferFromLdapEntry", "(", "LdapEntry", "ldapEntry", ")", "throws", "WIMException", "{", "IdentifierType", "outId", "=", "new", "IdentifierType", "(", ")", ";", "outId", ".", "setUniqueName", "(", "ldapEntry", ".", "getUniqueName", "(", ")", ")", ";", "outId", ".", "setExternalId", "(", "ldapEntry", ".", "getExtId", "(", ")", ")", ";", "outId", ".", "setExternalName", "(", "ldapEntry", ".", "getDN", "(", ")", ")", ";", "outId", ".", "setRepositoryId", "(", "reposId", ")", ";", "return", "outId", ";", "}" ]
Create an IdentifierType object for the LdapEntry. @param ldapEntry @return @throws WIMException
[ "Create", "an", "IdentifierType", "object", "for", "the", "LdapEntry", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L1188-L1196
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.setPropertyValue
@SuppressWarnings("unchecked") private void setPropertyValue(Entity entity, Attribute attr, String propName, LdapAttribute ldapAttr) throws WIMException { String dataType = entity.getDataType(propName); boolean isMany = entity.isMultiValuedProperty(propName); String syntax = LDAP_ATTR_SYNTAX_STRING; if (ldapAttr != null) { syntax = ldapAttr.getSyntax(); if (tc.isEventEnabled()) { Tr.event(tc, "ldapAttr " + ldapAttr + " syntax is " + syntax); } } try { if (isMany) { for (NamingEnumeration<?> enu = attr.getAll(); enu.hasMoreElements();) { Object ldapValue = enu.nextElement(); if (ldapValue != null) { entity.set(propName, processPropertyValue(entity, propName, dataType, syntax, ldapValue)); } } } else { Object ldapValue = attr.get(); if (ldapValue != null) { entity.set(propName, processPropertyValue(entity, propName, dataType, syntax, ldapValue)); } } } catch (NamingException e) { if (tc.isEventEnabled()) { Tr.event(tc, "Unexpected on " + propName + " with dataType " + dataType, e); } String msg = Tr.formatMessage(tc, WIMMessageKey.NAMING_EXCEPTION, WIMMessageHelper.generateMsgParms(e.toString(true))); throw new WIMSystemException(WIMMessageKey.NAMING_EXCEPTION, msg, e); } catch (ClassCastException ce) { if (tc.isEventEnabled()) { Tr.event(tc, "Failed to cast property " + propName + " to " + dataType, ce); } if (tc.isErrorEnabled()) Tr.error(tc, WIMMessageKey.INVALID_PROPERTY_DATA_TYPE, WIMMessageHelper.generateMsgParms(propName)); } catch (ArrayStoreException ae) { if (tc.isEventEnabled()) { Tr.event(tc, "Unexpected on " + propName + " with dataType " + dataType, ae); } if (tc.isErrorEnabled()) Tr.error(tc, WIMMessageKey.INVALID_PROPERTY_DATA_TYPE, WIMMessageHelper.generateMsgParms(propName)); } }
java
@SuppressWarnings("unchecked") private void setPropertyValue(Entity entity, Attribute attr, String propName, LdapAttribute ldapAttr) throws WIMException { String dataType = entity.getDataType(propName); boolean isMany = entity.isMultiValuedProperty(propName); String syntax = LDAP_ATTR_SYNTAX_STRING; if (ldapAttr != null) { syntax = ldapAttr.getSyntax(); if (tc.isEventEnabled()) { Tr.event(tc, "ldapAttr " + ldapAttr + " syntax is " + syntax); } } try { if (isMany) { for (NamingEnumeration<?> enu = attr.getAll(); enu.hasMoreElements();) { Object ldapValue = enu.nextElement(); if (ldapValue != null) { entity.set(propName, processPropertyValue(entity, propName, dataType, syntax, ldapValue)); } } } else { Object ldapValue = attr.get(); if (ldapValue != null) { entity.set(propName, processPropertyValue(entity, propName, dataType, syntax, ldapValue)); } } } catch (NamingException e) { if (tc.isEventEnabled()) { Tr.event(tc, "Unexpected on " + propName + " with dataType " + dataType, e); } String msg = Tr.formatMessage(tc, WIMMessageKey.NAMING_EXCEPTION, WIMMessageHelper.generateMsgParms(e.toString(true))); throw new WIMSystemException(WIMMessageKey.NAMING_EXCEPTION, msg, e); } catch (ClassCastException ce) { if (tc.isEventEnabled()) { Tr.event(tc, "Failed to cast property " + propName + " to " + dataType, ce); } if (tc.isErrorEnabled()) Tr.error(tc, WIMMessageKey.INVALID_PROPERTY_DATA_TYPE, WIMMessageHelper.generateMsgParms(propName)); } catch (ArrayStoreException ae) { if (tc.isEventEnabled()) { Tr.event(tc, "Unexpected on " + propName + " with dataType " + dataType, ae); } if (tc.isErrorEnabled()) Tr.error(tc, WIMMessageKey.INVALID_PROPERTY_DATA_TYPE, WIMMessageHelper.generateMsgParms(propName)); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "setPropertyValue", "(", "Entity", "entity", ",", "Attribute", "attr", ",", "String", "propName", ",", "LdapAttribute", "ldapAttr", ")", "throws", "WIMException", "{", "String", "dataType", "=", "entity", ".", "getDataType", "(", "propName", ")", ";", "boolean", "isMany", "=", "entity", ".", "isMultiValuedProperty", "(", "propName", ")", ";", "String", "syntax", "=", "LDAP_ATTR_SYNTAX_STRING", ";", "if", "(", "ldapAttr", "!=", "null", ")", "{", "syntax", "=", "ldapAttr", ".", "getSyntax", "(", ")", ";", "if", "(", "tc", ".", "isEventEnabled", "(", ")", ")", "{", "Tr", ".", "event", "(", "tc", ",", "\"ldapAttr \"", "+", "ldapAttr", "+", "\" syntax is \"", "+", "syntax", ")", ";", "}", "}", "try", "{", "if", "(", "isMany", ")", "{", "for", "(", "NamingEnumeration", "<", "?", ">", "enu", "=", "attr", ".", "getAll", "(", ")", ";", "enu", ".", "hasMoreElements", "(", ")", ";", ")", "{", "Object", "ldapValue", "=", "enu", ".", "nextElement", "(", ")", ";", "if", "(", "ldapValue", "!=", "null", ")", "{", "entity", ".", "set", "(", "propName", ",", "processPropertyValue", "(", "entity", ",", "propName", ",", "dataType", ",", "syntax", ",", "ldapValue", ")", ")", ";", "}", "}", "}", "else", "{", "Object", "ldapValue", "=", "attr", ".", "get", "(", ")", ";", "if", "(", "ldapValue", "!=", "null", ")", "{", "entity", ".", "set", "(", "propName", ",", "processPropertyValue", "(", "entity", ",", "propName", ",", "dataType", ",", "syntax", ",", "ldapValue", ")", ")", ";", "}", "}", "}", "catch", "(", "NamingException", "e", ")", "{", "if", "(", "tc", ".", "isEventEnabled", "(", ")", ")", "{", "Tr", ".", "event", "(", "tc", ",", "\"Unexpected on \"", "+", "propName", "+", "\" with dataType \"", "+", "dataType", ",", "e", ")", ";", "}", "String", "msg", "=", "Tr", ".", "formatMessage", "(", "tc", ",", "WIMMessageKey", ".", "NAMING_EXCEPTION", ",", "WIMMessageHelper", ".", "generateMsgParms", "(", "e", ".", "toString", "(", "true", ")", ")", ")", ";", "throw", "new", "WIMSystemException", "(", "WIMMessageKey", ".", "NAMING_EXCEPTION", ",", "msg", ",", "e", ")", ";", "}", "catch", "(", "ClassCastException", "ce", ")", "{", "if", "(", "tc", ".", "isEventEnabled", "(", ")", ")", "{", "Tr", ".", "event", "(", "tc", ",", "\"Failed to cast property \"", "+", "propName", "+", "\" to \"", "+", "dataType", ",", "ce", ")", ";", "}", "if", "(", "tc", ".", "isErrorEnabled", "(", ")", ")", "Tr", ".", "error", "(", "tc", ",", "WIMMessageKey", ".", "INVALID_PROPERTY_DATA_TYPE", ",", "WIMMessageHelper", ".", "generateMsgParms", "(", "propName", ")", ")", ";", "}", "catch", "(", "ArrayStoreException", "ae", ")", "{", "if", "(", "tc", ".", "isEventEnabled", "(", ")", ")", "{", "Tr", ".", "event", "(", "tc", ",", "\"Unexpected on \"", "+", "propName", "+", "\" with dataType \"", "+", "dataType", ",", "ae", ")", ";", "}", "if", "(", "tc", ".", "isErrorEnabled", "(", ")", ")", "Tr", ".", "error", "(", "tc", ",", "WIMMessageKey", ".", "INVALID_PROPERTY_DATA_TYPE", ",", "WIMMessageHelper", ".", "generateMsgParms", "(", "propName", ")", ")", ";", "}", "}" ]
Set the appropriate value for the specified property. @param entity @param attr @param prop @param ldapAttr @throws WIMException
[ "Set", "the", "appropriate", "value", "for", "the", "specified", "property", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L1207-L1257
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.processPropertyValue
private Object processPropertyValue(Entity entity, String propName, final String dataType, final String syntax, Object ldapValue) throws WIMException { if (DATA_TYPE_STRING.equals(dataType)) { boolean octet = LDAP_ATTR_SYNTAX_OCTETSTRING.equalsIgnoreCase(syntax); return getString(octet, ldapValue); } else if (DATA_TYPE_DATE_TIME.equals(dataType)) { return getDateString(ldapValue); } else if (DATA_TYPE_DATE.equals(dataType)) { return getDateObject(ldapValue); } else if (DATA_TYPE_INT.equals(dataType)) { return Integer.parseInt(ldapValue.toString()); } else if (DATA_TYPE_IDENTIFIER_TYPE.equals(dataType)) { try { String stringValue = (String) ldapValue; LdapEntry ldapEntry = iLdapConn.getEntityByIdentifier(stringValue, null, null, null, null, false, false); return createIdentiferFromLdapEntry(ldapEntry); } catch (WIMException we) { if (WIMMessageKey.LDAP_ENTRY_NOT_FOUND.equalsIgnoreCase(we.getMessageKey())) { String msg = Tr.formatMessage(tc, WIMMessageKey.INVALID_PROPERTY_VALUE, WIMMessageHelper.generateMsgParms(propName, entity.getIdentifier().getExternalName())); throw new WIMSystemException(WIMMessageKey.INVALID_PROPERTY_VALUE, msg); } else { throw we; } } } else if (DATA_TYPE_BASE_64_BINARY.equals(dataType)) { return ldapValue; } else if (DATA_TYPE_LANG_TYPE.equals(dataType)) { LangType lang = new LangType(); lang.setValue(String.valueOf(ldapValue)); return lang; } else if (DATA_TYPE_BOOLEAN.equals(dataType)) { return Boolean.parseBoolean(ldapValue.toString()); } else if (DATA_TYPE_LONG.equals(dataType)) { //PI05723 return Long.parseLong(ldapValue.toString()); } else { if (tc.isEventEnabled()) { Tr.event(tc, "Datatype for " + propName + " was null, process without casting"); } return ldapValue; } }
java
private Object processPropertyValue(Entity entity, String propName, final String dataType, final String syntax, Object ldapValue) throws WIMException { if (DATA_TYPE_STRING.equals(dataType)) { boolean octet = LDAP_ATTR_SYNTAX_OCTETSTRING.equalsIgnoreCase(syntax); return getString(octet, ldapValue); } else if (DATA_TYPE_DATE_TIME.equals(dataType)) { return getDateString(ldapValue); } else if (DATA_TYPE_DATE.equals(dataType)) { return getDateObject(ldapValue); } else if (DATA_TYPE_INT.equals(dataType)) { return Integer.parseInt(ldapValue.toString()); } else if (DATA_TYPE_IDENTIFIER_TYPE.equals(dataType)) { try { String stringValue = (String) ldapValue; LdapEntry ldapEntry = iLdapConn.getEntityByIdentifier(stringValue, null, null, null, null, false, false); return createIdentiferFromLdapEntry(ldapEntry); } catch (WIMException we) { if (WIMMessageKey.LDAP_ENTRY_NOT_FOUND.equalsIgnoreCase(we.getMessageKey())) { String msg = Tr.formatMessage(tc, WIMMessageKey.INVALID_PROPERTY_VALUE, WIMMessageHelper.generateMsgParms(propName, entity.getIdentifier().getExternalName())); throw new WIMSystemException(WIMMessageKey.INVALID_PROPERTY_VALUE, msg); } else { throw we; } } } else if (DATA_TYPE_BASE_64_BINARY.equals(dataType)) { return ldapValue; } else if (DATA_TYPE_LANG_TYPE.equals(dataType)) { LangType lang = new LangType(); lang.setValue(String.valueOf(ldapValue)); return lang; } else if (DATA_TYPE_BOOLEAN.equals(dataType)) { return Boolean.parseBoolean(ldapValue.toString()); } else if (DATA_TYPE_LONG.equals(dataType)) { //PI05723 return Long.parseLong(ldapValue.toString()); } else { if (tc.isEventEnabled()) { Tr.event(tc, "Datatype for " + propName + " was null, process without casting"); } return ldapValue; } }
[ "private", "Object", "processPropertyValue", "(", "Entity", "entity", ",", "String", "propName", ",", "final", "String", "dataType", ",", "final", "String", "syntax", ",", "Object", "ldapValue", ")", "throws", "WIMException", "{", "if", "(", "DATA_TYPE_STRING", ".", "equals", "(", "dataType", ")", ")", "{", "boolean", "octet", "=", "LDAP_ATTR_SYNTAX_OCTETSTRING", ".", "equalsIgnoreCase", "(", "syntax", ")", ";", "return", "getString", "(", "octet", ",", "ldapValue", ")", ";", "}", "else", "if", "(", "DATA_TYPE_DATE_TIME", ".", "equals", "(", "dataType", ")", ")", "{", "return", "getDateString", "(", "ldapValue", ")", ";", "}", "else", "if", "(", "DATA_TYPE_DATE", ".", "equals", "(", "dataType", ")", ")", "{", "return", "getDateObject", "(", "ldapValue", ")", ";", "}", "else", "if", "(", "DATA_TYPE_INT", ".", "equals", "(", "dataType", ")", ")", "{", "return", "Integer", ".", "parseInt", "(", "ldapValue", ".", "toString", "(", ")", ")", ";", "}", "else", "if", "(", "DATA_TYPE_IDENTIFIER_TYPE", ".", "equals", "(", "dataType", ")", ")", "{", "try", "{", "String", "stringValue", "=", "(", "String", ")", "ldapValue", ";", "LdapEntry", "ldapEntry", "=", "iLdapConn", ".", "getEntityByIdentifier", "(", "stringValue", ",", "null", ",", "null", ",", "null", ",", "null", ",", "false", ",", "false", ")", ";", "return", "createIdentiferFromLdapEntry", "(", "ldapEntry", ")", ";", "}", "catch", "(", "WIMException", "we", ")", "{", "if", "(", "WIMMessageKey", ".", "LDAP_ENTRY_NOT_FOUND", ".", "equalsIgnoreCase", "(", "we", ".", "getMessageKey", "(", ")", ")", ")", "{", "String", "msg", "=", "Tr", ".", "formatMessage", "(", "tc", ",", "WIMMessageKey", ".", "INVALID_PROPERTY_VALUE", ",", "WIMMessageHelper", ".", "generateMsgParms", "(", "propName", ",", "entity", ".", "getIdentifier", "(", ")", ".", "getExternalName", "(", ")", ")", ")", ";", "throw", "new", "WIMSystemException", "(", "WIMMessageKey", ".", "INVALID_PROPERTY_VALUE", ",", "msg", ")", ";", "}", "else", "{", "throw", "we", ";", "}", "}", "}", "else", "if", "(", "DATA_TYPE_BASE_64_BINARY", ".", "equals", "(", "dataType", ")", ")", "{", "return", "ldapValue", ";", "}", "else", "if", "(", "DATA_TYPE_LANG_TYPE", ".", "equals", "(", "dataType", ")", ")", "{", "LangType", "lang", "=", "new", "LangType", "(", ")", ";", "lang", ".", "setValue", "(", "String", ".", "valueOf", "(", "ldapValue", ")", ")", ";", "return", "lang", ";", "}", "else", "if", "(", "DATA_TYPE_BOOLEAN", ".", "equals", "(", "dataType", ")", ")", "{", "return", "Boolean", ".", "parseBoolean", "(", "ldapValue", ".", "toString", "(", ")", ")", ";", "}", "else", "if", "(", "DATA_TYPE_LONG", ".", "equals", "(", "dataType", ")", ")", "{", "//PI05723", "return", "Long", ".", "parseLong", "(", "ldapValue", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "if", "(", "tc", ".", "isEventEnabled", "(", ")", ")", "{", "Tr", ".", "event", "(", "tc", ",", "\"Datatype for \"", "+", "propName", "+", "\" was null, process without casting\"", ")", ";", "}", "return", "ldapValue", ";", "}", "}" ]
Process the value of a property. @param entity The entity to process the value for. @param propName The property name to process. @param dataType The data type of the property. @param syntax The syntax for the property. @param ldapValue The value from the LDAP server. @return The processed value. @throws WIMException If there was an issue processing the property's value.
[ "Process", "the", "value", "of", "a", "property", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L1270-L1309
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.getGroups
private void getGroups(Entity entity, LdapEntry ldapEntry, GroupMembershipControl grpMbrshipCtrl) throws WIMException { if (grpMbrshipCtrl == null) { return; } int level = grpMbrshipCtrl.getLevel(); List<String> propNames = grpMbrshipCtrl.getProperties(); String[] bases = null; List<String> searchBases = grpMbrshipCtrl.getSearchBases(); int size = searchBases.size(); String[] grpBases = iLdapConfigMgr.getGroupSearchBases(); if (size == 0) { // New:: Default search bases to top level nodes if no group level search bases are defined if (grpBases.length != 0) bases = grpBases; else bases = iLdapConfigMgr.getTopLdapNodes(); } else { List<String> baseList = new ArrayList<String>(size); for (int i = 0; i < size; i++) { String uName = searchBases.get(i); String dn = getDN(uName, null, null, true, false); baseList.add(dn); } bases = baseList.toArray(new String[0]); } bases = NodeHelper.getTopNodes(bases); if (iLdapConfigMgr.getMembershipAttribute() != null) { if (iLdapConfigMgr.isRacf()) getGroupsByMembershipRacf(entity, ldapEntry, bases, level, propNames, null); else { getGroupsByMembership(entity, ldapEntry, bases, level, propNames, null); } } else { // If operational attribute "ibm-allGroups" is specified in groupMemberIdMap, then get groups using operational attr "ibm-allGroups" if (LdapConstants.IDS_LDAP_SERVER.equalsIgnoreCase(iLdapConfigMgr.getLdapType()) && iLdapConfigMgr.isLdapOperationalAttributeSet()) getGroupsByOperationalAttribute(entity, ldapEntry, bases, level, propNames); else { getGroupsByMember(entity, ldapEntry, bases, level, propNames, null); } } }
java
private void getGroups(Entity entity, LdapEntry ldapEntry, GroupMembershipControl grpMbrshipCtrl) throws WIMException { if (grpMbrshipCtrl == null) { return; } int level = grpMbrshipCtrl.getLevel(); List<String> propNames = grpMbrshipCtrl.getProperties(); String[] bases = null; List<String> searchBases = grpMbrshipCtrl.getSearchBases(); int size = searchBases.size(); String[] grpBases = iLdapConfigMgr.getGroupSearchBases(); if (size == 0) { // New:: Default search bases to top level nodes if no group level search bases are defined if (grpBases.length != 0) bases = grpBases; else bases = iLdapConfigMgr.getTopLdapNodes(); } else { List<String> baseList = new ArrayList<String>(size); for (int i = 0; i < size; i++) { String uName = searchBases.get(i); String dn = getDN(uName, null, null, true, false); baseList.add(dn); } bases = baseList.toArray(new String[0]); } bases = NodeHelper.getTopNodes(bases); if (iLdapConfigMgr.getMembershipAttribute() != null) { if (iLdapConfigMgr.isRacf()) getGroupsByMembershipRacf(entity, ldapEntry, bases, level, propNames, null); else { getGroupsByMembership(entity, ldapEntry, bases, level, propNames, null); } } else { // If operational attribute "ibm-allGroups" is specified in groupMemberIdMap, then get groups using operational attr "ibm-allGroups" if (LdapConstants.IDS_LDAP_SERVER.equalsIgnoreCase(iLdapConfigMgr.getLdapType()) && iLdapConfigMgr.isLdapOperationalAttributeSet()) getGroupsByOperationalAttribute(entity, ldapEntry, bases, level, propNames); else { getGroupsByMember(entity, ldapEntry, bases, level, propNames, null); } } }
[ "private", "void", "getGroups", "(", "Entity", "entity", ",", "LdapEntry", "ldapEntry", ",", "GroupMembershipControl", "grpMbrshipCtrl", ")", "throws", "WIMException", "{", "if", "(", "grpMbrshipCtrl", "==", "null", ")", "{", "return", ";", "}", "int", "level", "=", "grpMbrshipCtrl", ".", "getLevel", "(", ")", ";", "List", "<", "String", ">", "propNames", "=", "grpMbrshipCtrl", ".", "getProperties", "(", ")", ";", "String", "[", "]", "bases", "=", "null", ";", "List", "<", "String", ">", "searchBases", "=", "grpMbrshipCtrl", ".", "getSearchBases", "(", ")", ";", "int", "size", "=", "searchBases", ".", "size", "(", ")", ";", "String", "[", "]", "grpBases", "=", "iLdapConfigMgr", ".", "getGroupSearchBases", "(", ")", ";", "if", "(", "size", "==", "0", ")", "{", "// New:: Default search bases to top level nodes if no group level search bases are defined", "if", "(", "grpBases", ".", "length", "!=", "0", ")", "bases", "=", "grpBases", ";", "else", "bases", "=", "iLdapConfigMgr", ".", "getTopLdapNodes", "(", ")", ";", "}", "else", "{", "List", "<", "String", ">", "baseList", "=", "new", "ArrayList", "<", "String", ">", "(", "size", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "String", "uName", "=", "searchBases", ".", "get", "(", "i", ")", ";", "String", "dn", "=", "getDN", "(", "uName", ",", "null", ",", "null", ",", "true", ",", "false", ")", ";", "baseList", ".", "add", "(", "dn", ")", ";", "}", "bases", "=", "baseList", ".", "toArray", "(", "new", "String", "[", "0", "]", ")", ";", "}", "bases", "=", "NodeHelper", ".", "getTopNodes", "(", "bases", ")", ";", "if", "(", "iLdapConfigMgr", ".", "getMembershipAttribute", "(", ")", "!=", "null", ")", "{", "if", "(", "iLdapConfigMgr", ".", "isRacf", "(", ")", ")", "getGroupsByMembershipRacf", "(", "entity", ",", "ldapEntry", ",", "bases", ",", "level", ",", "propNames", ",", "null", ")", ";", "else", "{", "getGroupsByMembership", "(", "entity", ",", "ldapEntry", ",", "bases", ",", "level", ",", "propNames", ",", "null", ")", ";", "}", "}", "else", "{", "// If operational attribute \"ibm-allGroups\" is specified in groupMemberIdMap, then get groups using operational attr \"ibm-allGroups\"", "if", "(", "LdapConstants", ".", "IDS_LDAP_SERVER", ".", "equalsIgnoreCase", "(", "iLdapConfigMgr", ".", "getLdapType", "(", ")", ")", "&&", "iLdapConfigMgr", ".", "isLdapOperationalAttributeSet", "(", ")", ")", "getGroupsByOperationalAttribute", "(", "entity", ",", "ldapEntry", ",", "bases", ",", "level", ",", "propNames", ")", ";", "else", "{", "getGroupsByMember", "(", "entity", ",", "ldapEntry", ",", "bases", ",", "level", ",", "propNames", ",", "null", ")", ";", "}", "}", "}" ]
Method to get the Groups for the given entity. @param entity @param ldapEntry @param grpMbrshipCtrl @throws WIMException
[ "Method", "to", "get", "the", "Groups", "for", "the", "given", "entity", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L1319-L1360
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.getDynamicMembers
private List<String> getDynamicMembers(Attribute groupMemberURLs) throws WIMException { final String METHODNAME = "getDynamicMembers"; List<String> memberDNs = new ArrayList<String>(); if (groupMemberURLs != null) { try { for (NamingEnumeration<?> enu = groupMemberURLs.getAll(); enu.hasMoreElements();) { String ldapurlStr = (String) (enu.nextElement()); if (ldapurlStr != null) { LdapURL ldapURL = new LdapURL(ldapurlStr); if (ldapURL.parsedOK()) { int searchScope = SearchControls.OBJECT_SCOPE; String scopeBuf = ldapURL.get_scope(); if (scopeBuf != null) { if (scopeBuf.compareToIgnoreCase("base") == 0) { searchScope = SearchControls.OBJECT_SCOPE; } else if (scopeBuf.compareToIgnoreCase("one") == 0) { searchScope = SearchControls.ONELEVEL_SCOPE; } else if (scopeBuf.compareToIgnoreCase("sub") == 0) { searchScope = SearchControls.SUBTREE_SCOPE; } } String searchFilter = ldapURL.get_filter(); if (searchFilter == null) { searchFilter = "(objectClass=*)"; } String searchBase = ldapURL.get_dn(); String[] attributesToReturn = ldapURL.get_attributes(); for (NamingEnumeration<?> nenu = iLdapConn.search(searchBase, searchFilter, searchScope, attributesToReturn); nenu.hasMoreElements();) { javax.naming.directory.SearchResult thisEntry = (javax.naming.directory.SearchResult) nenu.nextElement(); if (thisEntry == null) { continue; } String dynaMbrDN = LdapHelper.prepareDN(thisEntry.getName(), searchBase); memberDNs.add(dynaMbrDN); } } } else { if (tc.isDebugEnabled()) { Tr.debug(tc, METHODNAME + " LDAP URL=null."); } } } } catch (NamingException e) { throw new WIMSystemException(WIMMessageKey.NAMING_EXCEPTION, Tr.formatMessage( tc, WIMMessageKey.NAMING_EXCEPTION, WIMMessageHelper.generateMsgParms(e.toString(true)))); } } return memberDNs; }
java
private List<String> getDynamicMembers(Attribute groupMemberURLs) throws WIMException { final String METHODNAME = "getDynamicMembers"; List<String> memberDNs = new ArrayList<String>(); if (groupMemberURLs != null) { try { for (NamingEnumeration<?> enu = groupMemberURLs.getAll(); enu.hasMoreElements();) { String ldapurlStr = (String) (enu.nextElement()); if (ldapurlStr != null) { LdapURL ldapURL = new LdapURL(ldapurlStr); if (ldapURL.parsedOK()) { int searchScope = SearchControls.OBJECT_SCOPE; String scopeBuf = ldapURL.get_scope(); if (scopeBuf != null) { if (scopeBuf.compareToIgnoreCase("base") == 0) { searchScope = SearchControls.OBJECT_SCOPE; } else if (scopeBuf.compareToIgnoreCase("one") == 0) { searchScope = SearchControls.ONELEVEL_SCOPE; } else if (scopeBuf.compareToIgnoreCase("sub") == 0) { searchScope = SearchControls.SUBTREE_SCOPE; } } String searchFilter = ldapURL.get_filter(); if (searchFilter == null) { searchFilter = "(objectClass=*)"; } String searchBase = ldapURL.get_dn(); String[] attributesToReturn = ldapURL.get_attributes(); for (NamingEnumeration<?> nenu = iLdapConn.search(searchBase, searchFilter, searchScope, attributesToReturn); nenu.hasMoreElements();) { javax.naming.directory.SearchResult thisEntry = (javax.naming.directory.SearchResult) nenu.nextElement(); if (thisEntry == null) { continue; } String dynaMbrDN = LdapHelper.prepareDN(thisEntry.getName(), searchBase); memberDNs.add(dynaMbrDN); } } } else { if (tc.isDebugEnabled()) { Tr.debug(tc, METHODNAME + " LDAP URL=null."); } } } } catch (NamingException e) { throw new WIMSystemException(WIMMessageKey.NAMING_EXCEPTION, Tr.formatMessage( tc, WIMMessageKey.NAMING_EXCEPTION, WIMMessageHelper.generateMsgParms(e.toString(true)))); } } return memberDNs; }
[ "private", "List", "<", "String", ">", "getDynamicMembers", "(", "Attribute", "groupMemberURLs", ")", "throws", "WIMException", "{", "final", "String", "METHODNAME", "=", "\"getDynamicMembers\"", ";", "List", "<", "String", ">", "memberDNs", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "if", "(", "groupMemberURLs", "!=", "null", ")", "{", "try", "{", "for", "(", "NamingEnumeration", "<", "?", ">", "enu", "=", "groupMemberURLs", ".", "getAll", "(", ")", ";", "enu", ".", "hasMoreElements", "(", ")", ";", ")", "{", "String", "ldapurlStr", "=", "(", "String", ")", "(", "enu", ".", "nextElement", "(", ")", ")", ";", "if", "(", "ldapurlStr", "!=", "null", ")", "{", "LdapURL", "ldapURL", "=", "new", "LdapURL", "(", "ldapurlStr", ")", ";", "if", "(", "ldapURL", ".", "parsedOK", "(", ")", ")", "{", "int", "searchScope", "=", "SearchControls", ".", "OBJECT_SCOPE", ";", "String", "scopeBuf", "=", "ldapURL", ".", "get_scope", "(", ")", ";", "if", "(", "scopeBuf", "!=", "null", ")", "{", "if", "(", "scopeBuf", ".", "compareToIgnoreCase", "(", "\"base\"", ")", "==", "0", ")", "{", "searchScope", "=", "SearchControls", ".", "OBJECT_SCOPE", ";", "}", "else", "if", "(", "scopeBuf", ".", "compareToIgnoreCase", "(", "\"one\"", ")", "==", "0", ")", "{", "searchScope", "=", "SearchControls", ".", "ONELEVEL_SCOPE", ";", "}", "else", "if", "(", "scopeBuf", ".", "compareToIgnoreCase", "(", "\"sub\"", ")", "==", "0", ")", "{", "searchScope", "=", "SearchControls", ".", "SUBTREE_SCOPE", ";", "}", "}", "String", "searchFilter", "=", "ldapURL", ".", "get_filter", "(", ")", ";", "if", "(", "searchFilter", "==", "null", ")", "{", "searchFilter", "=", "\"(objectClass=*)\"", ";", "}", "String", "searchBase", "=", "ldapURL", ".", "get_dn", "(", ")", ";", "String", "[", "]", "attributesToReturn", "=", "ldapURL", ".", "get_attributes", "(", ")", ";", "for", "(", "NamingEnumeration", "<", "?", ">", "nenu", "=", "iLdapConn", ".", "search", "(", "searchBase", ",", "searchFilter", ",", "searchScope", ",", "attributesToReturn", ")", ";", "nenu", ".", "hasMoreElements", "(", ")", ";", ")", "{", "javax", ".", "naming", ".", "directory", ".", "SearchResult", "thisEntry", "=", "(", "javax", ".", "naming", ".", "directory", ".", "SearchResult", ")", "nenu", ".", "nextElement", "(", ")", ";", "if", "(", "thisEntry", "==", "null", ")", "{", "continue", ";", "}", "String", "dynaMbrDN", "=", "LdapHelper", ".", "prepareDN", "(", "thisEntry", ".", "getName", "(", ")", ",", "searchBase", ")", ";", "memberDNs", ".", "add", "(", "dynaMbrDN", ")", ";", "}", "}", "}", "else", "{", "if", "(", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "Tr", ".", "debug", "(", "tc", ",", "METHODNAME", "+", "\" LDAP URL=null.\"", ")", ";", "}", "}", "}", "}", "catch", "(", "NamingException", "e", ")", "{", "throw", "new", "WIMSystemException", "(", "WIMMessageKey", ".", "NAMING_EXCEPTION", ",", "Tr", ".", "formatMessage", "(", "tc", ",", "WIMMessageKey", ".", "NAMING_EXCEPTION", ",", "WIMMessageHelper", ".", "generateMsgParms", "(", "e", ".", "toString", "(", "true", ")", ")", ")", ")", ";", "}", "}", "return", "memberDNs", ";", "}" ]
Method to get the list of dynamic members from the given Group Member URL. @param groupMemberURLs @return @throws WIMException
[ "Method", "to", "get", "the", "list", "of", "dynamic", "members", "from", "the", "given", "Group", "Member", "URL", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L2371-L2425
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.getDescendants
private void getDescendants(Entity entity, LdapEntry ldapEntry, DescendantControl descCtrl) throws WIMException { if (descCtrl == null) { return; } List<String> propNames = descCtrl.getProperties(); int level = descCtrl.getLevel(); List<String> descTypes = getEntityTypes(descCtrl); String[] bases = getBases(descCtrl, descTypes); boolean treeView = descCtrl.isSetTreeView(); int scope = SearchControls.ONELEVEL_SCOPE; if (level == 0 && !treeView) { scope = SearchControls.SUBTREE_SCOPE; } Set<String> descToDo = new HashSet<String>(); Map<String, Entity> descendants = new HashMap<String, Entity>(); Set<LdapEntry> descEntries = iLdapConn.searchEntities(ldapEntry.getDN(), "objectClass=*", null, scope, descTypes, propNames, false, false); for (LdapEntry descEntry : descEntries) { String descType = descEntry.getType(); String descDn = descEntry.getDN(); Entity descendant = null; if (LdapHelper.isUnderBases(descDn, bases) && descTypes.contains(descType)) { descendant = createEntityFromLdapEntry(entity, SchemaConstants.DO_CHILDREN, descEntry, propNames); } else if (treeView) { descendant = createEntityFromLdapEntry(entity, SchemaConstants.DO_CHILDREN, descEntry, null); } if (treeView) { descToDo.add(descDn); descendants.put(descDn, descendant); } } if (treeView) { while (descToDo.size() > 0) { Set<String> nextDescs = new HashSet<String>(); for (String dn : descToDo) { Entity parent = descendants.get(dn); descEntries = iLdapConn.searchEntities(dn, "objectClass=*", null, scope, descTypes, propNames, false, false); for (LdapEntry descEntry : descEntries) { String descType = descEntry.getType(); String descDn = descEntry.getDN(); Entity descendant = null; if (descTypes.contains(descType)) { descendant = createEntityFromLdapEntry(parent, SchemaConstants.DO_CHILDREN, descEntry, propNames); } else if (treeView) { descendant = createEntityFromLdapEntry(parent, SchemaConstants.DO_CHILDREN, descEntry, null); } if (!descToDo.contains(descDn)) { nextDescs.add(descDn); descendants.put(descDn, descendant); } } } descToDo = nextDescs; } } }
java
private void getDescendants(Entity entity, LdapEntry ldapEntry, DescendantControl descCtrl) throws WIMException { if (descCtrl == null) { return; } List<String> propNames = descCtrl.getProperties(); int level = descCtrl.getLevel(); List<String> descTypes = getEntityTypes(descCtrl); String[] bases = getBases(descCtrl, descTypes); boolean treeView = descCtrl.isSetTreeView(); int scope = SearchControls.ONELEVEL_SCOPE; if (level == 0 && !treeView) { scope = SearchControls.SUBTREE_SCOPE; } Set<String> descToDo = new HashSet<String>(); Map<String, Entity> descendants = new HashMap<String, Entity>(); Set<LdapEntry> descEntries = iLdapConn.searchEntities(ldapEntry.getDN(), "objectClass=*", null, scope, descTypes, propNames, false, false); for (LdapEntry descEntry : descEntries) { String descType = descEntry.getType(); String descDn = descEntry.getDN(); Entity descendant = null; if (LdapHelper.isUnderBases(descDn, bases) && descTypes.contains(descType)) { descendant = createEntityFromLdapEntry(entity, SchemaConstants.DO_CHILDREN, descEntry, propNames); } else if (treeView) { descendant = createEntityFromLdapEntry(entity, SchemaConstants.DO_CHILDREN, descEntry, null); } if (treeView) { descToDo.add(descDn); descendants.put(descDn, descendant); } } if (treeView) { while (descToDo.size() > 0) { Set<String> nextDescs = new HashSet<String>(); for (String dn : descToDo) { Entity parent = descendants.get(dn); descEntries = iLdapConn.searchEntities(dn, "objectClass=*", null, scope, descTypes, propNames, false, false); for (LdapEntry descEntry : descEntries) { String descType = descEntry.getType(); String descDn = descEntry.getDN(); Entity descendant = null; if (descTypes.contains(descType)) { descendant = createEntityFromLdapEntry(parent, SchemaConstants.DO_CHILDREN, descEntry, propNames); } else if (treeView) { descendant = createEntityFromLdapEntry(parent, SchemaConstants.DO_CHILDREN, descEntry, null); } if (!descToDo.contains(descDn)) { nextDescs.add(descDn); descendants.put(descDn, descendant); } } } descToDo = nextDescs; } } }
[ "private", "void", "getDescendants", "(", "Entity", "entity", ",", "LdapEntry", "ldapEntry", ",", "DescendantControl", "descCtrl", ")", "throws", "WIMException", "{", "if", "(", "descCtrl", "==", "null", ")", "{", "return", ";", "}", "List", "<", "String", ">", "propNames", "=", "descCtrl", ".", "getProperties", "(", ")", ";", "int", "level", "=", "descCtrl", ".", "getLevel", "(", ")", ";", "List", "<", "String", ">", "descTypes", "=", "getEntityTypes", "(", "descCtrl", ")", ";", "String", "[", "]", "bases", "=", "getBases", "(", "descCtrl", ",", "descTypes", ")", ";", "boolean", "treeView", "=", "descCtrl", ".", "isSetTreeView", "(", ")", ";", "int", "scope", "=", "SearchControls", ".", "ONELEVEL_SCOPE", ";", "if", "(", "level", "==", "0", "&&", "!", "treeView", ")", "{", "scope", "=", "SearchControls", ".", "SUBTREE_SCOPE", ";", "}", "Set", "<", "String", ">", "descToDo", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "Map", "<", "String", ",", "Entity", ">", "descendants", "=", "new", "HashMap", "<", "String", ",", "Entity", ">", "(", ")", ";", "Set", "<", "LdapEntry", ">", "descEntries", "=", "iLdapConn", ".", "searchEntities", "(", "ldapEntry", ".", "getDN", "(", ")", ",", "\"objectClass=*\"", ",", "null", ",", "scope", ",", "descTypes", ",", "propNames", ",", "false", ",", "false", ")", ";", "for", "(", "LdapEntry", "descEntry", ":", "descEntries", ")", "{", "String", "descType", "=", "descEntry", ".", "getType", "(", ")", ";", "String", "descDn", "=", "descEntry", ".", "getDN", "(", ")", ";", "Entity", "descendant", "=", "null", ";", "if", "(", "LdapHelper", ".", "isUnderBases", "(", "descDn", ",", "bases", ")", "&&", "descTypes", ".", "contains", "(", "descType", ")", ")", "{", "descendant", "=", "createEntityFromLdapEntry", "(", "entity", ",", "SchemaConstants", ".", "DO_CHILDREN", ",", "descEntry", ",", "propNames", ")", ";", "}", "else", "if", "(", "treeView", ")", "{", "descendant", "=", "createEntityFromLdapEntry", "(", "entity", ",", "SchemaConstants", ".", "DO_CHILDREN", ",", "descEntry", ",", "null", ")", ";", "}", "if", "(", "treeView", ")", "{", "descToDo", ".", "add", "(", "descDn", ")", ";", "descendants", ".", "put", "(", "descDn", ",", "descendant", ")", ";", "}", "}", "if", "(", "treeView", ")", "{", "while", "(", "descToDo", ".", "size", "(", ")", ">", "0", ")", "{", "Set", "<", "String", ">", "nextDescs", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "String", "dn", ":", "descToDo", ")", "{", "Entity", "parent", "=", "descendants", ".", "get", "(", "dn", ")", ";", "descEntries", "=", "iLdapConn", ".", "searchEntities", "(", "dn", ",", "\"objectClass=*\"", ",", "null", ",", "scope", ",", "descTypes", ",", "propNames", ",", "false", ",", "false", ")", ";", "for", "(", "LdapEntry", "descEntry", ":", "descEntries", ")", "{", "String", "descType", "=", "descEntry", ".", "getType", "(", ")", ";", "String", "descDn", "=", "descEntry", ".", "getDN", "(", ")", ";", "Entity", "descendant", "=", "null", ";", "if", "(", "descTypes", ".", "contains", "(", "descType", ")", ")", "{", "descendant", "=", "createEntityFromLdapEntry", "(", "parent", ",", "SchemaConstants", ".", "DO_CHILDREN", ",", "descEntry", ",", "propNames", ")", ";", "}", "else", "if", "(", "treeView", ")", "{", "descendant", "=", "createEntityFromLdapEntry", "(", "parent", ",", "SchemaConstants", ".", "DO_CHILDREN", ",", "descEntry", ",", "null", ")", ";", "}", "if", "(", "!", "descToDo", ".", "contains", "(", "descDn", ")", ")", "{", "nextDescs", ".", "add", "(", "descDn", ")", ";", "descendants", ".", "put", "(", "descDn", ",", "descendant", ")", ";", "}", "}", "}", "descToDo", "=", "nextDescs", ";", "}", "}", "}" ]
Method to get the list of descendants. @param entity @param ldapEntry @param descCtrl @throws WIMException
[ "Method", "to", "get", "the", "list", "of", "descendants", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L2435-L2492
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.getAncestors
private void getAncestors(Entity entity, LdapEntry ldapEntry, AncestorControl ancesCtrl) throws WIMException { if (ancesCtrl == null) { return; } List<String> propNames = ancesCtrl.getProperties(); int level = ancesCtrl.getLevel(); List<String> ancesTypes = getEntityTypes(ancesCtrl); String[] bases = getBases(ancesCtrl, ancesTypes); String dn = ldapEntry.getDN(); List<String> ancestorDns = iLdapConn.getAncestorDNs(dn, level); Entity parentEntity = entity; for (int i = 0; i < ancestorDns.size(); i++) { String ancesDn = ancestorDns.get(i); if (ancesDn.length() == 0) { continue; } if (LdapHelper.isUnderBases(ancesDn, bases)) { LdapEntry ancesEntry = iLdapConn.getEntityByIdentifier(ancesDn, null, null, ancesTypes, propNames, false, false); String ancesType = ancesEntry.getType(); Entity ancestor = null; if (ancesTypes.contains(ancesType)) { ancestor = createEntityFromLdapEntry(parentEntity, SchemaConstants.DO_PARENT, ancesEntry, propNames); } else { ancestor = createEntityFromLdapEntry(parentEntity, SchemaConstants.DO_PARENT, ancesEntry, null); } parentEntity = ancestor; } } }
java
private void getAncestors(Entity entity, LdapEntry ldapEntry, AncestorControl ancesCtrl) throws WIMException { if (ancesCtrl == null) { return; } List<String> propNames = ancesCtrl.getProperties(); int level = ancesCtrl.getLevel(); List<String> ancesTypes = getEntityTypes(ancesCtrl); String[] bases = getBases(ancesCtrl, ancesTypes); String dn = ldapEntry.getDN(); List<String> ancestorDns = iLdapConn.getAncestorDNs(dn, level); Entity parentEntity = entity; for (int i = 0; i < ancestorDns.size(); i++) { String ancesDn = ancestorDns.get(i); if (ancesDn.length() == 0) { continue; } if (LdapHelper.isUnderBases(ancesDn, bases)) { LdapEntry ancesEntry = iLdapConn.getEntityByIdentifier(ancesDn, null, null, ancesTypes, propNames, false, false); String ancesType = ancesEntry.getType(); Entity ancestor = null; if (ancesTypes.contains(ancesType)) { ancestor = createEntityFromLdapEntry(parentEntity, SchemaConstants.DO_PARENT, ancesEntry, propNames); } else { ancestor = createEntityFromLdapEntry(parentEntity, SchemaConstants.DO_PARENT, ancesEntry, null); } parentEntity = ancestor; } } }
[ "private", "void", "getAncestors", "(", "Entity", "entity", ",", "LdapEntry", "ldapEntry", ",", "AncestorControl", "ancesCtrl", ")", "throws", "WIMException", "{", "if", "(", "ancesCtrl", "==", "null", ")", "{", "return", ";", "}", "List", "<", "String", ">", "propNames", "=", "ancesCtrl", ".", "getProperties", "(", ")", ";", "int", "level", "=", "ancesCtrl", ".", "getLevel", "(", ")", ";", "List", "<", "String", ">", "ancesTypes", "=", "getEntityTypes", "(", "ancesCtrl", ")", ";", "String", "[", "]", "bases", "=", "getBases", "(", "ancesCtrl", ",", "ancesTypes", ")", ";", "String", "dn", "=", "ldapEntry", ".", "getDN", "(", ")", ";", "List", "<", "String", ">", "ancestorDns", "=", "iLdapConn", ".", "getAncestorDNs", "(", "dn", ",", "level", ")", ";", "Entity", "parentEntity", "=", "entity", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ancestorDns", ".", "size", "(", ")", ";", "i", "++", ")", "{", "String", "ancesDn", "=", "ancestorDns", ".", "get", "(", "i", ")", ";", "if", "(", "ancesDn", ".", "length", "(", ")", "==", "0", ")", "{", "continue", ";", "}", "if", "(", "LdapHelper", ".", "isUnderBases", "(", "ancesDn", ",", "bases", ")", ")", "{", "LdapEntry", "ancesEntry", "=", "iLdapConn", ".", "getEntityByIdentifier", "(", "ancesDn", ",", "null", ",", "null", ",", "ancesTypes", ",", "propNames", ",", "false", ",", "false", ")", ";", "String", "ancesType", "=", "ancesEntry", ".", "getType", "(", ")", ";", "Entity", "ancestor", "=", "null", ";", "if", "(", "ancesTypes", ".", "contains", "(", "ancesType", ")", ")", "{", "ancestor", "=", "createEntityFromLdapEntry", "(", "parentEntity", ",", "SchemaConstants", ".", "DO_PARENT", ",", "ancesEntry", ",", "propNames", ")", ";", "}", "else", "{", "ancestor", "=", "createEntityFromLdapEntry", "(", "parentEntity", ",", "SchemaConstants", ".", "DO_PARENT", ",", "ancesEntry", ",", "null", ")", ";", "}", "parentEntity", "=", "ancestor", ";", "}", "}", "}" ]
Method to get the ancestors of the given entity. @param entity @param ldapEntry @param ancesCtrl @throws WIMException
[ "Method", "to", "get", "the", "ancestors", "of", "the", "given", "entity", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L2579-L2610
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.getSpecifiedRealms
public static Set<String> getSpecifiedRealms(Root root) { Set<String> result = new HashSet<String>(); List<Context> contexts = root.getContexts(); for (Context context : contexts) { String key = context.getKey(); if (key != null && key.equals(SchemaConstants.PROP_REALM)) { String value = (String) context.getValue(); result.add(value); } } return result; }
java
public static Set<String> getSpecifiedRealms(Root root) { Set<String> result = new HashSet<String>(); List<Context> contexts = root.getContexts(); for (Context context : contexts) { String key = context.getKey(); if (key != null && key.equals(SchemaConstants.PROP_REALM)) { String value = (String) context.getValue(); result.add(value); } } return result; }
[ "public", "static", "Set", "<", "String", ">", "getSpecifiedRealms", "(", "Root", "root", ")", "{", "Set", "<", "String", ">", "result", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "List", "<", "Context", ">", "contexts", "=", "root", ".", "getContexts", "(", ")", ";", "for", "(", "Context", "context", ":", "contexts", ")", "{", "String", "key", "=", "context", ".", "getKey", "(", ")", ";", "if", "(", "key", "!=", "null", "&&", "key", ".", "equals", "(", "SchemaConstants", ".", "PROP_REALM", ")", ")", "{", "String", "value", "=", "(", "String", ")", "context", ".", "getValue", "(", ")", ";", "result", ".", "add", "(", "value", ")", ";", "}", "}", "return", "result", ";", "}" ]
return the specified realms from the root object of the input data graph @param root @return
[ "return", "the", "specified", "realms", "from", "the", "root", "object", "of", "the", "input", "data", "graph" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L2658-L2669
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.getContextProperty
public static String getContextProperty(Root root, String propertyName) { String result = ""; List<Context> contexts = root.getContexts(); for (Context context : contexts) { String key = context.getKey(); if (key != null && key.equals(propertyName)) { result = (String) context.getValue(); break; } } return result; }
java
public static String getContextProperty(Root root, String propertyName) { String result = ""; List<Context> contexts = root.getContexts(); for (Context context : contexts) { String key = context.getKey(); if (key != null && key.equals(propertyName)) { result = (String) context.getValue(); break; } } return result; }
[ "public", "static", "String", "getContextProperty", "(", "Root", "root", ",", "String", "propertyName", ")", "{", "String", "result", "=", "\"\"", ";", "List", "<", "Context", ">", "contexts", "=", "root", ".", "getContexts", "(", ")", ";", "for", "(", "Context", "context", ":", "contexts", ")", "{", "String", "key", "=", "context", ".", "getKey", "(", ")", ";", "if", "(", "key", "!=", "null", "&&", "key", ".", "equals", "(", "propertyName", ")", ")", "{", "result", "=", "(", "String", ")", "context", ".", "getValue", "(", ")", ";", "break", ";", "}", "}", "return", "result", ";", "}" ]
return the customProperty from the root object of the input data graph @param root @param propertyName @return
[ "return", "the", "customProperty", "from", "the", "root", "object", "of", "the", "input", "data", "graph" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L2678-L2689
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.isEntitySearchBaseConfigured
private boolean isEntitySearchBaseConfigured(List<String> mbrTypes) { String METHODNAME = "isEntitySearchBaseConfigured(mbrTypes)"; boolean isConfigured = false; if (mbrTypes != null) { for (String mbrType : mbrTypes) { LdapEntity ldapEntity = iLdapConfigMgr.getLdapEntity(mbrType); if (ldapEntity != null && ldapEntity.isSearchBaseConfigured()) { isConfigured = true; if (tc.isDebugEnabled()) Tr.debug(tc, METHODNAME + " Search base is explicitly configured for " + mbrType + ": " + ldapEntity.getSearchBaseList()); } } } return isConfigured; }
java
private boolean isEntitySearchBaseConfigured(List<String> mbrTypes) { String METHODNAME = "isEntitySearchBaseConfigured(mbrTypes)"; boolean isConfigured = false; if (mbrTypes != null) { for (String mbrType : mbrTypes) { LdapEntity ldapEntity = iLdapConfigMgr.getLdapEntity(mbrType); if (ldapEntity != null && ldapEntity.isSearchBaseConfigured()) { isConfigured = true; if (tc.isDebugEnabled()) Tr.debug(tc, METHODNAME + " Search base is explicitly configured for " + mbrType + ": " + ldapEntity.getSearchBaseList()); } } } return isConfigured; }
[ "private", "boolean", "isEntitySearchBaseConfigured", "(", "List", "<", "String", ">", "mbrTypes", ")", "{", "String", "METHODNAME", "=", "\"isEntitySearchBaseConfigured(mbrTypes)\"", ";", "boolean", "isConfigured", "=", "false", ";", "if", "(", "mbrTypes", "!=", "null", ")", "{", "for", "(", "String", "mbrType", ":", "mbrTypes", ")", "{", "LdapEntity", "ldapEntity", "=", "iLdapConfigMgr", ".", "getLdapEntity", "(", "mbrType", ")", ";", "if", "(", "ldapEntity", "!=", "null", "&&", "ldapEntity", ".", "isSearchBaseConfigured", "(", ")", ")", "{", "isConfigured", "=", "true", ";", "if", "(", "tc", ".", "isDebugEnabled", "(", ")", ")", "Tr", ".", "debug", "(", "tc", ",", "METHODNAME", "+", "\" Search base is explicitly configured for \"", "+", "mbrType", "+", "\": \"", "+", "ldapEntity", ".", "getSearchBaseList", "(", ")", ")", ";", "}", "}", "}", "return", "isConfigured", ";", "}" ]
Checks if a search base is configured for the entity types. @param mbrTypes Entity types @return
[ "Checks", "if", "a", "search", "base", "is", "configured", "for", "the", "entity", "types", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L2866-L2881
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.deleteAll
private List<LdapEntry> deleteAll(LdapEntry ldapEntry, boolean delDescendant) throws WIMException { String dn = ldapEntry.getDN(); List<LdapEntry> delEntries = new ArrayList<LdapEntry>(); List<LdapEntry> descs = getDescendants(dn, SearchControls.ONELEVEL_SCOPE); if (descs.size() > 0) { if (delDescendant) { for (int i = 0; i < descs.size(); i++) { LdapEntry descEntry = descs.get(i); delEntries.addAll(deleteAll(descEntry, true)); } } else { throw new EntityHasDescendantsException(WIMMessageKey.ENTITY_HAS_DESCENDENTS, Tr.formatMessage(tc, WIMMessageKey.ENTITY_HAS_DESCENDENTS, WIMMessageHelper.generateMsgParms(dn))); } } /* Call the preexit function */ deletePreExit(dn); List<String> grpList = getGroups(dn); iLdapConn.getContextManager().destroySubcontext(dn); delEntries.add(ldapEntry); for (int i = 0; i < grpList.size(); i++) { String grpDN = grpList.get(i); iLdapConn.invalidateAttributes(grpDN, null, null); } return delEntries; }
java
private List<LdapEntry> deleteAll(LdapEntry ldapEntry, boolean delDescendant) throws WIMException { String dn = ldapEntry.getDN(); List<LdapEntry> delEntries = new ArrayList<LdapEntry>(); List<LdapEntry> descs = getDescendants(dn, SearchControls.ONELEVEL_SCOPE); if (descs.size() > 0) { if (delDescendant) { for (int i = 0; i < descs.size(); i++) { LdapEntry descEntry = descs.get(i); delEntries.addAll(deleteAll(descEntry, true)); } } else { throw new EntityHasDescendantsException(WIMMessageKey.ENTITY_HAS_DESCENDENTS, Tr.formatMessage(tc, WIMMessageKey.ENTITY_HAS_DESCENDENTS, WIMMessageHelper.generateMsgParms(dn))); } } /* Call the preexit function */ deletePreExit(dn); List<String> grpList = getGroups(dn); iLdapConn.getContextManager().destroySubcontext(dn); delEntries.add(ldapEntry); for (int i = 0; i < grpList.size(); i++) { String grpDN = grpList.get(i); iLdapConn.invalidateAttributes(grpDN, null, null); } return delEntries; }
[ "private", "List", "<", "LdapEntry", ">", "deleteAll", "(", "LdapEntry", "ldapEntry", ",", "boolean", "delDescendant", ")", "throws", "WIMException", "{", "String", "dn", "=", "ldapEntry", ".", "getDN", "(", ")", ";", "List", "<", "LdapEntry", ">", "delEntries", "=", "new", "ArrayList", "<", "LdapEntry", ">", "(", ")", ";", "List", "<", "LdapEntry", ">", "descs", "=", "getDescendants", "(", "dn", ",", "SearchControls", ".", "ONELEVEL_SCOPE", ")", ";", "if", "(", "descs", ".", "size", "(", ")", ">", "0", ")", "{", "if", "(", "delDescendant", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "descs", ".", "size", "(", ")", ";", "i", "++", ")", "{", "LdapEntry", "descEntry", "=", "descs", ".", "get", "(", "i", ")", ";", "delEntries", ".", "addAll", "(", "deleteAll", "(", "descEntry", ",", "true", ")", ")", ";", "}", "}", "else", "{", "throw", "new", "EntityHasDescendantsException", "(", "WIMMessageKey", ".", "ENTITY_HAS_DESCENDENTS", ",", "Tr", ".", "formatMessage", "(", "tc", ",", "WIMMessageKey", ".", "ENTITY_HAS_DESCENDENTS", ",", "WIMMessageHelper", ".", "generateMsgParms", "(", "dn", ")", ")", ")", ";", "}", "}", "/* Call the preexit function */", "deletePreExit", "(", "dn", ")", ";", "List", "<", "String", ">", "grpList", "=", "getGroups", "(", "dn", ")", ";", "iLdapConn", ".", "getContextManager", "(", ")", ".", "destroySubcontext", "(", "dn", ")", ";", "delEntries", ".", "add", "(", "ldapEntry", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "grpList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "String", "grpDN", "=", "grpList", ".", "get", "(", "i", ")", ";", "iLdapConn", ".", "invalidateAttributes", "(", "grpDN", ",", "null", ",", "null", ")", ";", "}", "return", "delEntries", ";", "}" ]
Delete the descendants of the specified ldap entry. @param ldapEntry @param delDescendant @return @throws WIMException
[ "Delete", "the", "descendants", "of", "the", "specified", "ldap", "entry", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L3104-L3131
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.getDescendants
private List<LdapEntry> getDescendants(String DN, int level) throws WIMException { int scope = SearchControls.ONELEVEL_SCOPE; if (level == 0) { scope = SearchControls.SUBTREE_SCOPE; } List<LdapEntry> descendants = new ArrayList<LdapEntry>(); Set<LdapEntry> ldapEntries = iLdapConn.searchEntities(DN, "objectClass=*", null, scope, null, null, false, false); for (Iterator<LdapEntry> iter = ldapEntries.iterator(); iter.hasNext();) { LdapEntry entry = iter.next(); descendants.add(entry); } return descendants; }
java
private List<LdapEntry> getDescendants(String DN, int level) throws WIMException { int scope = SearchControls.ONELEVEL_SCOPE; if (level == 0) { scope = SearchControls.SUBTREE_SCOPE; } List<LdapEntry> descendants = new ArrayList<LdapEntry>(); Set<LdapEntry> ldapEntries = iLdapConn.searchEntities(DN, "objectClass=*", null, scope, null, null, false, false); for (Iterator<LdapEntry> iter = ldapEntries.iterator(); iter.hasNext();) { LdapEntry entry = iter.next(); descendants.add(entry); } return descendants; }
[ "private", "List", "<", "LdapEntry", ">", "getDescendants", "(", "String", "DN", ",", "int", "level", ")", "throws", "WIMException", "{", "int", "scope", "=", "SearchControls", ".", "ONELEVEL_SCOPE", ";", "if", "(", "level", "==", "0", ")", "{", "scope", "=", "SearchControls", ".", "SUBTREE_SCOPE", ";", "}", "List", "<", "LdapEntry", ">", "descendants", "=", "new", "ArrayList", "<", "LdapEntry", ">", "(", ")", ";", "Set", "<", "LdapEntry", ">", "ldapEntries", "=", "iLdapConn", ".", "searchEntities", "(", "DN", ",", "\"objectClass=*\"", ",", "null", ",", "scope", ",", "null", ",", "null", ",", "false", ",", "false", ")", ";", "for", "(", "Iterator", "<", "LdapEntry", ">", "iter", "=", "ldapEntries", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "LdapEntry", "entry", "=", "iter", ".", "next", "(", ")", ";", "descendants", ".", "add", "(", "entry", ")", ";", "}", "return", "descendants", ";", "}" ]
Get all the descendants of the given DN. @param DN @param level @return @throws WIMException
[ "Get", "all", "the", "descendants", "of", "the", "given", "DN", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L3148-L3162
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.getGroups
private List<String> getGroups(String dn) throws WIMException { List<String> grpList = new ArrayList<String>(); String filter = iLdapConfigMgr.getGroupMemberFilter(dn); String[] searchBases = iLdapConfigMgr.getGroupSearchBases(); for (int i = 0; i < searchBases.length; i++) { String searchBase = searchBases[i]; NamingEnumeration<SearchResult> nenu = iLdapConn.search(searchBase, filter, SearchControls.SUBTREE_SCOPE, LDAP_ATTR_OBJECTCLASS_ARRAY); while (nenu.hasMoreElements()) { SearchResult thisEntry = nenu.nextElement(); if (thisEntry == null) { continue; } String entryName = thisEntry.getName(); if (entryName == null || entryName.trim().length() == 0) { continue; } grpList.add(LdapHelper.prepareDN(entryName, searchBase)); } } return grpList; }
java
private List<String> getGroups(String dn) throws WIMException { List<String> grpList = new ArrayList<String>(); String filter = iLdapConfigMgr.getGroupMemberFilter(dn); String[] searchBases = iLdapConfigMgr.getGroupSearchBases(); for (int i = 0; i < searchBases.length; i++) { String searchBase = searchBases[i]; NamingEnumeration<SearchResult> nenu = iLdapConn.search(searchBase, filter, SearchControls.SUBTREE_SCOPE, LDAP_ATTR_OBJECTCLASS_ARRAY); while (nenu.hasMoreElements()) { SearchResult thisEntry = nenu.nextElement(); if (thisEntry == null) { continue; } String entryName = thisEntry.getName(); if (entryName == null || entryName.trim().length() == 0) { continue; } grpList.add(LdapHelper.prepareDN(entryName, searchBase)); } } return grpList; }
[ "private", "List", "<", "String", ">", "getGroups", "(", "String", "dn", ")", "throws", "WIMException", "{", "List", "<", "String", ">", "grpList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "String", "filter", "=", "iLdapConfigMgr", ".", "getGroupMemberFilter", "(", "dn", ")", ";", "String", "[", "]", "searchBases", "=", "iLdapConfigMgr", ".", "getGroupSearchBases", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "searchBases", ".", "length", ";", "i", "++", ")", "{", "String", "searchBase", "=", "searchBases", "[", "i", "]", ";", "NamingEnumeration", "<", "SearchResult", ">", "nenu", "=", "iLdapConn", ".", "search", "(", "searchBase", ",", "filter", ",", "SearchControls", ".", "SUBTREE_SCOPE", ",", "LDAP_ATTR_OBJECTCLASS_ARRAY", ")", ";", "while", "(", "nenu", ".", "hasMoreElements", "(", ")", ")", "{", "SearchResult", "thisEntry", "=", "nenu", ".", "nextElement", "(", ")", ";", "if", "(", "thisEntry", "==", "null", ")", "{", "continue", ";", "}", "String", "entryName", "=", "thisEntry", ".", "getName", "(", ")", ";", "if", "(", "entryName", "==", "null", "||", "entryName", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "continue", ";", "}", "grpList", ".", "add", "(", "LdapHelper", ".", "prepareDN", "(", "entryName", ",", "searchBase", ")", ")", ";", "}", "}", "return", "grpList", ";", "}" ]
Get the groups that contain the specified DN as its member. @param dn @return @throws WIMException
[ "Get", "the", "groups", "that", "contain", "the", "specified", "DN", "as", "its", "member", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L3171-L3192
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
LdapAdapter.updateGroupMember
private void updateGroupMember(String oldDN, String newDN) throws WIMException { if (!iLdapConfigMgr.updateGroupMembership()) { return; } String filter = iLdapConfigMgr.getGroupMemberFilter(oldDN); String[] mbrAttrs = iLdapConfigMgr.getMemberAttributes(); Map<String, ModificationItem[]> mbrAttrMap = new HashMap<String, ModificationItem[]>(mbrAttrs.length); for (int i = 0; i < mbrAttrs.length; i++) { String mbrAttr = mbrAttrs[i]; ModificationItem removeAttr = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, new BasicAttribute(mbrAttr, oldDN)); ModificationItem[] modifAttrs = null; if (newDN != null) { ModificationItem addAttr = new ModificationItem(DirContext.ADD_ATTRIBUTE, new BasicAttribute(mbrAttr, newDN)); modifAttrs = new ModificationItem[2]; modifAttrs[0] = addAttr; modifAttrs[1] = removeAttr; } else { modifAttrs = new ModificationItem[1]; modifAttrs[0] = removeAttr; } mbrAttrMap.put(mbrAttr.toLowerCase(), modifAttrs); } String[] searchBases = iLdapConfigMgr.getGroupSearchBases(); for (int i = 0; i < searchBases.length; i++) { String searchBase = searchBases[i]; NamingEnumeration<SearchResult> nenu = iLdapConn.search(searchBase, filter, SearchControls.SUBTREE_SCOPE, LDAP_ATTR_OBJECTCLASS_ARRAY); while (nenu.hasMoreElements()) { SearchResult thisEntry = nenu.nextElement(); if (thisEntry == null) { continue; } String entryName = thisEntry.getName(); if (entryName == null || entryName.trim().length() == 0) { continue; } String DN = LdapHelper.prepareDN(entryName, searchBase); Attributes attrs = thisEntry.getAttributes(); String[] thisMbrAttrs = iLdapConfigMgr.getMemberAttribute(attrs.get(LDAP_ATTR_OBJECTCLASS)); if (thisMbrAttrs != null) { for (int j = 0; j < thisMbrAttrs.length; j++) { ModificationItem[] attrsTobeModify = mbrAttrMap.get(thisMbrAttrs[j].toLowerCase()); if (attrsTobeModify != null) { try { iLdapConn.modifyAttributes(DN, attrsTobeModify); } catch (Exception e) { if (tc.isDebugEnabled()) { Tr.debug(tc, "Updating group " + DN + " for " + oldDN + " failed due to: " + e.toString()); } } } } } } } }
java
private void updateGroupMember(String oldDN, String newDN) throws WIMException { if (!iLdapConfigMgr.updateGroupMembership()) { return; } String filter = iLdapConfigMgr.getGroupMemberFilter(oldDN); String[] mbrAttrs = iLdapConfigMgr.getMemberAttributes(); Map<String, ModificationItem[]> mbrAttrMap = new HashMap<String, ModificationItem[]>(mbrAttrs.length); for (int i = 0; i < mbrAttrs.length; i++) { String mbrAttr = mbrAttrs[i]; ModificationItem removeAttr = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, new BasicAttribute(mbrAttr, oldDN)); ModificationItem[] modifAttrs = null; if (newDN != null) { ModificationItem addAttr = new ModificationItem(DirContext.ADD_ATTRIBUTE, new BasicAttribute(mbrAttr, newDN)); modifAttrs = new ModificationItem[2]; modifAttrs[0] = addAttr; modifAttrs[1] = removeAttr; } else { modifAttrs = new ModificationItem[1]; modifAttrs[0] = removeAttr; } mbrAttrMap.put(mbrAttr.toLowerCase(), modifAttrs); } String[] searchBases = iLdapConfigMgr.getGroupSearchBases(); for (int i = 0; i < searchBases.length; i++) { String searchBase = searchBases[i]; NamingEnumeration<SearchResult> nenu = iLdapConn.search(searchBase, filter, SearchControls.SUBTREE_SCOPE, LDAP_ATTR_OBJECTCLASS_ARRAY); while (nenu.hasMoreElements()) { SearchResult thisEntry = nenu.nextElement(); if (thisEntry == null) { continue; } String entryName = thisEntry.getName(); if (entryName == null || entryName.trim().length() == 0) { continue; } String DN = LdapHelper.prepareDN(entryName, searchBase); Attributes attrs = thisEntry.getAttributes(); String[] thisMbrAttrs = iLdapConfigMgr.getMemberAttribute(attrs.get(LDAP_ATTR_OBJECTCLASS)); if (thisMbrAttrs != null) { for (int j = 0; j < thisMbrAttrs.length; j++) { ModificationItem[] attrsTobeModify = mbrAttrMap.get(thisMbrAttrs[j].toLowerCase()); if (attrsTobeModify != null) { try { iLdapConn.modifyAttributes(DN, attrsTobeModify); } catch (Exception e) { if (tc.isDebugEnabled()) { Tr.debug(tc, "Updating group " + DN + " for " + oldDN + " failed due to: " + e.toString()); } } } } } } } }
[ "private", "void", "updateGroupMember", "(", "String", "oldDN", ",", "String", "newDN", ")", "throws", "WIMException", "{", "if", "(", "!", "iLdapConfigMgr", ".", "updateGroupMembership", "(", ")", ")", "{", "return", ";", "}", "String", "filter", "=", "iLdapConfigMgr", ".", "getGroupMemberFilter", "(", "oldDN", ")", ";", "String", "[", "]", "mbrAttrs", "=", "iLdapConfigMgr", ".", "getMemberAttributes", "(", ")", ";", "Map", "<", "String", ",", "ModificationItem", "[", "]", ">", "mbrAttrMap", "=", "new", "HashMap", "<", "String", ",", "ModificationItem", "[", "]", ">", "(", "mbrAttrs", ".", "length", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mbrAttrs", ".", "length", ";", "i", "++", ")", "{", "String", "mbrAttr", "=", "mbrAttrs", "[", "i", "]", ";", "ModificationItem", "removeAttr", "=", "new", "ModificationItem", "(", "DirContext", ".", "REMOVE_ATTRIBUTE", ",", "new", "BasicAttribute", "(", "mbrAttr", ",", "oldDN", ")", ")", ";", "ModificationItem", "[", "]", "modifAttrs", "=", "null", ";", "if", "(", "newDN", "!=", "null", ")", "{", "ModificationItem", "addAttr", "=", "new", "ModificationItem", "(", "DirContext", ".", "ADD_ATTRIBUTE", ",", "new", "BasicAttribute", "(", "mbrAttr", ",", "newDN", ")", ")", ";", "modifAttrs", "=", "new", "ModificationItem", "[", "2", "]", ";", "modifAttrs", "[", "0", "]", "=", "addAttr", ";", "modifAttrs", "[", "1", "]", "=", "removeAttr", ";", "}", "else", "{", "modifAttrs", "=", "new", "ModificationItem", "[", "1", "]", ";", "modifAttrs", "[", "0", "]", "=", "removeAttr", ";", "}", "mbrAttrMap", ".", "put", "(", "mbrAttr", ".", "toLowerCase", "(", ")", ",", "modifAttrs", ")", ";", "}", "String", "[", "]", "searchBases", "=", "iLdapConfigMgr", ".", "getGroupSearchBases", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "searchBases", ".", "length", ";", "i", "++", ")", "{", "String", "searchBase", "=", "searchBases", "[", "i", "]", ";", "NamingEnumeration", "<", "SearchResult", ">", "nenu", "=", "iLdapConn", ".", "search", "(", "searchBase", ",", "filter", ",", "SearchControls", ".", "SUBTREE_SCOPE", ",", "LDAP_ATTR_OBJECTCLASS_ARRAY", ")", ";", "while", "(", "nenu", ".", "hasMoreElements", "(", ")", ")", "{", "SearchResult", "thisEntry", "=", "nenu", ".", "nextElement", "(", ")", ";", "if", "(", "thisEntry", "==", "null", ")", "{", "continue", ";", "}", "String", "entryName", "=", "thisEntry", ".", "getName", "(", ")", ";", "if", "(", "entryName", "==", "null", "||", "entryName", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "continue", ";", "}", "String", "DN", "=", "LdapHelper", ".", "prepareDN", "(", "entryName", ",", "searchBase", ")", ";", "Attributes", "attrs", "=", "thisEntry", ".", "getAttributes", "(", ")", ";", "String", "[", "]", "thisMbrAttrs", "=", "iLdapConfigMgr", ".", "getMemberAttribute", "(", "attrs", ".", "get", "(", "LDAP_ATTR_OBJECTCLASS", ")", ")", ";", "if", "(", "thisMbrAttrs", "!=", "null", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "thisMbrAttrs", ".", "length", ";", "j", "++", ")", "{", "ModificationItem", "[", "]", "attrsTobeModify", "=", "mbrAttrMap", ".", "get", "(", "thisMbrAttrs", "[", "j", "]", ".", "toLowerCase", "(", ")", ")", ";", "if", "(", "attrsTobeModify", "!=", "null", ")", "{", "try", "{", "iLdapConn", ".", "modifyAttributes", "(", "DN", ",", "attrsTobeModify", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "if", "(", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "Tr", ".", "debug", "(", "tc", ",", "\"Updating group \"", "+", "DN", "+", "\" for \"", "+", "oldDN", "+", "\" failed due to: \"", "+", "e", ".", "toString", "(", ")", ")", ";", "}", "}", "}", "}", "}", "}", "}", "}" ]
Update the Group member @param oldDN @param newDN @throws WIMException
[ "Update", "the", "Group", "member" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L3201-L3256
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.audit.reader/src/com/ibm/ws/security/audit/reader/tasks/HelpTask.java
HelpTask.getTask
private AuditUtilityTask getTask(String taskName) { AuditUtilityTask task = null; for (AuditUtilityTask availTask : tasks) { if (availTask.getTaskName().equals(taskName)) { task = availTask; } } return task; }
java
private AuditUtilityTask getTask(String taskName) { AuditUtilityTask task = null; for (AuditUtilityTask availTask : tasks) { if (availTask.getTaskName().equals(taskName)) { task = availTask; } } return task; }
[ "private", "AuditUtilityTask", "getTask", "(", "String", "taskName", ")", "{", "AuditUtilityTask", "task", "=", "null", ";", "for", "(", "AuditUtilityTask", "availTask", ":", "tasks", ")", "{", "if", "(", "availTask", ".", "getTaskName", "(", ")", ".", "equals", "(", "taskName", ")", ")", "{", "task", "=", "availTask", ";", "}", "}", "return", "task", ";", "}" ]
Given a task name, return the corresponding AuditUtilityTask. @param taskName desired task name @return corresponding AuditUtilityTask, or null if no match is found
[ "Given", "a", "task", "name", "return", "the", "corresponding", "AuditUtilityTask", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.audit.reader/src/com/ibm/ws/security/audit/reader/tasks/HelpTask.java#L137-L145
train
OpenLiberty/open-liberty
dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/matchspace/selector/impl/LiteralImpl.java
LiteralImpl.objectType
static int objectType(Object value) { if (value instanceof String) return STRING; else if (value instanceof Boolean) // was BooleanValue return BOOLEAN; else if (value instanceof Number) //was NumericValue // NumericValue types are ordered INT..DOUBLE starting at zero. Selector types are // ordered INT..DOUBLE starting at Selector.INT. return EvaluatorImpl.getType((Number) value) + Selector.INT; // was ((NumericValue) value).type() else if (value instanceof Serializable) return OBJECT; else return INVALID; }
java
static int objectType(Object value) { if (value instanceof String) return STRING; else if (value instanceof Boolean) // was BooleanValue return BOOLEAN; else if (value instanceof Number) //was NumericValue // NumericValue types are ordered INT..DOUBLE starting at zero. Selector types are // ordered INT..DOUBLE starting at Selector.INT. return EvaluatorImpl.getType((Number) value) + Selector.INT; // was ((NumericValue) value).type() else if (value instanceof Serializable) return OBJECT; else return INVALID; }
[ "static", "int", "objectType", "(", "Object", "value", ")", "{", "if", "(", "value", "instanceof", "String", ")", "return", "STRING", ";", "else", "if", "(", "value", "instanceof", "Boolean", ")", "// was BooleanValue", "return", "BOOLEAN", ";", "else", "if", "(", "value", "instanceof", "Number", ")", "//was NumericValue", "// NumericValue types are ordered INT..DOUBLE starting at zero. Selector types are", "// ordered INT..DOUBLE starting at Selector.INT.", "return", "EvaluatorImpl", ".", "getType", "(", "(", "Number", ")", "value", ")", "+", "Selector", ".", "INT", ";", "// was ((NumericValue) value).type()", "else", "if", "(", "value", "instanceof", "Serializable", ")", "return", "OBJECT", ";", "else", "return", "INVALID", ";", "}" ]
Determine Selector type code of a Literal value according to its class. Used by the Literal constructor and by the Evaluator @param value the value whose type is requested @return one of the available literal type codes or Selector.INVALID
[ "Determine", "Selector", "type", "code", "of", "a", "Literal", "value", "according", "to", "its", "class", ".", "Used", "by", "the", "Literal", "constructor", "and", "by", "the", "Evaluator" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/matchspace/selector/impl/LiteralImpl.java#L40-L53
train
OpenLiberty/open-liberty
dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/osgi/response/IResponseImpl.java
IResponseImpl.convertHttpCookie
private Cookie convertHttpCookie(HttpCookie cookie) { Cookie rc = new Cookie(cookie.getName(), cookie.getValue()); rc.setVersion(cookie.getVersion()); if (null != cookie.getPath()) { rc.setPath(cookie.getPath()); } if (null != cookie.getDomain()) { rc.setDomain(cookie.getDomain()); } rc.setMaxAge(cookie.getMaxAge()); rc.setSecure(cookie.isSecure()); return rc; }
java
private Cookie convertHttpCookie(HttpCookie cookie) { Cookie rc = new Cookie(cookie.getName(), cookie.getValue()); rc.setVersion(cookie.getVersion()); if (null != cookie.getPath()) { rc.setPath(cookie.getPath()); } if (null != cookie.getDomain()) { rc.setDomain(cookie.getDomain()); } rc.setMaxAge(cookie.getMaxAge()); rc.setSecure(cookie.isSecure()); return rc; }
[ "private", "Cookie", "convertHttpCookie", "(", "HttpCookie", "cookie", ")", "{", "Cookie", "rc", "=", "new", "Cookie", "(", "cookie", ".", "getName", "(", ")", ",", "cookie", ".", "getValue", "(", ")", ")", ";", "rc", ".", "setVersion", "(", "cookie", ".", "getVersion", "(", ")", ")", ";", "if", "(", "null", "!=", "cookie", ".", "getPath", "(", ")", ")", "{", "rc", ".", "setPath", "(", "cookie", ".", "getPath", "(", ")", ")", ";", "}", "if", "(", "null", "!=", "cookie", ".", "getDomain", "(", ")", ")", "{", "rc", ".", "setDomain", "(", "cookie", ".", "getDomain", "(", ")", ")", ";", "}", "rc", ".", "setMaxAge", "(", "cookie", ".", "getMaxAge", "(", ")", ")", ";", "rc", ".", "setSecure", "(", "cookie", ".", "isSecure", "(", ")", ")", ";", "return", "rc", ";", "}" ]
Convert the transport cookie to a J2EE cookie. @param cookie @return Cookie
[ "Convert", "the", "transport", "cookie", "to", "a", "J2EE", "cookie", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/osgi/response/IResponseImpl.java#L289-L304
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/view/JspViewDeclarationLanguageBase.java
JspViewDeclarationLanguageBase.getResponseSwitch
private static ResponseSwitch getResponseSwitch(Object response) { // unwrap the response until we find a ResponseSwitch while (response != null) { if (response instanceof ResponseSwitch) { // found return (ResponseSwitch) response; } if (response instanceof ServletResponseWrapper) { // unwrap response = ((ServletResponseWrapper) response).getResponse(); } // no more possibilities to find a ResponseSwitch break; } return null; // not found }
java
private static ResponseSwitch getResponseSwitch(Object response) { // unwrap the response until we find a ResponseSwitch while (response != null) { if (response instanceof ResponseSwitch) { // found return (ResponseSwitch) response; } if (response instanceof ServletResponseWrapper) { // unwrap response = ((ServletResponseWrapper) response).getResponse(); } // no more possibilities to find a ResponseSwitch break; } return null; // not found }
[ "private", "static", "ResponseSwitch", "getResponseSwitch", "(", "Object", "response", ")", "{", "// unwrap the response until we find a ResponseSwitch", "while", "(", "response", "!=", "null", ")", "{", "if", "(", "response", "instanceof", "ResponseSwitch", ")", "{", "// found", "return", "(", "ResponseSwitch", ")", "response", ";", "}", "if", "(", "response", "instanceof", "ServletResponseWrapper", ")", "{", "// unwrap", "response", "=", "(", "(", "ServletResponseWrapper", ")", "response", ")", ".", "getResponse", "(", ")", ";", "}", "// no more possibilities to find a ResponseSwitch", "break", ";", "}", "return", "null", ";", "// not found", "}" ]
Trys to obtain a ResponseSwitch from the Response. @param response @return if found, the ResponseSwitch, null otherwise
[ "Trys", "to", "obtain", "a", "ResponseSwitch", "from", "the", "Response", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/view/JspViewDeclarationLanguageBase.java#L412-L431
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/view/JspViewDeclarationLanguageBase.java
JspViewDeclarationLanguageBase.createResponseSwitch
private static ResponseSwitch createResponseSwitch(Object response) { if (response instanceof HttpServletResponse) { return new HttpServletResponseSwitch((HttpServletResponse) response); } else if (response instanceof ServletResponse) { return new ServletResponseSwitch((ServletResponse) response); } return null; }
java
private static ResponseSwitch createResponseSwitch(Object response) { if (response instanceof HttpServletResponse) { return new HttpServletResponseSwitch((HttpServletResponse) response); } else if (response instanceof ServletResponse) { return new ServletResponseSwitch((ServletResponse) response); } return null; }
[ "private", "static", "ResponseSwitch", "createResponseSwitch", "(", "Object", "response", ")", "{", "if", "(", "response", "instanceof", "HttpServletResponse", ")", "{", "return", "new", "HttpServletResponseSwitch", "(", "(", "HttpServletResponse", ")", "response", ")", ";", "}", "else", "if", "(", "response", "instanceof", "ServletResponse", ")", "{", "return", "new", "ServletResponseSwitch", "(", "(", "ServletResponse", ")", "response", ")", ";", "}", "return", "null", ";", "}" ]
Try to create a ResponseSwitch for this response. @param response @return the created ResponseSwitch, if there is a ResponseSwitch implementation for the given response, null otherwise
[ "Try", "to", "create", "a", "ResponseSwitch", "for", "this", "response", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/view/JspViewDeclarationLanguageBase.java#L439-L450
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.core/src/com/ibm/ws/security/wim/ServiceProvider.java
ServiceProvider.updateFederatedManagerService
private void updateFederatedManagerService() { if (!activated) { return; } if (profileManager.getReference() != null) { Tr.info(tc, "FEDERATED_MANAGER_SERVICE_READY"); } else { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "Some required federated manager services are not available."); } } }
java
private void updateFederatedManagerService() { if (!activated) { return; } if (profileManager.getReference() != null) { Tr.info(tc, "FEDERATED_MANAGER_SERVICE_READY"); } else { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "Some required federated manager services are not available."); } } }
[ "private", "void", "updateFederatedManagerService", "(", ")", "{", "if", "(", "!", "activated", ")", "{", "return", ";", "}", "if", "(", "profileManager", ".", "getReference", "(", ")", "!=", "null", ")", "{", "Tr", ".", "info", "(", "tc", ",", "\"FEDERATED_MANAGER_SERVICE_READY\"", ")", ";", "}", "else", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "Tr", ".", "debug", "(", "tc", ",", "\"Some required federated manager services are not available.\"", ")", ";", "}", "}", "}" ]
Federated Manager is ready when all of these required services have been registered.
[ "Federated", "Manager", "is", "ready", "when", "all", "of", "these", "required", "services", "have", "been", "registered", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.core/src/com/ibm/ws/security/wim/ServiceProvider.java#L76-L88
train
OpenLiberty/open-liberty
dev/com.ibm.ws.ssl/src/com/ibm/ws/ssl/config/SSLConfigManager.java
SSLConfigManager.parseSSLConfig
private SSLConfig parseSSLConfig(Map<String, Object> properties, boolean reinitialize) throws Exception { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.entry(tc, "parseSSLConfig: " + properties.get(LibertyConstants.KEY_ID), properties); SSLConfig rc = parseSecureSocketLayer(properties, reinitialize); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "parseSSLConfig"); return rc; }
java
private SSLConfig parseSSLConfig(Map<String, Object> properties, boolean reinitialize) throws Exception { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.entry(tc, "parseSSLConfig: " + properties.get(LibertyConstants.KEY_ID), properties); SSLConfig rc = parseSecureSocketLayer(properties, reinitialize); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "parseSSLConfig"); return rc; }
[ "private", "SSLConfig", "parseSSLConfig", "(", "Map", "<", "String", ",", "Object", ">", "properties", ",", "boolean", "reinitialize", ")", "throws", "Exception", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "entry", "(", "tc", ",", "\"parseSSLConfig: \"", "+", "properties", ".", "get", "(", "LibertyConstants", ".", "KEY_ID", ")", ",", "properties", ")", ";", "SSLConfig", "rc", "=", "parseSecureSocketLayer", "(", "properties", ",", "reinitialize", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "exit", "(", "tc", ",", "\"parseSSLConfig\"", ")", ";", "return", "rc", ";", "}" ]
Helper method to build the SSLConfig properties from the SSLConfig model object.
[ "Helper", "method", "to", "build", "the", "SSLConfig", "properties", "from", "the", "SSLConfig", "model", "object", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ssl/src/com/ibm/ws/ssl/config/SSLConfigManager.java#L314-L323
train
OpenLiberty/open-liberty
dev/com.ibm.ws.ssl/src/com/ibm/ws/ssl/config/SSLConfigManager.java
SSLConfigManager.getSSLConfig
public synchronized SSLConfig getSSLConfig(String alias) throws IllegalArgumentException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.entry(tc, "getSSLConfig: " + alias); SSLConfig rc = null; if (alias == null || alias.equals("")) { rc = getDefaultSSLConfig(); } else { // sslConfigMap is not yet populated!!! rc = sslConfigMap.get(alias); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getSSLConfig", rc); return rc; }
java
public synchronized SSLConfig getSSLConfig(String alias) throws IllegalArgumentException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.entry(tc, "getSSLConfig: " + alias); SSLConfig rc = null; if (alias == null || alias.equals("")) { rc = getDefaultSSLConfig(); } else { // sslConfigMap is not yet populated!!! rc = sslConfigMap.get(alias); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getSSLConfig", rc); return rc; }
[ "public", "synchronized", "SSLConfig", "getSSLConfig", "(", "String", "alias", ")", "throws", "IllegalArgumentException", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "entry", "(", "tc", ",", "\"getSSLConfig: \"", "+", "alias", ")", ";", "SSLConfig", "rc", "=", "null", ";", "if", "(", "alias", "==", "null", "||", "alias", ".", "equals", "(", "\"\"", ")", ")", "{", "rc", "=", "getDefaultSSLConfig", "(", ")", ";", "}", "else", "{", "// sslConfigMap is not yet populated!!!", "rc", "=", "sslConfigMap", ".", "get", "(", "alias", ")", ";", "}", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "exit", "(", "tc", ",", "\"getSSLConfig\"", ",", "rc", ")", ";", "return", "rc", ";", "}" ]
Finds an SSLConfig from the Map given an alias. @param alias @return SSLConfig @throws IllegalArgumentException
[ "Finds", "an", "SSLConfig", "from", "the", "Map", "given", "an", "alias", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ssl/src/com/ibm/ws/ssl/config/SSLConfigManager.java#L595-L610
train
OpenLiberty/open-liberty
dev/com.ibm.ws.ssl/src/com/ibm/ws/ssl/config/SSLConfigManager.java
SSLConfigManager.loadGlobalProperties
public synchronized void loadGlobalProperties(Map<String, Object> map) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.entry(tc, "loadGlobalProperties"); // clear before reloading. globalConfigProperties.clear(); for (Entry<String, Object> prop : map.entrySet()) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "Setting global property: " + prop.getKey() + "=" + prop.getValue()); } globalConfigProperties.setProperty(prop.getKey(), (String) prop.getValue()); } // Check for dynamic outbound and default config conflicts String outboundDefaultAlias = getGlobalProperty(LibertyConstants.SSLPROP_OUTBOUND_DEFAULT_ALIAS); if (outboundDefaultAlias != null && isTransportSecurityEnabled()) outboundSSL.checkDefaultConflict(); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "loadGlobalProperties"); }
java
public synchronized void loadGlobalProperties(Map<String, Object> map) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.entry(tc, "loadGlobalProperties"); // clear before reloading. globalConfigProperties.clear(); for (Entry<String, Object> prop : map.entrySet()) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "Setting global property: " + prop.getKey() + "=" + prop.getValue()); } globalConfigProperties.setProperty(prop.getKey(), (String) prop.getValue()); } // Check for dynamic outbound and default config conflicts String outboundDefaultAlias = getGlobalProperty(LibertyConstants.SSLPROP_OUTBOUND_DEFAULT_ALIAS); if (outboundDefaultAlias != null && isTransportSecurityEnabled()) outboundSSL.checkDefaultConflict(); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "loadGlobalProperties"); }
[ "public", "synchronized", "void", "loadGlobalProperties", "(", "Map", "<", "String", ",", "Object", ">", "map", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "entry", "(", "tc", ",", "\"loadGlobalProperties\"", ")", ";", "// clear before reloading.", "globalConfigProperties", ".", "clear", "(", ")", ";", "for", "(", "Entry", "<", "String", ",", "Object", ">", "prop", ":", "map", ".", "entrySet", "(", ")", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "Tr", ".", "debug", "(", "tc", ",", "\"Setting global property: \"", "+", "prop", ".", "getKey", "(", ")", "+", "\"=\"", "+", "prop", ".", "getValue", "(", ")", ")", ";", "}", "globalConfigProperties", ".", "setProperty", "(", "prop", ".", "getKey", "(", ")", ",", "(", "String", ")", "prop", ".", "getValue", "(", ")", ")", ";", "}", "// Check for dynamic outbound and default config conflicts", "String", "outboundDefaultAlias", "=", "getGlobalProperty", "(", "LibertyConstants", ".", "SSLPROP_OUTBOUND_DEFAULT_ALIAS", ")", ";", "if", "(", "outboundDefaultAlias", "!=", "null", "&&", "isTransportSecurityEnabled", "(", ")", ")", "outboundSSL", ".", "checkDefaultConflict", "(", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "exit", "(", "tc", ",", "\"loadGlobalProperties\"", ")", ";", "}" ]
Helper method for loading global properties. @param map
[ "Helper", "method", "for", "loading", "global", "properties", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ssl/src/com/ibm/ws/ssl/config/SSLConfigManager.java#L617-L638
train
OpenLiberty/open-liberty
dev/com.ibm.ws.couchdb/src/com/ibm/ws/couchdb/internal/CouchDbService.java
CouchDbService.set
@Trivial private void set(Class<?> builderCls, Object builder, String propName, Object value) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { try { Class<?> cls = COUCHDB_CLIENT_OPTIONS_TYPES.get(propName); // setter methods are just propName, not setPropName. Method method = builderCls.getMethod(propName, cls); // even though we told the config service that some of these props are Integers, they // get converted to longs. Need // to convert them back to int so that our .invoke(..) method doesn't blow up. if (cls.equals(int.class) && value instanceof Long) { value = ((Long) value).intValue(); } if (propName.equals("password")) { SerializableProtectedString password = (SerializableProtectedString) value; String pwdStr = password == null ? null : String.valueOf(password.getChars()); value = PasswordUtil.getCryptoAlgorithm(pwdStr) == null ? pwdStr : PasswordUtil.decode(pwdStr); } method.invoke(builder, value); return; } catch (Throwable x) { if (x instanceof InvocationTargetException) x = x.getCause(); IllegalArgumentException failure = ignoreWarnOrFail(x, IllegalArgumentException.class, "CWKKD0010.prop.error", propName, COUCHDB, id, x); if (failure != null) { FFDCFilter.processException(failure, getClass().getName(), "394", this, new Object[] { value == null ? null : value.getClass(), value }); throw failure; } } }
java
@Trivial private void set(Class<?> builderCls, Object builder, String propName, Object value) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { try { Class<?> cls = COUCHDB_CLIENT_OPTIONS_TYPES.get(propName); // setter methods are just propName, not setPropName. Method method = builderCls.getMethod(propName, cls); // even though we told the config service that some of these props are Integers, they // get converted to longs. Need // to convert them back to int so that our .invoke(..) method doesn't blow up. if (cls.equals(int.class) && value instanceof Long) { value = ((Long) value).intValue(); } if (propName.equals("password")) { SerializableProtectedString password = (SerializableProtectedString) value; String pwdStr = password == null ? null : String.valueOf(password.getChars()); value = PasswordUtil.getCryptoAlgorithm(pwdStr) == null ? pwdStr : PasswordUtil.decode(pwdStr); } method.invoke(builder, value); return; } catch (Throwable x) { if (x instanceof InvocationTargetException) x = x.getCause(); IllegalArgumentException failure = ignoreWarnOrFail(x, IllegalArgumentException.class, "CWKKD0010.prop.error", propName, COUCHDB, id, x); if (failure != null) { FFDCFilter.processException(failure, getClass().getName(), "394", this, new Object[] { value == null ? null : value.getClass(), value }); throw failure; } } }
[ "@", "Trivial", "private", "void", "set", "(", "Class", "<", "?", ">", "builderCls", ",", "Object", "builder", ",", "String", "propName", ",", "Object", "value", ")", "throws", "IntrospectionException", ",", "IllegalArgumentException", ",", "IllegalAccessException", ",", "InvocationTargetException", "{", "try", "{", "Class", "<", "?", ">", "cls", "=", "COUCHDB_CLIENT_OPTIONS_TYPES", ".", "get", "(", "propName", ")", ";", "// setter methods are just propName, not setPropName.", "Method", "method", "=", "builderCls", ".", "getMethod", "(", "propName", ",", "cls", ")", ";", "// even though we told the config service that some of these props are Integers, they", "// get converted to longs. Need", "// to convert them back to int so that our .invoke(..) method doesn't blow up.", "if", "(", "cls", ".", "equals", "(", "int", ".", "class", ")", "&&", "value", "instanceof", "Long", ")", "{", "value", "=", "(", "(", "Long", ")", "value", ")", ".", "intValue", "(", ")", ";", "}", "if", "(", "propName", ".", "equals", "(", "\"password\"", ")", ")", "{", "SerializableProtectedString", "password", "=", "(", "SerializableProtectedString", ")", "value", ";", "String", "pwdStr", "=", "password", "==", "null", "?", "null", ":", "String", ".", "valueOf", "(", "password", ".", "getChars", "(", ")", ")", ";", "value", "=", "PasswordUtil", ".", "getCryptoAlgorithm", "(", "pwdStr", ")", "==", "null", "?", "pwdStr", ":", "PasswordUtil", ".", "decode", "(", "pwdStr", ")", ";", "}", "method", ".", "invoke", "(", "builder", ",", "value", ")", ";", "return", ";", "}", "catch", "(", "Throwable", "x", ")", "{", "if", "(", "x", "instanceof", "InvocationTargetException", ")", "x", "=", "x", ".", "getCause", "(", ")", ";", "IllegalArgumentException", "failure", "=", "ignoreWarnOrFail", "(", "x", ",", "IllegalArgumentException", ".", "class", ",", "\"CWKKD0010.prop.error\"", ",", "propName", ",", "COUCHDB", ",", "id", ",", "x", ")", ";", "if", "(", "failure", "!=", "null", ")", "{", "FFDCFilter", ".", "processException", "(", "failure", ",", "getClass", "(", ")", ".", "getName", "(", ")", ",", "\"394\"", ",", "this", ",", "new", "Object", "[", "]", "{", "value", "==", "null", "?", "null", ":", "value", ".", "getClass", "(", ")", ",", "value", "}", ")", ";", "throw", "failure", ";", "}", "}", "}" ]
Configure a couchdb option. @param builder class org.ektorp.http.StdHttpClient$Builder @param builder instance org.ektorp.http.StdHttpClient$Builder @param propName name of the config property @param value value of the config property.
[ "Configure", "a", "couchdb", "option", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.couchdb/src/com/ibm/ws/couchdb/internal/CouchDbService.java#L229-L262
train
OpenLiberty/open-liberty
dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/osgi/container/config/WebAppConfiguratorHelper.java
WebAppConfiguratorHelper.configureJMSConnectionFactories
private void configureJMSConnectionFactories(List<JMSConnectionFactory> jmsConnFactories) { Map<String, ConfigItem<JMSConnectionFactory>> jmsCfConfigItemMap = configurator.getConfigItemMap(JNDIEnvironmentRefType.JMSConnectionFactory.getXMLElementName()); for (JMSConnectionFactory jmsConnFactory : jmsConnFactories) { String name = jmsConnFactory.getName(); if (name == null) { continue; } ConfigItem<JMSConnectionFactory> existedCF = jmsCfConfigItemMap.get(name); if (existedCF == null) { jmsCfConfigItemMap.put(name, createConfigItem(jmsConnFactory, JMS_CF_COMPARATOR)); webAppConfiguration.addRef(JNDIEnvironmentRefType.JMSConnectionFactory, jmsConnFactory); } else { if (existedCF.getSource() == ConfigSource.WEB_XML && configurator.getConfigSource() == ConfigSource.WEB_FRAGMENT) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "{0}.{1} with value {2} is configured in web.xml, the value {3} from web-fragment.xml in {4} is ignored", JNDIEnvironmentRefType.JMSConnectionFactory.getXMLElementName(), "name", existedCF.getValue(), name, configurator.getLibraryURI()); } } else if (existedCF.getSource() == ConfigSource.WEB_FRAGMENT && configurator.getConfigSource() == ConfigSource.WEB_FRAGMENT && !existedCF.compareValue(jmsConnFactory)) { configurator.addErrorMessage(nls.getFormattedMessage("CONFLICT_JMS_CONNECTION_FACTORY_REFERENCE_BETWEEN_WEB_FRAGMENT_XML", new Object[] { name, existedCF.getLibraryURI(), this.configurator.getLibraryURI() }, "Two "+JNDIEnvironmentRefType.JMSConnectionFactory.getXMLElementName()+" configurations with the same name {0} found in the web-fragment.xml of {1} and {2}.")); } } } }
java
private void configureJMSConnectionFactories(List<JMSConnectionFactory> jmsConnFactories) { Map<String, ConfigItem<JMSConnectionFactory>> jmsCfConfigItemMap = configurator.getConfigItemMap(JNDIEnvironmentRefType.JMSConnectionFactory.getXMLElementName()); for (JMSConnectionFactory jmsConnFactory : jmsConnFactories) { String name = jmsConnFactory.getName(); if (name == null) { continue; } ConfigItem<JMSConnectionFactory> existedCF = jmsCfConfigItemMap.get(name); if (existedCF == null) { jmsCfConfigItemMap.put(name, createConfigItem(jmsConnFactory, JMS_CF_COMPARATOR)); webAppConfiguration.addRef(JNDIEnvironmentRefType.JMSConnectionFactory, jmsConnFactory); } else { if (existedCF.getSource() == ConfigSource.WEB_XML && configurator.getConfigSource() == ConfigSource.WEB_FRAGMENT) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "{0}.{1} with value {2} is configured in web.xml, the value {3} from web-fragment.xml in {4} is ignored", JNDIEnvironmentRefType.JMSConnectionFactory.getXMLElementName(), "name", existedCF.getValue(), name, configurator.getLibraryURI()); } } else if (existedCF.getSource() == ConfigSource.WEB_FRAGMENT && configurator.getConfigSource() == ConfigSource.WEB_FRAGMENT && !existedCF.compareValue(jmsConnFactory)) { configurator.addErrorMessage(nls.getFormattedMessage("CONFLICT_JMS_CONNECTION_FACTORY_REFERENCE_BETWEEN_WEB_FRAGMENT_XML", new Object[] { name, existedCF.getLibraryURI(), this.configurator.getLibraryURI() }, "Two "+JNDIEnvironmentRefType.JMSConnectionFactory.getXMLElementName()+" configurations with the same name {0} found in the web-fragment.xml of {1} and {2}.")); } } } }
[ "private", "void", "configureJMSConnectionFactories", "(", "List", "<", "JMSConnectionFactory", ">", "jmsConnFactories", ")", "{", "Map", "<", "String", ",", "ConfigItem", "<", "JMSConnectionFactory", ">", ">", "jmsCfConfigItemMap", "=", "configurator", ".", "getConfigItemMap", "(", "JNDIEnvironmentRefType", ".", "JMSConnectionFactory", ".", "getXMLElementName", "(", ")", ")", ";", "for", "(", "JMSConnectionFactory", "jmsConnFactory", ":", "jmsConnFactories", ")", "{", "String", "name", "=", "jmsConnFactory", ".", "getName", "(", ")", ";", "if", "(", "name", "==", "null", ")", "{", "continue", ";", "}", "ConfigItem", "<", "JMSConnectionFactory", ">", "existedCF", "=", "jmsCfConfigItemMap", ".", "get", "(", "name", ")", ";", "if", "(", "existedCF", "==", "null", ")", "{", "jmsCfConfigItemMap", ".", "put", "(", "name", ",", "createConfigItem", "(", "jmsConnFactory", ",", "JMS_CF_COMPARATOR", ")", ")", ";", "webAppConfiguration", ".", "addRef", "(", "JNDIEnvironmentRefType", ".", "JMSConnectionFactory", ",", "jmsConnFactory", ")", ";", "}", "else", "{", "if", "(", "existedCF", ".", "getSource", "(", ")", "==", "ConfigSource", ".", "WEB_XML", "&&", "configurator", ".", "getConfigSource", "(", ")", "==", "ConfigSource", ".", "WEB_FRAGMENT", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "Tr", ".", "debug", "(", "tc", ",", "\"{0}.{1} with value {2} is configured in web.xml, the value {3} from web-fragment.xml in {4} is ignored\"", ",", "JNDIEnvironmentRefType", ".", "JMSConnectionFactory", ".", "getXMLElementName", "(", ")", ",", "\"name\"", ",", "existedCF", ".", "getValue", "(", ")", ",", "name", ",", "configurator", ".", "getLibraryURI", "(", ")", ")", ";", "}", "}", "else", "if", "(", "existedCF", ".", "getSource", "(", ")", "==", "ConfigSource", ".", "WEB_FRAGMENT", "&&", "configurator", ".", "getConfigSource", "(", ")", "==", "ConfigSource", ".", "WEB_FRAGMENT", "&&", "!", "existedCF", ".", "compareValue", "(", "jmsConnFactory", ")", ")", "{", "configurator", ".", "addErrorMessage", "(", "nls", ".", "getFormattedMessage", "(", "\"CONFLICT_JMS_CONNECTION_FACTORY_REFERENCE_BETWEEN_WEB_FRAGMENT_XML\"", ",", "new", "Object", "[", "]", "{", "name", ",", "existedCF", ".", "getLibraryURI", "(", ")", ",", "this", ".", "configurator", ".", "getLibraryURI", "(", ")", "}", ",", "\"Two \"", "+", "JNDIEnvironmentRefType", ".", "JMSConnectionFactory", ".", "getXMLElementName", "(", ")", "+", "\" configurations with the same name {0} found in the web-fragment.xml of {1} and {2}.\"", ")", ")", ";", "}", "}", "}", "}" ]
To configure JMS ConnectionFactory @param jmsConnFactories
[ "To", "configure", "JMS", "ConnectionFactory" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/osgi/container/config/WebAppConfiguratorHelper.java#L1420-L1449
train
OpenLiberty/open-liberty
dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/osgi/container/config/WebAppConfiguratorHelper.java
WebAppConfiguratorHelper.configureJMSDestinations
private void configureJMSDestinations(List<JMSDestination> jmsDestinations) { Map<String, ConfigItem<JMSDestination>> jmsDestinationConfigItemMap = configurator.getConfigItemMap(JNDIEnvironmentRefType.JMSConnectionFactory.getXMLElementName()); for (JMSDestination jmsDestination : jmsDestinations) { String name = jmsDestination.getName(); if (name == null) { continue; } ConfigItem<JMSDestination> existedCF = jmsDestinationConfigItemMap.get(name); if (existedCF == null) { jmsDestinationConfigItemMap.put(name, createConfigItem(jmsDestination, JMS_DESTINATION_COMPARATOR)); webAppConfiguration.addRef(JNDIEnvironmentRefType.JMSDestination, jmsDestination); } else { if (existedCF.getSource() == ConfigSource.WEB_XML && configurator.getConfigSource() == ConfigSource.WEB_FRAGMENT) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "{0}.{1} with value {2} is configured in web.xml, the value {3} from web-fragment.xml in {4} is ignored", JNDIEnvironmentRefType.JMSConnectionFactory.getXMLElementName(), "name", existedCF.getValue(), name, configurator.getLibraryURI()); } } else if (existedCF.getSource() == ConfigSource.WEB_FRAGMENT && configurator.getConfigSource() == ConfigSource.WEB_FRAGMENT && !existedCF.compareValue(jmsDestination)) { configurator.addErrorMessage(nls.getFormattedMessage("CONFLICT_JMS_DESTINATION_REFERENCE_BETWEEN_WEB_FRAGMENT_XML", new Object[] { name, existedCF.getLibraryURI(), this.configurator.getLibraryURI() }, "Two "+JNDIEnvironmentRefType.JMSConnectionFactory.getXMLElementName()+" configurations with the same name {0} found in the web-fragment.xml of {1} and {2}.")); } } } }
java
private void configureJMSDestinations(List<JMSDestination> jmsDestinations) { Map<String, ConfigItem<JMSDestination>> jmsDestinationConfigItemMap = configurator.getConfigItemMap(JNDIEnvironmentRefType.JMSConnectionFactory.getXMLElementName()); for (JMSDestination jmsDestination : jmsDestinations) { String name = jmsDestination.getName(); if (name == null) { continue; } ConfigItem<JMSDestination> existedCF = jmsDestinationConfigItemMap.get(name); if (existedCF == null) { jmsDestinationConfigItemMap.put(name, createConfigItem(jmsDestination, JMS_DESTINATION_COMPARATOR)); webAppConfiguration.addRef(JNDIEnvironmentRefType.JMSDestination, jmsDestination); } else { if (existedCF.getSource() == ConfigSource.WEB_XML && configurator.getConfigSource() == ConfigSource.WEB_FRAGMENT) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "{0}.{1} with value {2} is configured in web.xml, the value {3} from web-fragment.xml in {4} is ignored", JNDIEnvironmentRefType.JMSConnectionFactory.getXMLElementName(), "name", existedCF.getValue(), name, configurator.getLibraryURI()); } } else if (existedCF.getSource() == ConfigSource.WEB_FRAGMENT && configurator.getConfigSource() == ConfigSource.WEB_FRAGMENT && !existedCF.compareValue(jmsDestination)) { configurator.addErrorMessage(nls.getFormattedMessage("CONFLICT_JMS_DESTINATION_REFERENCE_BETWEEN_WEB_FRAGMENT_XML", new Object[] { name, existedCF.getLibraryURI(), this.configurator.getLibraryURI() }, "Two "+JNDIEnvironmentRefType.JMSConnectionFactory.getXMLElementName()+" configurations with the same name {0} found in the web-fragment.xml of {1} and {2}.")); } } } }
[ "private", "void", "configureJMSDestinations", "(", "List", "<", "JMSDestination", ">", "jmsDestinations", ")", "{", "Map", "<", "String", ",", "ConfigItem", "<", "JMSDestination", ">", ">", "jmsDestinationConfigItemMap", "=", "configurator", ".", "getConfigItemMap", "(", "JNDIEnvironmentRefType", ".", "JMSConnectionFactory", ".", "getXMLElementName", "(", ")", ")", ";", "for", "(", "JMSDestination", "jmsDestination", ":", "jmsDestinations", ")", "{", "String", "name", "=", "jmsDestination", ".", "getName", "(", ")", ";", "if", "(", "name", "==", "null", ")", "{", "continue", ";", "}", "ConfigItem", "<", "JMSDestination", ">", "existedCF", "=", "jmsDestinationConfigItemMap", ".", "get", "(", "name", ")", ";", "if", "(", "existedCF", "==", "null", ")", "{", "jmsDestinationConfigItemMap", ".", "put", "(", "name", ",", "createConfigItem", "(", "jmsDestination", ",", "JMS_DESTINATION_COMPARATOR", ")", ")", ";", "webAppConfiguration", ".", "addRef", "(", "JNDIEnvironmentRefType", ".", "JMSDestination", ",", "jmsDestination", ")", ";", "}", "else", "{", "if", "(", "existedCF", ".", "getSource", "(", ")", "==", "ConfigSource", ".", "WEB_XML", "&&", "configurator", ".", "getConfigSource", "(", ")", "==", "ConfigSource", ".", "WEB_FRAGMENT", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "Tr", ".", "debug", "(", "tc", ",", "\"{0}.{1} with value {2} is configured in web.xml, the value {3} from web-fragment.xml in {4} is ignored\"", ",", "JNDIEnvironmentRefType", ".", "JMSConnectionFactory", ".", "getXMLElementName", "(", ")", ",", "\"name\"", ",", "existedCF", ".", "getValue", "(", ")", ",", "name", ",", "configurator", ".", "getLibraryURI", "(", ")", ")", ";", "}", "}", "else", "if", "(", "existedCF", ".", "getSource", "(", ")", "==", "ConfigSource", ".", "WEB_FRAGMENT", "&&", "configurator", ".", "getConfigSource", "(", ")", "==", "ConfigSource", ".", "WEB_FRAGMENT", "&&", "!", "existedCF", ".", "compareValue", "(", "jmsDestination", ")", ")", "{", "configurator", ".", "addErrorMessage", "(", "nls", ".", "getFormattedMessage", "(", "\"CONFLICT_JMS_DESTINATION_REFERENCE_BETWEEN_WEB_FRAGMENT_XML\"", ",", "new", "Object", "[", "]", "{", "name", ",", "existedCF", ".", "getLibraryURI", "(", ")", ",", "this", ".", "configurator", ".", "getLibraryURI", "(", ")", "}", ",", "\"Two \"", "+", "JNDIEnvironmentRefType", ".", "JMSConnectionFactory", ".", "getXMLElementName", "(", ")", "+", "\" configurations with the same name {0} found in the web-fragment.xml of {1} and {2}.\"", ")", ")", ";", "}", "}", "}", "}" ]
To configure JMS Destinations @param jmsDestinations
[ "To", "configure", "JMS", "Destinations" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/osgi/container/config/WebAppConfiguratorHelper.java#L1455-L1483
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/ExternalContextUtils.java
ExternalContextUtils.getRequestType
public static final RequestType getRequestType(ExternalContext externalContext) { //Stuff is laid out strangely in this class in order to optimize //performance. We want to do as few instanceof's as possible so //things are laid out according to the expected frequency of the //various requests occurring. if(_PORTLET_10_SUPPORTED || _PORTLET_20_SUPPORTED) { if (_PORTLET_CONTEXT_CLASS.isInstance(externalContext.getContext())) { //We are inside of a portlet container Object request = externalContext.getRequest(); if(_PORTLET_RENDER_REQUEST_CLASS.isInstance(request)) { return RequestType.RENDER; } if(_PORTLET_RESOURCE_REQUEST_CLASS != null) { if(_PORTLET_ACTION_REQUEST_CLASS.isInstance(request)) { return RequestType.ACTION; } //We are in a JSR-286 container if(_PORTLET_RESOURCE_REQUEST_CLASS.isInstance(request)) { return RequestType.RESOURCE; } return RequestType.EVENT; } return RequestType.ACTION; } } return RequestType.SERVLET; }
java
public static final RequestType getRequestType(ExternalContext externalContext) { //Stuff is laid out strangely in this class in order to optimize //performance. We want to do as few instanceof's as possible so //things are laid out according to the expected frequency of the //various requests occurring. if(_PORTLET_10_SUPPORTED || _PORTLET_20_SUPPORTED) { if (_PORTLET_CONTEXT_CLASS.isInstance(externalContext.getContext())) { //We are inside of a portlet container Object request = externalContext.getRequest(); if(_PORTLET_RENDER_REQUEST_CLASS.isInstance(request)) { return RequestType.RENDER; } if(_PORTLET_RESOURCE_REQUEST_CLASS != null) { if(_PORTLET_ACTION_REQUEST_CLASS.isInstance(request)) { return RequestType.ACTION; } //We are in a JSR-286 container if(_PORTLET_RESOURCE_REQUEST_CLASS.isInstance(request)) { return RequestType.RESOURCE; } return RequestType.EVENT; } return RequestType.ACTION; } } return RequestType.SERVLET; }
[ "public", "static", "final", "RequestType", "getRequestType", "(", "ExternalContext", "externalContext", ")", "{", "//Stuff is laid out strangely in this class in order to optimize", "//performance. We want to do as few instanceof's as possible so", "//things are laid out according to the expected frequency of the", "//various requests occurring.", "if", "(", "_PORTLET_10_SUPPORTED", "||", "_PORTLET_20_SUPPORTED", ")", "{", "if", "(", "_PORTLET_CONTEXT_CLASS", ".", "isInstance", "(", "externalContext", ".", "getContext", "(", ")", ")", ")", "{", "//We are inside of a portlet container", "Object", "request", "=", "externalContext", ".", "getRequest", "(", ")", ";", "if", "(", "_PORTLET_RENDER_REQUEST_CLASS", ".", "isInstance", "(", "request", ")", ")", "{", "return", "RequestType", ".", "RENDER", ";", "}", "if", "(", "_PORTLET_RESOURCE_REQUEST_CLASS", "!=", "null", ")", "{", "if", "(", "_PORTLET_ACTION_REQUEST_CLASS", ".", "isInstance", "(", "request", ")", ")", "{", "return", "RequestType", ".", "ACTION", ";", "}", "//We are in a JSR-286 container", "if", "(", "_PORTLET_RESOURCE_REQUEST_CLASS", ".", "isInstance", "(", "request", ")", ")", "{", "return", "RequestType", ".", "RESOURCE", ";", "}", "return", "RequestType", ".", "EVENT", ";", "}", "return", "RequestType", ".", "ACTION", ";", "}", "}", "return", "RequestType", ".", "SERVLET", ";", "}" ]
Returns the requestType of this ExternalContext. @param externalContext the current external context @return the appropriate RequestType for this external context @see RequestType
[ "Returns", "the", "requestType", "of", "this", "ExternalContext", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/ExternalContextUtils.java#L119-L158
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/ExternalContextUtils.java
ExternalContextUtils.getRequestType
public static final RequestType getRequestType(Object context, Object request) { //Stuff is laid out strangely in this class in order to optimize //performance. We want to do as few instanceof's as possible so //things are laid out according to the expected frequency of the //various requests occurring. if(_PORTLET_10_SUPPORTED || _PORTLET_20_SUPPORTED) { if (_PORTLET_CONFIG_CLASS.isInstance(context) || _PORTLET_CONTEXT_CLASS.isInstance(context)) { //We are inside of a portlet container if(_PORTLET_RENDER_REQUEST_CLASS.isInstance(request)) { return RequestType.RENDER; } if(_PORTLET_RESOURCE_REQUEST_CLASS != null) { if(_PORTLET_ACTION_REQUEST_CLASS.isInstance(request)) { return RequestType.ACTION; } //We are in a JSR-286 container if(_PORTLET_RESOURCE_REQUEST_CLASS.isInstance(request)) { return RequestType.RESOURCE; } return RequestType.EVENT; } return RequestType.ACTION; } } return RequestType.SERVLET; }
java
public static final RequestType getRequestType(Object context, Object request) { //Stuff is laid out strangely in this class in order to optimize //performance. We want to do as few instanceof's as possible so //things are laid out according to the expected frequency of the //various requests occurring. if(_PORTLET_10_SUPPORTED || _PORTLET_20_SUPPORTED) { if (_PORTLET_CONFIG_CLASS.isInstance(context) || _PORTLET_CONTEXT_CLASS.isInstance(context)) { //We are inside of a portlet container if(_PORTLET_RENDER_REQUEST_CLASS.isInstance(request)) { return RequestType.RENDER; } if(_PORTLET_RESOURCE_REQUEST_CLASS != null) { if(_PORTLET_ACTION_REQUEST_CLASS.isInstance(request)) { return RequestType.ACTION; } //We are in a JSR-286 container if(_PORTLET_RESOURCE_REQUEST_CLASS.isInstance(request)) { return RequestType.RESOURCE; } return RequestType.EVENT; } return RequestType.ACTION; } } return RequestType.SERVLET; }
[ "public", "static", "final", "RequestType", "getRequestType", "(", "Object", "context", ",", "Object", "request", ")", "{", "//Stuff is laid out strangely in this class in order to optimize", "//performance. We want to do as few instanceof's as possible so", "//things are laid out according to the expected frequency of the", "//various requests occurring.", "if", "(", "_PORTLET_10_SUPPORTED", "||", "_PORTLET_20_SUPPORTED", ")", "{", "if", "(", "_PORTLET_CONFIG_CLASS", ".", "isInstance", "(", "context", ")", "||", "_PORTLET_CONTEXT_CLASS", ".", "isInstance", "(", "context", ")", ")", "{", "//We are inside of a portlet container", "if", "(", "_PORTLET_RENDER_REQUEST_CLASS", ".", "isInstance", "(", "request", ")", ")", "{", "return", "RequestType", ".", "RENDER", ";", "}", "if", "(", "_PORTLET_RESOURCE_REQUEST_CLASS", "!=", "null", ")", "{", "if", "(", "_PORTLET_ACTION_REQUEST_CLASS", ".", "isInstance", "(", "request", ")", ")", "{", "return", "RequestType", ".", "ACTION", ";", "}", "//We are in a JSR-286 container", "if", "(", "_PORTLET_RESOURCE_REQUEST_CLASS", ".", "isInstance", "(", "request", ")", ")", "{", "return", "RequestType", ".", "RESOURCE", ";", "}", "return", "RequestType", ".", "EVENT", ";", "}", "return", "RequestType", ".", "ACTION", ";", "}", "}", "return", "RequestType", ".", "SERVLET", ";", "}" ]
This method is used when a ExternalContext object is not available, like in TomahawkFacesContextFactory. According to TOMAHAWK-1331, the object context could receive an instance of javax.portlet.PortletContext or javax.portlet.PortletConfig, so we check both cases. @param context @param request @return
[ "This", "method", "is", "used", "when", "a", "ExternalContext", "object", "is", "not", "available", "like", "in", "TomahawkFacesContextFactory", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/ExternalContextUtils.java#L172-L212
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/ExternalContextUtils.java
ExternalContextUtils.getRequestInputStream
public static InputStream getRequestInputStream(ExternalContext ec) throws IOException { RequestType type = getRequestType(ec); if (type.isRequestFromClient()) { Object req = ec.getRequest(); if (type.isPortlet()) { return (InputStream) _runMethod(req, "getPortletInputStream"); } else { return ((ServletRequest) ec.getRequest()).getInputStream(); } } return null; }
java
public static InputStream getRequestInputStream(ExternalContext ec) throws IOException { RequestType type = getRequestType(ec); if (type.isRequestFromClient()) { Object req = ec.getRequest(); if (type.isPortlet()) { return (InputStream) _runMethod(req, "getPortletInputStream"); } else { return ((ServletRequest) ec.getRequest()).getInputStream(); } } return null; }
[ "public", "static", "InputStream", "getRequestInputStream", "(", "ExternalContext", "ec", ")", "throws", "IOException", "{", "RequestType", "type", "=", "getRequestType", "(", "ec", ")", ";", "if", "(", "type", ".", "isRequestFromClient", "(", ")", ")", "{", "Object", "req", "=", "ec", ".", "getRequest", "(", ")", ";", "if", "(", "type", ".", "isPortlet", "(", ")", ")", "{", "return", "(", "InputStream", ")", "_runMethod", "(", "req", ",", "\"getPortletInputStream\"", ")", ";", "}", "else", "{", "return", "(", "(", "ServletRequest", ")", "ec", ".", "getRequest", "(", ")", ")", ".", "getInputStream", "(", ")", ";", "}", "}", "return", "null", ";", "}" ]
Returns the request input stream if one is available @param ec the current external context @return the request's input stream @throws IOException if there was a problem getting the input stream
[ "Returns", "the", "request", "input", "stream", "if", "one", "is", "available" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/ExternalContextUtils.java#L436-L454
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/ExternalContextUtils.java
ExternalContextUtils._runMethod
private static Object _runMethod(Object obj, String methodName) { try { Method sessionIdMethod = obj.getClass().getMethod(methodName); return sessionIdMethod.invoke(obj); } catch (Exception e) { return null; } }
java
private static Object _runMethod(Object obj, String methodName) { try { Method sessionIdMethod = obj.getClass().getMethod(methodName); return sessionIdMethod.invoke(obj); } catch (Exception e) { return null; } }
[ "private", "static", "Object", "_runMethod", "(", "Object", "obj", ",", "String", "methodName", ")", "{", "try", "{", "Method", "sessionIdMethod", "=", "obj", ".", "getClass", "(", ")", ".", "getMethod", "(", "methodName", ")", ";", "return", "sessionIdMethod", ".", "invoke", "(", "obj", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "null", ";", "}", "}" ]
Runs a method on an object and returns the result @param obj the object to run the method on @param methodName the name of the method @return the results of the method run
[ "Runs", "a", "method", "on", "an", "object", "and", "returns", "the", "result" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/ExternalContextUtils.java#L579-L591
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/ExternalContextUtils.java
ExternalContextUtils.getHttpServletResponse
public static HttpServletResponse getHttpServletResponse(Object response) { // unwrap the response until we find a HttpServletResponse while (response != null) { if (response instanceof HttpServletResponse) { // found return (HttpServletResponse) response; } if (response instanceof ServletResponseWrapper) { // unwrap response = ((ServletResponseWrapper) response).getResponse(); } // no more possibilities to find a HttpServletResponse break; } return null; // not found }
java
public static HttpServletResponse getHttpServletResponse(Object response) { // unwrap the response until we find a HttpServletResponse while (response != null) { if (response instanceof HttpServletResponse) { // found return (HttpServletResponse) response; } if (response instanceof ServletResponseWrapper) { // unwrap response = ((ServletResponseWrapper) response).getResponse(); } // no more possibilities to find a HttpServletResponse break; } return null; // not found }
[ "public", "static", "HttpServletResponse", "getHttpServletResponse", "(", "Object", "response", ")", "{", "// unwrap the response until we find a HttpServletResponse", "while", "(", "response", "!=", "null", ")", "{", "if", "(", "response", "instanceof", "HttpServletResponse", ")", "{", "// found", "return", "(", "HttpServletResponse", ")", "response", ";", "}", "if", "(", "response", "instanceof", "ServletResponseWrapper", ")", "{", "// unwrap", "response", "=", "(", "(", "ServletResponseWrapper", ")", "response", ")", ".", "getResponse", "(", ")", ";", "}", "// no more possibilities to find a HttpServletResponse", "break", ";", "}", "return", "null", ";", "// not found", "}" ]
Trys to obtain a HttpServletResponse from the Response. Note that this method also trys to unwrap any ServletResponseWrapper in order to retrieve a valid HttpServletResponse. @param response @return if found, the HttpServletResponse, null otherwise
[ "Trys", "to", "obtain", "a", "HttpServletResponse", "from", "the", "Response", ".", "Note", "that", "this", "method", "also", "trys", "to", "unwrap", "any", "ServletResponseWrapper", "in", "order", "to", "retrieve", "a", "valid", "HttpServletResponse", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/ExternalContextUtils.java#L711-L730
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jsp/src/com/ibm/ws/jsp/translator/document/SymbolTable.java
SymbolTable.addSymbol
public String addSymbol(String symbol) { // search for identical symbol int bucket = hash(symbol) % fTableSize; int length = symbol.length(); OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) { if (length == entry.characters.length) { for (int i = 0; i < length; i++) { if (symbol.charAt(i) != entry.characters[i]) { continue OUTER; } } return entry.symbol; } } // create new entry Entry entry = new Entry(symbol, fBuckets[bucket]); fBuckets[bucket] = entry; return entry.symbol; }
java
public String addSymbol(String symbol) { // search for identical symbol int bucket = hash(symbol) % fTableSize; int length = symbol.length(); OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) { if (length == entry.characters.length) { for (int i = 0; i < length; i++) { if (symbol.charAt(i) != entry.characters[i]) { continue OUTER; } } return entry.symbol; } } // create new entry Entry entry = new Entry(symbol, fBuckets[bucket]); fBuckets[bucket] = entry; return entry.symbol; }
[ "public", "String", "addSymbol", "(", "String", "symbol", ")", "{", "// search for identical symbol", "int", "bucket", "=", "hash", "(", "symbol", ")", "%", "fTableSize", ";", "int", "length", "=", "symbol", ".", "length", "(", ")", ";", "OUTER", ":", "for", "(", "Entry", "entry", "=", "fBuckets", "[", "bucket", "]", ";", "entry", "!=", "null", ";", "entry", "=", "entry", ".", "next", ")", "{", "if", "(", "length", "==", "entry", ".", "characters", ".", "length", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "if", "(", "symbol", ".", "charAt", "(", "i", ")", "!=", "entry", ".", "characters", "[", "i", "]", ")", "{", "continue", "OUTER", ";", "}", "}", "return", "entry", ".", "symbol", ";", "}", "}", "// create new entry", "Entry", "entry", "=", "new", "Entry", "(", "symbol", ",", "fBuckets", "[", "bucket", "]", ")", ";", "fBuckets", "[", "bucket", "]", "=", "entry", ";", "return", "entry", ".", "symbol", ";", "}" ]
Adds the specified symbol to the symbol table and returns a reference to the unique symbol. If the symbol already exists, the previous symbol reference is returned instead, in order guarantee that symbol references remain unique. @param symbol The new symbol.
[ "Adds", "the", "specified", "symbol", "to", "the", "symbol", "table", "and", "returns", "a", "reference", "to", "the", "unique", "symbol", ".", "If", "the", "symbol", "already", "exists", "the", "previous", "symbol", "reference", "is", "returned", "instead", "in", "order", "guarantee", "that", "symbol", "references", "remain", "unique", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsp/src/com/ibm/ws/jsp/translator/document/SymbolTable.java#L86-L107
train
OpenLiberty/open-liberty
dev/com.ibm.tx.core/src/com/ibm/tx/jta/impl/XARecoveryWrapper.java
XARecoveryWrapper.deserialize
static XARecoveryWrapper deserialize(byte[] serializedWrapper) { if (tc.isEntryEnabled()) Tr.entry(tc, "deserialize"); XARecoveryWrapper wrapper = null; try { final ByteArrayInputStream bis = new ByteArrayInputStream(serializedWrapper); final ObjectInputStream oin = new ObjectInputStream(bis); wrapper = (XARecoveryWrapper) oin.readObject(); oin.close(); } catch (ClassNotFoundException e) { FFDCFilter.processException(e, "com.ibm.ws.Transaction.JTA.XARecoveryWrapper.deserialize", "298"); if (tc.isDebugEnabled()) Tr.debug(tc, "Unable to deserialize an object from byte stream", e); String notfound = e.getMessage (); final int index = notfound.indexOf (":"); notfound = notfound.substring (index + 1); Tr.error(tc, "WTRN0002_UNABLE_TO_FIND_RESOURCE_CLASS", notfound); } catch (Throwable t) { FFDCFilter.processException(t, "com.ibm.ws.Transaction.JTA.XARecoveryWrapper.deserialize", "306"); if (tc.isDebugEnabled()) Tr.debug(tc, "Unable to deserialize an object from byte stream", t); Tr.error(tc, "WTRN0040_OBJECT_DESERIALIZE_FAILED", t); } if (tc.isEntryEnabled()) Tr.exit(tc, "deserialize", wrapper); return wrapper; }
java
static XARecoveryWrapper deserialize(byte[] serializedWrapper) { if (tc.isEntryEnabled()) Tr.entry(tc, "deserialize"); XARecoveryWrapper wrapper = null; try { final ByteArrayInputStream bis = new ByteArrayInputStream(serializedWrapper); final ObjectInputStream oin = new ObjectInputStream(bis); wrapper = (XARecoveryWrapper) oin.readObject(); oin.close(); } catch (ClassNotFoundException e) { FFDCFilter.processException(e, "com.ibm.ws.Transaction.JTA.XARecoveryWrapper.deserialize", "298"); if (tc.isDebugEnabled()) Tr.debug(tc, "Unable to deserialize an object from byte stream", e); String notfound = e.getMessage (); final int index = notfound.indexOf (":"); notfound = notfound.substring (index + 1); Tr.error(tc, "WTRN0002_UNABLE_TO_FIND_RESOURCE_CLASS", notfound); } catch (Throwable t) { FFDCFilter.processException(t, "com.ibm.ws.Transaction.JTA.XARecoveryWrapper.deserialize", "306"); if (tc.isDebugEnabled()) Tr.debug(tc, "Unable to deserialize an object from byte stream", t); Tr.error(tc, "WTRN0040_OBJECT_DESERIALIZE_FAILED", t); } if (tc.isEntryEnabled()) Tr.exit(tc, "deserialize", wrapper); return wrapper; }
[ "static", "XARecoveryWrapper", "deserialize", "(", "byte", "[", "]", "serializedWrapper", ")", "{", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "entry", "(", "tc", ",", "\"deserialize\"", ")", ";", "XARecoveryWrapper", "wrapper", "=", "null", ";", "try", "{", "final", "ByteArrayInputStream", "bis", "=", "new", "ByteArrayInputStream", "(", "serializedWrapper", ")", ";", "final", "ObjectInputStream", "oin", "=", "new", "ObjectInputStream", "(", "bis", ")", ";", "wrapper", "=", "(", "XARecoveryWrapper", ")", "oin", ".", "readObject", "(", ")", ";", "oin", ".", "close", "(", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "FFDCFilter", ".", "processException", "(", "e", ",", "\"com.ibm.ws.Transaction.JTA.XARecoveryWrapper.deserialize\"", ",", "\"298\"", ")", ";", "if", "(", "tc", ".", "isDebugEnabled", "(", ")", ")", "Tr", ".", "debug", "(", "tc", ",", "\"Unable to deserialize an object from byte stream\"", ",", "e", ")", ";", "String", "notfound", "=", "e", ".", "getMessage", "(", ")", ";", "final", "int", "index", "=", "notfound", ".", "indexOf", "(", "\":\"", ")", ";", "notfound", "=", "notfound", ".", "substring", "(", "index", "+", "1", ")", ";", "Tr", ".", "error", "(", "tc", ",", "\"WTRN0002_UNABLE_TO_FIND_RESOURCE_CLASS\"", ",", "notfound", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "FFDCFilter", ".", "processException", "(", "t", ",", "\"com.ibm.ws.Transaction.JTA.XARecoveryWrapper.deserialize\"", ",", "\"306\"", ")", ";", "if", "(", "tc", ".", "isDebugEnabled", "(", ")", ")", "Tr", ".", "debug", "(", "tc", ",", "\"Unable to deserialize an object from byte stream\"", ",", "t", ")", ";", "Tr", ".", "error", "(", "tc", ",", "\"WTRN0040_OBJECT_DESERIALIZE_FAILED\"", ",", "t", ")", ";", "}", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "exit", "(", "tc", ",", "\"deserialize\"", ",", "wrapper", ")", ";", "return", "wrapper", ";", "}" ]
which classloader is passed in and which is on the thread.
[ "which", "classloader", "is", "passed", "in", "and", "which", "is", "on", "the", "thread", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.tx.core/src/com/ibm/tx/jta/impl/XARecoveryWrapper.java#L288-L319
train
OpenLiberty/open-liberty
dev/com.ibm.tx.core/src/com/ibm/tx/jta/impl/XARecoveryWrapper.java
XARecoveryWrapper.canonicalise
private String[] canonicalise(final String[] xaResInfoClasspath) { if (tc.isEntryEnabled()) Tr.entry(tc, "canonicalise", xaResInfoClasspath); final String[] result; if(xaResInfoClasspath != null) { final ArrayList<String> al = new ArrayList<String>(); for (final String pathElement : xaResInfoClasspath) { if(pathElement != null) { String cp; try { cp = (String)TMHelper.runAsSystem(new PrivilegedExceptionAction<String>() { public String run() throws Exception { String path = (new File(pathElement)).getCanonicalPath(); //@D656080A if (!(new File(path)).exists()) path = null; //@D656080A return path; //@D656080C } } ); } catch(Throwable t) { FFDCFilter.processException(t, "com.ibm.ws.Transaction.JTA.XARecoveryWrapper.canonicalise", "512", this); // can't do much else than .... cp = pathElement; } if (cp != null) al.add(cp); // @D656080C } } if (al.size() > 0) // @D656080A { // @D656080A result = al.toArray(new String[al.size()]); } // @D656080A else // @D656080A { // @D656080A result = null; // @D656080A } // @D656080A } else { result = null; } if (tc.isEntryEnabled()) Tr.exit(tc, "canonicalise", result); return result; }
java
private String[] canonicalise(final String[] xaResInfoClasspath) { if (tc.isEntryEnabled()) Tr.entry(tc, "canonicalise", xaResInfoClasspath); final String[] result; if(xaResInfoClasspath != null) { final ArrayList<String> al = new ArrayList<String>(); for (final String pathElement : xaResInfoClasspath) { if(pathElement != null) { String cp; try { cp = (String)TMHelper.runAsSystem(new PrivilegedExceptionAction<String>() { public String run() throws Exception { String path = (new File(pathElement)).getCanonicalPath(); //@D656080A if (!(new File(path)).exists()) path = null; //@D656080A return path; //@D656080C } } ); } catch(Throwable t) { FFDCFilter.processException(t, "com.ibm.ws.Transaction.JTA.XARecoveryWrapper.canonicalise", "512", this); // can't do much else than .... cp = pathElement; } if (cp != null) al.add(cp); // @D656080C } } if (al.size() > 0) // @D656080A { // @D656080A result = al.toArray(new String[al.size()]); } // @D656080A else // @D656080A { // @D656080A result = null; // @D656080A } // @D656080A } else { result = null; } if (tc.isEntryEnabled()) Tr.exit(tc, "canonicalise", result); return result; }
[ "private", "String", "[", "]", "canonicalise", "(", "final", "String", "[", "]", "xaResInfoClasspath", ")", "{", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "entry", "(", "tc", ",", "\"canonicalise\"", ",", "xaResInfoClasspath", ")", ";", "final", "String", "[", "]", "result", ";", "if", "(", "xaResInfoClasspath", "!=", "null", ")", "{", "final", "ArrayList", "<", "String", ">", "al", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "final", "String", "pathElement", ":", "xaResInfoClasspath", ")", "{", "if", "(", "pathElement", "!=", "null", ")", "{", "String", "cp", ";", "try", "{", "cp", "=", "(", "String", ")", "TMHelper", ".", "runAsSystem", "(", "new", "PrivilegedExceptionAction", "<", "String", ">", "(", ")", "{", "public", "String", "run", "(", ")", "throws", "Exception", "{", "String", "path", "=", "(", "new", "File", "(", "pathElement", ")", ")", ".", "getCanonicalPath", "(", ")", ";", "//@D656080A", "if", "(", "!", "(", "new", "File", "(", "path", ")", ")", ".", "exists", "(", ")", ")", "path", "=", "null", ";", "//@D656080A", "return", "path", ";", "//@D656080C", "}", "}", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "FFDCFilter", ".", "processException", "(", "t", ",", "\"com.ibm.ws.Transaction.JTA.XARecoveryWrapper.canonicalise\"", ",", "\"512\"", ",", "this", ")", ";", "// can't do much else than ....", "cp", "=", "pathElement", ";", "}", "if", "(", "cp", "!=", "null", ")", "al", ".", "add", "(", "cp", ")", ";", "// @D656080C", "}", "}", "if", "(", "al", ".", "size", "(", ")", ">", "0", ")", "// @D656080A", "{", "// @D656080A", "result", "=", "al", ".", "toArray", "(", "new", "String", "[", "al", ".", "size", "(", ")", "]", ")", ";", "}", "// @D656080A", "else", "// @D656080A", "{", "// @D656080A", "result", "=", "null", ";", "// @D656080A", "}", "// @D656080A", "}", "else", "{", "result", "=", "null", ";", "}", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "exit", "(", "tc", ",", "\"canonicalise\"", ",", "result", ")", ";", "return", "result", ";", "}" ]
Canonicalise inbound paths so they can be compared with paths held in the classloaders @param xaResInfoClasspath @return
[ "Canonicalise", "inbound", "paths", "so", "they", "can", "be", "compared", "with", "paths", "held", "in", "the", "classloaders" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.tx.core/src/com/ibm/tx/jta/impl/XARecoveryWrapper.java#L375-L433
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/ConnectionEventListener.java
ConnectionEventListener.connectionClosed
@Override public void connectionClosed(ConnectionEvent event) { final boolean isTracingEnabled = TraceComponent.isAnyTracingEnabled(); if (isTracingEnabled && tc.isEntryEnabled()) { Tr.entry(this, tc, "connectionClosed"); } if (event.getId() == ConnectionEvent.CONNECTION_CLOSED) { if (!mcWrapper.isParkedWrapper()) { if (isTracingEnabled && tc.isDebugEnabled()) { //Tr.debug(this, tc, "Closing handle for ManagedConnection@" + Integer.toHexString(mc.hashCode()) + " from pool " + mcWrapper.gConfigProps.pmiName + " from mcWrapper " + mcWrapper.toString() + " from mc " + mc); // Omit handle info. //Tr.debug(this, tc, "***Connection Close Request*** Handle Name: " + event.getConnectionHandle().toString() + " Connection Pool: " + mcWrapper.getPoolManager().toString() + " Details: : " + mcWrapper.toString() ); // I only removed the connection handle toString, since this is the one getting the null pointer exception. // The trace component code will check for null first before calling toString on the handle. // Any new debug should not use the .toString() to prevent null pointer exceptions in trace. // Changed trace string to only dump pool manager name not entire pool. Tr.debug(this, tc, "***Connection Close Request*** Handle Name: " + event.getConnectionHandle() + " Connection Pool: " + mcWrapper.getPoolManager().getGConfigProps().getXpathId() + " Details: : " + mcWrapper); } ConnectionManager cm = mcWrapper.getConnectionManagerWithoutStateCheck(); if (cm != null && cm.handleToThreadMap != null) { cm.handleToThreadMap.clear(); } if (cm != null && cm.handleToCMDMap != null) { cm.handleToCMDMap.clear(); } if (!(mcWrapper.gConfigProps.isSmartHandleSupport() && (cm != null && cm.shareable()))) { Object conHandle = event.getConnectionHandle(); if (null == conHandle) { Tr.warning(tc, "CONNECTION_CLOSED_NULL_HANDLE_J2CA0148", event); } else { mcWrapper.removeFromHandleList(conHandle); // TODO - need to implement - Notify the CHM to stop tracking the handle because it has been closed. } } /* * Decrement the number of open connections for Managed Connection and see if * all the connections are now closed. If they are all closed and the MC is not * associated with a transaction, then return it to the pool. If all the handles * are closed and the MC is associated with a transaction, then do nothing. * The MC will be released back to the pool at the end of the transaction when * afterCompletion is called on one of the transactional wrapper objects. */ mcWrapper.decrementHandleCount(); if (mcWrapper.getHandleCount() == 0) { /* * If we are processing a NoTransaction resource, then we are essentially done with * the "transaction" when all of the connection handles are closed. We have to * perform this extra cleanup because of the dual purpose of the involvedInTransaction * method on the MCWrapper. */ if (mcWrapper.getTranWrapperId() == MCWrapper.NOTXWRAPPER) { mcWrapper.transactionComplete(); } // Deleted calling mcWrapper.transactionComplete() for RRS Local Tran /* * If the ManagedConnection is not associated with a * transaction any more, return it to the pool. */ if (!mcWrapper.involvedInTransaction()) { /* * The ManagedConnection is not associated with a transactional * context so return it to the pool. We need to check if the MC was * shareable or not. If it was shareable, then we need to extract the * coordinator from the MCWrapper and send it into releaseToPoolManager. * If it was unshareable, then we just pass null into the * releaseToPoolManager method and it releases it back to the pool. */ try { mcWrapper.releaseToPoolManager(); } catch (Exception ex) { // Nothing to do here. PoolManager has already logged it. // Since we are in cleanup mode, we will not surface a Runtime exception to the ResourceAdapter FFDCFilter.processException(ex, "com.ibm.ejs.j2c.ConnectionEventListener.connectionClosed", "197", this); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(this, tc, "connectionClosed: Closing connection in pool " + mcWrapper.gConfigProps.getXpathId() + " caught exception, but will continue processing: ", ex); } } } } } } else { // Connection Event passed in doesn't match the method called. // This should never happen unless there is an error in the ResourceAdapter. processBadEvent("connectionClosed", ConnectionEvent.CONNECTION_CLOSED, event); } if (isTracingEnabled && tc.isEntryEnabled()) { Tr.exit(this, tc, "connectionClosed"); } return; }
java
@Override public void connectionClosed(ConnectionEvent event) { final boolean isTracingEnabled = TraceComponent.isAnyTracingEnabled(); if (isTracingEnabled && tc.isEntryEnabled()) { Tr.entry(this, tc, "connectionClosed"); } if (event.getId() == ConnectionEvent.CONNECTION_CLOSED) { if (!mcWrapper.isParkedWrapper()) { if (isTracingEnabled && tc.isDebugEnabled()) { //Tr.debug(this, tc, "Closing handle for ManagedConnection@" + Integer.toHexString(mc.hashCode()) + " from pool " + mcWrapper.gConfigProps.pmiName + " from mcWrapper " + mcWrapper.toString() + " from mc " + mc); // Omit handle info. //Tr.debug(this, tc, "***Connection Close Request*** Handle Name: " + event.getConnectionHandle().toString() + " Connection Pool: " + mcWrapper.getPoolManager().toString() + " Details: : " + mcWrapper.toString() ); // I only removed the connection handle toString, since this is the one getting the null pointer exception. // The trace component code will check for null first before calling toString on the handle. // Any new debug should not use the .toString() to prevent null pointer exceptions in trace. // Changed trace string to only dump pool manager name not entire pool. Tr.debug(this, tc, "***Connection Close Request*** Handle Name: " + event.getConnectionHandle() + " Connection Pool: " + mcWrapper.getPoolManager().getGConfigProps().getXpathId() + " Details: : " + mcWrapper); } ConnectionManager cm = mcWrapper.getConnectionManagerWithoutStateCheck(); if (cm != null && cm.handleToThreadMap != null) { cm.handleToThreadMap.clear(); } if (cm != null && cm.handleToCMDMap != null) { cm.handleToCMDMap.clear(); } if (!(mcWrapper.gConfigProps.isSmartHandleSupport() && (cm != null && cm.shareable()))) { Object conHandle = event.getConnectionHandle(); if (null == conHandle) { Tr.warning(tc, "CONNECTION_CLOSED_NULL_HANDLE_J2CA0148", event); } else { mcWrapper.removeFromHandleList(conHandle); // TODO - need to implement - Notify the CHM to stop tracking the handle because it has been closed. } } /* * Decrement the number of open connections for Managed Connection and see if * all the connections are now closed. If they are all closed and the MC is not * associated with a transaction, then return it to the pool. If all the handles * are closed and the MC is associated with a transaction, then do nothing. * The MC will be released back to the pool at the end of the transaction when * afterCompletion is called on one of the transactional wrapper objects. */ mcWrapper.decrementHandleCount(); if (mcWrapper.getHandleCount() == 0) { /* * If we are processing a NoTransaction resource, then we are essentially done with * the "transaction" when all of the connection handles are closed. We have to * perform this extra cleanup because of the dual purpose of the involvedInTransaction * method on the MCWrapper. */ if (mcWrapper.getTranWrapperId() == MCWrapper.NOTXWRAPPER) { mcWrapper.transactionComplete(); } // Deleted calling mcWrapper.transactionComplete() for RRS Local Tran /* * If the ManagedConnection is not associated with a * transaction any more, return it to the pool. */ if (!mcWrapper.involvedInTransaction()) { /* * The ManagedConnection is not associated with a transactional * context so return it to the pool. We need to check if the MC was * shareable or not. If it was shareable, then we need to extract the * coordinator from the MCWrapper and send it into releaseToPoolManager. * If it was unshareable, then we just pass null into the * releaseToPoolManager method and it releases it back to the pool. */ try { mcWrapper.releaseToPoolManager(); } catch (Exception ex) { // Nothing to do here. PoolManager has already logged it. // Since we are in cleanup mode, we will not surface a Runtime exception to the ResourceAdapter FFDCFilter.processException(ex, "com.ibm.ejs.j2c.ConnectionEventListener.connectionClosed", "197", this); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(this, tc, "connectionClosed: Closing connection in pool " + mcWrapper.gConfigProps.getXpathId() + " caught exception, but will continue processing: ", ex); } } } } } } else { // Connection Event passed in doesn't match the method called. // This should never happen unless there is an error in the ResourceAdapter. processBadEvent("connectionClosed", ConnectionEvent.CONNECTION_CLOSED, event); } if (isTracingEnabled && tc.isEntryEnabled()) { Tr.exit(this, tc, "connectionClosed"); } return; }
[ "@", "Override", "public", "void", "connectionClosed", "(", "ConnectionEvent", "event", ")", "{", "final", "boolean", "isTracingEnabled", "=", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", ";", "if", "(", "isTracingEnabled", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "entry", "(", "this", ",", "tc", ",", "\"connectionClosed\"", ")", ";", "}", "if", "(", "event", ".", "getId", "(", ")", "==", "ConnectionEvent", ".", "CONNECTION_CLOSED", ")", "{", "if", "(", "!", "mcWrapper", ".", "isParkedWrapper", "(", ")", ")", "{", "if", "(", "isTracingEnabled", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "//Tr.debug(this, tc, \"Closing handle for ManagedConnection@\" + Integer.toHexString(mc.hashCode()) + \" from pool \" + mcWrapper.gConfigProps.pmiName + \" from mcWrapper \" + mcWrapper.toString() + \" from mc \" + mc);", "// Omit handle info.", "//Tr.debug(this, tc, \"***Connection Close Request*** Handle Name: \" + event.getConnectionHandle().toString() + \" Connection Pool: \" + mcWrapper.getPoolManager().toString() + \" Details: : \" + mcWrapper.toString() );", "// I only removed the connection handle toString, since this is the one getting the null pointer exception.", "// The trace component code will check for null first before calling toString on the handle.", "// Any new debug should not use the .toString() to prevent null pointer exceptions in trace.", "// Changed trace string to only dump pool manager name not entire pool.", "Tr", ".", "debug", "(", "this", ",", "tc", ",", "\"***Connection Close Request*** Handle Name: \"", "+", "event", ".", "getConnectionHandle", "(", ")", "+", "\" Connection Pool: \"", "+", "mcWrapper", ".", "getPoolManager", "(", ")", ".", "getGConfigProps", "(", ")", ".", "getXpathId", "(", ")", "+", "\" Details: : \"", "+", "mcWrapper", ")", ";", "}", "ConnectionManager", "cm", "=", "mcWrapper", ".", "getConnectionManagerWithoutStateCheck", "(", ")", ";", "if", "(", "cm", "!=", "null", "&&", "cm", ".", "handleToThreadMap", "!=", "null", ")", "{", "cm", ".", "handleToThreadMap", ".", "clear", "(", ")", ";", "}", "if", "(", "cm", "!=", "null", "&&", "cm", ".", "handleToCMDMap", "!=", "null", ")", "{", "cm", ".", "handleToCMDMap", ".", "clear", "(", ")", ";", "}", "if", "(", "!", "(", "mcWrapper", ".", "gConfigProps", ".", "isSmartHandleSupport", "(", ")", "&&", "(", "cm", "!=", "null", "&&", "cm", ".", "shareable", "(", ")", ")", ")", ")", "{", "Object", "conHandle", "=", "event", ".", "getConnectionHandle", "(", ")", ";", "if", "(", "null", "==", "conHandle", ")", "{", "Tr", ".", "warning", "(", "tc", ",", "\"CONNECTION_CLOSED_NULL_HANDLE_J2CA0148\"", ",", "event", ")", ";", "}", "else", "{", "mcWrapper", ".", "removeFromHandleList", "(", "conHandle", ")", ";", "// TODO - need to implement - Notify the CHM to stop tracking the handle because it has been closed.", "}", "}", "/*\n * Decrement the number of open connections for Managed Connection and see if\n * all the connections are now closed. If they are all closed and the MC is not\n * associated with a transaction, then return it to the pool. If all the handles\n * are closed and the MC is associated with a transaction, then do nothing.\n * The MC will be released back to the pool at the end of the transaction when\n * afterCompletion is called on one of the transactional wrapper objects.\n */", "mcWrapper", ".", "decrementHandleCount", "(", ")", ";", "if", "(", "mcWrapper", ".", "getHandleCount", "(", ")", "==", "0", ")", "{", "/*\n * If we are processing a NoTransaction resource, then we are essentially done with\n * the \"transaction\" when all of the connection handles are closed. We have to\n * perform this extra cleanup because of the dual purpose of the involvedInTransaction\n * method on the MCWrapper.\n */", "if", "(", "mcWrapper", ".", "getTranWrapperId", "(", ")", "==", "MCWrapper", ".", "NOTXWRAPPER", ")", "{", "mcWrapper", ".", "transactionComplete", "(", ")", ";", "}", "// Deleted calling mcWrapper.transactionComplete() for RRS Local Tran", "/*\n * If the ManagedConnection is not associated with a\n * transaction any more, return it to the pool.\n */", "if", "(", "!", "mcWrapper", ".", "involvedInTransaction", "(", ")", ")", "{", "/*\n * The ManagedConnection is not associated with a transactional\n * context so return it to the pool. We need to check if the MC was\n * shareable or not. If it was shareable, then we need to extract the\n * coordinator from the MCWrapper and send it into releaseToPoolManager.\n * If it was unshareable, then we just pass null into the\n * releaseToPoolManager method and it releases it back to the pool.\n */", "try", "{", "mcWrapper", ".", "releaseToPoolManager", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "// Nothing to do here. PoolManager has already logged it.", "// Since we are in cleanup mode, we will not surface a Runtime exception to the ResourceAdapter", "FFDCFilter", ".", "processException", "(", "ex", ",", "\"com.ibm.ejs.j2c.ConnectionEventListener.connectionClosed\"", ",", "\"197\"", ",", "this", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "Tr", ".", "debug", "(", "this", ",", "tc", ",", "\"connectionClosed: Closing connection in pool \"", "+", "mcWrapper", ".", "gConfigProps", ".", "getXpathId", "(", ")", "+", "\" caught exception, but will continue processing: \"", ",", "ex", ")", ";", "}", "}", "}", "}", "}", "}", "else", "{", "// Connection Event passed in doesn't match the method called.", "// This should never happen unless there is an error in the ResourceAdapter.", "processBadEvent", "(", "\"connectionClosed\"", ",", "ConnectionEvent", ".", "CONNECTION_CLOSED", ",", "event", ")", ";", "}", "if", "(", "isTracingEnabled", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "exit", "(", "this", ",", "tc", ",", "\"connectionClosed\"", ")", ";", "}", "return", ";", "}" ]
This method is called by a resource adapter when the application calls close on a Connection. @param ConnectionEvent
[ "This", "method", "is", "called", "by", "a", "resource", "adapter", "when", "the", "application", "calls", "close", "on", "a", "Connection", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/ConnectionEventListener.java#L60-L174
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/ConnectionEventListener.java
ConnectionEventListener.connectionErrorOccurred
@Override public void connectionErrorOccurred(ConnectionEvent event) { int eventID = event.getId(); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { StringBuilder entry = new StringBuilder(event.getClass().getSimpleName()).append('{'); entry.append("id=").append(event.getId()).append(", "); entry.append("source=").append(event.getSource()); entry.append('}'); if (event.getException() == null) Tr.entry(this, tc, "connectionErrorOccurred", entry.toString()); else Tr.entry(this, tc, "connectionErrorOccurred", entry.toString(), event.getException()); } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { // (ASSERT: event is not null) StringBuffer tsb = new StringBuffer(); Object connHandle = event.getConnectionHandle(); tsb.append("***Connection Error Request*** Handle Name: " + connHandle); if (mcWrapper != null) { Object poolMgr = mcWrapper.getPoolManager(); tsb.append(", Connection Pool: " + poolMgr + ", Details: " + mcWrapper); } else { tsb.append(", Details: null"); } Tr.debug(this, tc, tsb.toString()); } switch (eventID) { case ConnectionEvent.CONNECTION_ERROR_OCCURRED: { Exception tempEx = event.getException(); // Initialize tempString so the msg makes sense for the case where the event has NO associated Exception String tempString = ""; if (tempEx != null) { // If there is an associated Exception, generate tempString from that tempString = J2CUtilityClass.generateExceptionString(tempEx); Tr.audit(tc, "RA_CONNECTION_ERROR_J2CA0056", tempString, mcWrapper.gConfigProps.cfName); } else { Tr.audit(tc, "NO_RA_EXCEPTION_J2CA0216", mcWrapper.gConfigProps.cfName); } // NOTE: Moving all functional code for this to the MCWrapper as it is // closer to all the data/objects needed to perform this cleanup. mcWrapper.connectionErrorOccurred(event); break; } case com.ibm.websphere.j2c.ConnectionEvent.SINGLE_CONNECTION_ERROR_OCCURRED: { /* * 51 is the id selected for this event. * * If a resource adapter uses this Id, the connection may be * unconditionally cleaned up and destroyed. We are assuming the resource * adapter knows this connection can not be recovered. * * Existing transactions may delay destroying the connection. * * The connectionErrorOccurred method will process this request, * * Only this connection will be destroyed. */ Exception tempEx = event.getException(); // Initialize tempString so the msg makes sense for the case where the event has NO associated Exception String tempString = ""; if (tempEx != null) { // If there is an associated Exception, generate tempString from that tempString = J2CUtilityClass.generateExceptionString(tempEx); Tr.audit(tc, "RA_CONNECTION_ERROR_J2CA0056", tempString, mcWrapper.gConfigProps.cfName); } else { Tr.audit(tc, "NO_RA_EXCEPTION_J2CA0216", mcWrapper.gConfigProps.cfName); } // NOTE: Moving all functional code for this to the MCWrapper as it is // closer to all the data/objects needed to perform this cleanup. mcWrapper.connectionErrorOccurred(event); break; } case com.ibm.websphere.j2c.ConnectionEvent.CONNECTION_ERROR_OCCURRED_NO_EVENT: { // NOTE: Moving all functional code for this to the MCWrapper as it is // closer to all the data/objects needed to perform this cleanup. mcWrapper.connectionErrorOccurred(event); break; } default: { // Connection Event passed in doesn't match the method called. // This should never happen unless there is an error in the ResourceAdapter. processBadEvent("connectionErrorOccurred", ConnectionEvent.CONNECTION_ERROR_OCCURRED, event); } } // end switch if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(this, tc, "connectionErrorOccurred"); } return; }
java
@Override public void connectionErrorOccurred(ConnectionEvent event) { int eventID = event.getId(); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { StringBuilder entry = new StringBuilder(event.getClass().getSimpleName()).append('{'); entry.append("id=").append(event.getId()).append(", "); entry.append("source=").append(event.getSource()); entry.append('}'); if (event.getException() == null) Tr.entry(this, tc, "connectionErrorOccurred", entry.toString()); else Tr.entry(this, tc, "connectionErrorOccurred", entry.toString(), event.getException()); } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { // (ASSERT: event is not null) StringBuffer tsb = new StringBuffer(); Object connHandle = event.getConnectionHandle(); tsb.append("***Connection Error Request*** Handle Name: " + connHandle); if (mcWrapper != null) { Object poolMgr = mcWrapper.getPoolManager(); tsb.append(", Connection Pool: " + poolMgr + ", Details: " + mcWrapper); } else { tsb.append(", Details: null"); } Tr.debug(this, tc, tsb.toString()); } switch (eventID) { case ConnectionEvent.CONNECTION_ERROR_OCCURRED: { Exception tempEx = event.getException(); // Initialize tempString so the msg makes sense for the case where the event has NO associated Exception String tempString = ""; if (tempEx != null) { // If there is an associated Exception, generate tempString from that tempString = J2CUtilityClass.generateExceptionString(tempEx); Tr.audit(tc, "RA_CONNECTION_ERROR_J2CA0056", tempString, mcWrapper.gConfigProps.cfName); } else { Tr.audit(tc, "NO_RA_EXCEPTION_J2CA0216", mcWrapper.gConfigProps.cfName); } // NOTE: Moving all functional code for this to the MCWrapper as it is // closer to all the data/objects needed to perform this cleanup. mcWrapper.connectionErrorOccurred(event); break; } case com.ibm.websphere.j2c.ConnectionEvent.SINGLE_CONNECTION_ERROR_OCCURRED: { /* * 51 is the id selected for this event. * * If a resource adapter uses this Id, the connection may be * unconditionally cleaned up and destroyed. We are assuming the resource * adapter knows this connection can not be recovered. * * Existing transactions may delay destroying the connection. * * The connectionErrorOccurred method will process this request, * * Only this connection will be destroyed. */ Exception tempEx = event.getException(); // Initialize tempString so the msg makes sense for the case where the event has NO associated Exception String tempString = ""; if (tempEx != null) { // If there is an associated Exception, generate tempString from that tempString = J2CUtilityClass.generateExceptionString(tempEx); Tr.audit(tc, "RA_CONNECTION_ERROR_J2CA0056", tempString, mcWrapper.gConfigProps.cfName); } else { Tr.audit(tc, "NO_RA_EXCEPTION_J2CA0216", mcWrapper.gConfigProps.cfName); } // NOTE: Moving all functional code for this to the MCWrapper as it is // closer to all the data/objects needed to perform this cleanup. mcWrapper.connectionErrorOccurred(event); break; } case com.ibm.websphere.j2c.ConnectionEvent.CONNECTION_ERROR_OCCURRED_NO_EVENT: { // NOTE: Moving all functional code for this to the MCWrapper as it is // closer to all the data/objects needed to perform this cleanup. mcWrapper.connectionErrorOccurred(event); break; } default: { // Connection Event passed in doesn't match the method called. // This should never happen unless there is an error in the ResourceAdapter. processBadEvent("connectionErrorOccurred", ConnectionEvent.CONNECTION_ERROR_OCCURRED, event); } } // end switch if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(this, tc, "connectionErrorOccurred"); } return; }
[ "@", "Override", "public", "void", "connectionErrorOccurred", "(", "ConnectionEvent", "event", ")", "{", "int", "eventID", "=", "event", ".", "getId", "(", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "StringBuilder", "entry", "=", "new", "StringBuilder", "(", "event", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "entry", ".", "append", "(", "\"id=\"", ")", ".", "append", "(", "event", ".", "getId", "(", ")", ")", ".", "append", "(", "\", \"", ")", ";", "entry", ".", "append", "(", "\"source=\"", ")", ".", "append", "(", "event", ".", "getSource", "(", ")", ")", ";", "entry", ".", "append", "(", "'", "'", ")", ";", "if", "(", "event", ".", "getException", "(", ")", "==", "null", ")", "Tr", ".", "entry", "(", "this", ",", "tc", ",", "\"connectionErrorOccurred\"", ",", "entry", ".", "toString", "(", ")", ")", ";", "else", "Tr", ".", "entry", "(", "this", ",", "tc", ",", "\"connectionErrorOccurred\"", ",", "entry", ".", "toString", "(", ")", ",", "event", ".", "getException", "(", ")", ")", ";", "}", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "// (ASSERT: event is not null)", "StringBuffer", "tsb", "=", "new", "StringBuffer", "(", ")", ";", "Object", "connHandle", "=", "event", ".", "getConnectionHandle", "(", ")", ";", "tsb", ".", "append", "(", "\"***Connection Error Request*** Handle Name: \"", "+", "connHandle", ")", ";", "if", "(", "mcWrapper", "!=", "null", ")", "{", "Object", "poolMgr", "=", "mcWrapper", ".", "getPoolManager", "(", ")", ";", "tsb", ".", "append", "(", "\", Connection Pool: \"", "+", "poolMgr", "+", "\", Details: \"", "+", "mcWrapper", ")", ";", "}", "else", "{", "tsb", ".", "append", "(", "\", Details: null\"", ")", ";", "}", "Tr", ".", "debug", "(", "this", ",", "tc", ",", "tsb", ".", "toString", "(", ")", ")", ";", "}", "switch", "(", "eventID", ")", "{", "case", "ConnectionEvent", ".", "CONNECTION_ERROR_OCCURRED", ":", "{", "Exception", "tempEx", "=", "event", ".", "getException", "(", ")", ";", "// Initialize tempString so the msg makes sense for the case where the event has NO associated Exception", "String", "tempString", "=", "\"\"", ";", "if", "(", "tempEx", "!=", "null", ")", "{", "// If there is an associated Exception, generate tempString from that", "tempString", "=", "J2CUtilityClass", ".", "generateExceptionString", "(", "tempEx", ")", ";", "Tr", ".", "audit", "(", "tc", ",", "\"RA_CONNECTION_ERROR_J2CA0056\"", ",", "tempString", ",", "mcWrapper", ".", "gConfigProps", ".", "cfName", ")", ";", "}", "else", "{", "Tr", ".", "audit", "(", "tc", ",", "\"NO_RA_EXCEPTION_J2CA0216\"", ",", "mcWrapper", ".", "gConfigProps", ".", "cfName", ")", ";", "}", "// NOTE: Moving all functional code for this to the MCWrapper as it is", "// closer to all the data/objects needed to perform this cleanup.", "mcWrapper", ".", "connectionErrorOccurred", "(", "event", ")", ";", "break", ";", "}", "case", "com", ".", "ibm", ".", "websphere", ".", "j2c", ".", "ConnectionEvent", ".", "SINGLE_CONNECTION_ERROR_OCCURRED", ":", "{", "/*\n * 51 is the id selected for this event.\n *\n * If a resource adapter uses this Id, the connection may be\n * unconditionally cleaned up and destroyed. We are assuming the resource\n * adapter knows this connection can not be recovered.\n *\n * Existing transactions may delay destroying the connection.\n *\n * The connectionErrorOccurred method will process this request,\n *\n * Only this connection will be destroyed.\n */", "Exception", "tempEx", "=", "event", ".", "getException", "(", ")", ";", "// Initialize tempString so the msg makes sense for the case where the event has NO associated Exception", "String", "tempString", "=", "\"\"", ";", "if", "(", "tempEx", "!=", "null", ")", "{", "// If there is an associated Exception, generate tempString from that", "tempString", "=", "J2CUtilityClass", ".", "generateExceptionString", "(", "tempEx", ")", ";", "Tr", ".", "audit", "(", "tc", ",", "\"RA_CONNECTION_ERROR_J2CA0056\"", ",", "tempString", ",", "mcWrapper", ".", "gConfigProps", ".", "cfName", ")", ";", "}", "else", "{", "Tr", ".", "audit", "(", "tc", ",", "\"NO_RA_EXCEPTION_J2CA0216\"", ",", "mcWrapper", ".", "gConfigProps", ".", "cfName", ")", ";", "}", "// NOTE: Moving all functional code for this to the MCWrapper as it is", "// closer to all the data/objects needed to perform this cleanup.", "mcWrapper", ".", "connectionErrorOccurred", "(", "event", ")", ";", "break", ";", "}", "case", "com", ".", "ibm", ".", "websphere", ".", "j2c", ".", "ConnectionEvent", ".", "CONNECTION_ERROR_OCCURRED_NO_EVENT", ":", "{", "// NOTE: Moving all functional code for this to the MCWrapper as it is", "// closer to all the data/objects needed to perform this cleanup.", "mcWrapper", ".", "connectionErrorOccurred", "(", "event", ")", ";", "break", ";", "}", "default", ":", "{", "// Connection Event passed in doesn't match the method called.", "// This should never happen unless there is an error in the ResourceAdapter.", "processBadEvent", "(", "\"connectionErrorOccurred\"", ",", "ConnectionEvent", ".", "CONNECTION_ERROR_OCCURRED", ",", "event", ")", ";", "}", "}", "// end switch", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "exit", "(", "this", ",", "tc", ",", "\"connectionErrorOccurred\"", ")", ";", "}", "return", ";", "}" ]
This method is called by a resource adapter when a connection error occurs. This is also called internally by this class when other event handling methods fail and require cleanup. @param ConnectionEvent
[ "This", "method", "is", "called", "by", "a", "resource", "adapter", "when", "a", "connection", "error", "occurs", ".", "This", "is", "also", "called", "internally", "by", "this", "class", "when", "other", "event", "handling", "methods", "fail", "and", "require", "cleanup", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/ConnectionEventListener.java#L184-L305
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/ConnectionEventListener.java
ConnectionEventListener.localTransactionCommitted
@Override public void localTransactionCommitted(ConnectionEvent event) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(this, tc, "localTransactionCommitted"); } if (event.getId() == ConnectionEvent.LOCAL_TRANSACTION_COMMITTED) { if (mcWrapper.involvedInTransaction()) { /* * The ManagedConnection is associated with a transaction. * Delist the ManagedConnection from the transaction and * postpone release of the connection until transaction finishes. */ TranWrapper wrapper = null; try { wrapper = mcWrapper.getCurrentTranWrapper(); wrapper.delist(); } catch (ResourceException e) { // Can't delist, something went wrong. // Destroy the connection(s) so it can't cause any future problems. FFDCFilter.processException(e, "com.ibm.ejs.j2c.ConnectionEventListener.localTransactionCommitted", "316", "this"); // add datasource name to message Tr.error(tc, "DELIST_FAILED_J2CA0073", "localTransactionCommitted", e, mcWrapper.gConfigProps.cfName); // Moved event.getSource() inside of catch block for performance reasons ManagedConnection mc = null; try { mc = (ManagedConnection) event.getSource(); } catch (ClassCastException cce) { Tr.error(tc, "GET_SOURCE_CLASS_CAST_EXCP_J2CA0098", cce); throw new IllegalStateException("ClassCastException occurred attempting to cast event.getSource to ManagedConnection"); } ConnectionEvent errorEvent = new ConnectionEvent(mc, ConnectionEvent.CONNECTION_ERROR_OCCURRED); this.connectionErrorOccurred(errorEvent); RuntimeException rte = new IllegalStateException(e.getMessage()); throw rte; } } else { // if we are not involved in a transaction, then we are likely running with NO transaction // context on the thread. This case currently needs to be supported because // servlets can spin their own threads which would not have context. // Note: it is very rare that users do this. All other occurances are // considered to be an error. if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(this, tc, "localTransactionCommitted", "no transaction context, return without delisting"); } return; } } else { // Connection Event passed in doesn't match the method called. // This should never happen unless there is an error in the ResourceAdapter. processBadEvent("localTransactionCommitted", ConnectionEvent.LOCAL_TRANSACTION_COMMITTED, event); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(this, tc, "localTransactionCommitted"); } return; }
java
@Override public void localTransactionCommitted(ConnectionEvent event) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(this, tc, "localTransactionCommitted"); } if (event.getId() == ConnectionEvent.LOCAL_TRANSACTION_COMMITTED) { if (mcWrapper.involvedInTransaction()) { /* * The ManagedConnection is associated with a transaction. * Delist the ManagedConnection from the transaction and * postpone release of the connection until transaction finishes. */ TranWrapper wrapper = null; try { wrapper = mcWrapper.getCurrentTranWrapper(); wrapper.delist(); } catch (ResourceException e) { // Can't delist, something went wrong. // Destroy the connection(s) so it can't cause any future problems. FFDCFilter.processException(e, "com.ibm.ejs.j2c.ConnectionEventListener.localTransactionCommitted", "316", "this"); // add datasource name to message Tr.error(tc, "DELIST_FAILED_J2CA0073", "localTransactionCommitted", e, mcWrapper.gConfigProps.cfName); // Moved event.getSource() inside of catch block for performance reasons ManagedConnection mc = null; try { mc = (ManagedConnection) event.getSource(); } catch (ClassCastException cce) { Tr.error(tc, "GET_SOURCE_CLASS_CAST_EXCP_J2CA0098", cce); throw new IllegalStateException("ClassCastException occurred attempting to cast event.getSource to ManagedConnection"); } ConnectionEvent errorEvent = new ConnectionEvent(mc, ConnectionEvent.CONNECTION_ERROR_OCCURRED); this.connectionErrorOccurred(errorEvent); RuntimeException rte = new IllegalStateException(e.getMessage()); throw rte; } } else { // if we are not involved in a transaction, then we are likely running with NO transaction // context on the thread. This case currently needs to be supported because // servlets can spin their own threads which would not have context. // Note: it is very rare that users do this. All other occurances are // considered to be an error. if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(this, tc, "localTransactionCommitted", "no transaction context, return without delisting"); } return; } } else { // Connection Event passed in doesn't match the method called. // This should never happen unless there is an error in the ResourceAdapter. processBadEvent("localTransactionCommitted", ConnectionEvent.LOCAL_TRANSACTION_COMMITTED, event); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(this, tc, "localTransactionCommitted"); } return; }
[ "@", "Override", "public", "void", "localTransactionCommitted", "(", "ConnectionEvent", "event", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "entry", "(", "this", ",", "tc", ",", "\"localTransactionCommitted\"", ")", ";", "}", "if", "(", "event", ".", "getId", "(", ")", "==", "ConnectionEvent", ".", "LOCAL_TRANSACTION_COMMITTED", ")", "{", "if", "(", "mcWrapper", ".", "involvedInTransaction", "(", ")", ")", "{", "/*\n * The ManagedConnection is associated with a transaction.\n * Delist the ManagedConnection from the transaction and\n * postpone release of the connection until transaction finishes.\n */", "TranWrapper", "wrapper", "=", "null", ";", "try", "{", "wrapper", "=", "mcWrapper", ".", "getCurrentTranWrapper", "(", ")", ";", "wrapper", ".", "delist", "(", ")", ";", "}", "catch", "(", "ResourceException", "e", ")", "{", "// Can't delist, something went wrong.", "// Destroy the connection(s) so it can't cause any future problems.", "FFDCFilter", ".", "processException", "(", "e", ",", "\"com.ibm.ejs.j2c.ConnectionEventListener.localTransactionCommitted\"", ",", "\"316\"", ",", "\"this\"", ")", ";", "// add datasource name to message", "Tr", ".", "error", "(", "tc", ",", "\"DELIST_FAILED_J2CA0073\"", ",", "\"localTransactionCommitted\"", ",", "e", ",", "mcWrapper", ".", "gConfigProps", ".", "cfName", ")", ";", "// Moved event.getSource() inside of catch block for performance reasons", "ManagedConnection", "mc", "=", "null", ";", "try", "{", "mc", "=", "(", "ManagedConnection", ")", "event", ".", "getSource", "(", ")", ";", "}", "catch", "(", "ClassCastException", "cce", ")", "{", "Tr", ".", "error", "(", "tc", ",", "\"GET_SOURCE_CLASS_CAST_EXCP_J2CA0098\"", ",", "cce", ")", ";", "throw", "new", "IllegalStateException", "(", "\"ClassCastException occurred attempting to cast event.getSource to ManagedConnection\"", ")", ";", "}", "ConnectionEvent", "errorEvent", "=", "new", "ConnectionEvent", "(", "mc", ",", "ConnectionEvent", ".", "CONNECTION_ERROR_OCCURRED", ")", ";", "this", ".", "connectionErrorOccurred", "(", "errorEvent", ")", ";", "RuntimeException", "rte", "=", "new", "IllegalStateException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "throw", "rte", ";", "}", "}", "else", "{", "// if we are not involved in a transaction, then we are likely running with NO transaction", "// context on the thread. This case currently needs to be supported because", "// servlets can spin their own threads which would not have context.", "// Note: it is very rare that users do this. All other occurances are", "// considered to be an error.", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "exit", "(", "this", ",", "tc", ",", "\"localTransactionCommitted\"", ",", "\"no transaction context, return without delisting\"", ")", ";", "}", "return", ";", "}", "}", "else", "{", "// Connection Event passed in doesn't match the method called.", "// This should never happen unless there is an error in the ResourceAdapter.", "processBadEvent", "(", "\"localTransactionCommitted\"", ",", "ConnectionEvent", ".", "LOCAL_TRANSACTION_COMMITTED", ",", "event", ")", ";", "}", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "exit", "(", "this", ",", "tc", ",", "\"localTransactionCommitted\"", ")", ";", "}", "return", ";", "}" ]
This method is called by a resource adapter when a CCI local transation commit is called by the application on a connection. If the MC is associated with a UOW, delist its corresponding transaction wrapper. @param ConnectionEvent
[ "This", "method", "is", "called", "by", "a", "resource", "adapter", "when", "a", "CCI", "local", "transation", "commit", "is", "called", "by", "the", "application", "on", "a", "connection", ".", "If", "the", "MC", "is", "associated", "with", "a", "UOW", "delist", "its", "corresponding", "transaction", "wrapper", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/ConnectionEventListener.java#L315-L377
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/ConnectionEventListener.java
ConnectionEventListener.localTransactionStarted
@Override public void localTransactionStarted(ConnectionEvent event) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(this, tc, "localTransactionStarted"); } if (event.getId() == ConnectionEvent.LOCAL_TRANSACTION_STARTED) { // // The LocalTransactionStarted event for local transaction connections is analogous to the // InteractionPending event for xa transaction connections. JMS's usage of ManagedSessions // is very dependent on the ability to use these two events for properly enlisting their // unshared connections. When a ManagedSession is first created, it is done under an LTC. // When that LTC ends, some partial cleanup is done on the MCWrapper, but it is not put // back into the pool because the unshared connection handle is still active. One of the // items that gets cleaned up is the coordinator within the MCWrapper. This makes sense // since the LTC has ended. But, when it is determined by JMS that it's time to get // enlisted in the current transaction, a null coordinator causes all kinds of problems // (reference the string of defects that have attempted to correct this situation). The // solution determined seems to be the right one. In both localTransactionStarted // and interactionPending methods, we need to check if the MCWrapper coordinator is null and // if it is null, then go out to the TM and get it updated. // // Note that this special null coordinator processing is due to the SmartHandle support // utilized by JMS and RRA. Without smart handles, the coordinator would have gotten // re-initialized during the handle re-association logic. // // In addition, we have determined that the check for involvedInTransaction() is not necessary // (and causes problems for the scenario described just previous). Since the getCurrentTranWrapper() // already checks for a valid state setting before returning, we can just rely on that method to // do the proper checking instead of calling the involvedInTransaction() method. // UOWCoordinator uowCoordinator = mcWrapper.getUOWCoordinator(); if (uowCoordinator == null) { uowCoordinator = mcWrapper.updateUOWCoordinator(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(this, tc, "uowCoord was null, updating it to current coordinator"); } } // if the coordinator is still null, then we are running with NO transaction // context on the thread. This case currently needs to be supported because // servlets can spin their own threads which would not have context. // Note: it is very rare that users do this. All other occurances are // considered to be an error. if (uowCoordinator == null) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(this, tc, "localTransactionStarted", "no transaction context, return without enlisting"); } return; } /* * We know we are in a transaction but we need to verify that it is not a global transaction * before continuing. */ if (tc.isDebugEnabled() && uowCoordinator.isGlobal()) { IllegalStateException ise = new IllegalStateException("Illegal attempt to start a local transaction within a global (user) transaction"); Tr.debug(this, tc, "ILLEGAL_USE_OF_LOCAL_TRANSACTION_J2CA0295", ise); } /* * The ManagedConnection should be associated with a transaction. And, if it's not, * the getCurrentTranWrapper() method will detect the situation and throw an * exception. * * enlist() the ManagedConnection from the transaction. */ try { mcWrapper.getCurrentTranWrapper().enlist(); } catch (ResourceException e) { /* * // Can't enlist, something went wrong. * // Destroy the connection(s) so it can't cause any future problems. * try { * mcWrapper.markStale(); * mcWrapper.releaseToPoolManager(); * } * catch (Exception ex) { * // Nothing to do here. PoolManager has already logged it. * // Since we are in cleanup mode, we will not surface a Runtime exception to the ResourceAdapter * FFDCFilter.processException(ex, "com.ibm.ejs.j2c.ConnectionEventListener.localTransactionStarted", "473", this); * if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { * Tr.debug(this, tc, "localTransactionStarted: Error when trying to enlist " + mcWrapper.getPoolManager().getPmiName() + * " caught exception, but will continue processing: ", ex); * } * } */ FFDCFilter.processException(e, "com.ibm.ejs.j2c.ConnectionEventListener.localTransactionStarted", "481", this); // add datasource name to message Tr.error(tc, "ENLIST_FAILED_J2CA0074", "localTransactionStarted", e, mcWrapper.gConfigProps.cfName); // Moved event.getSource() inside of catch block for performance reasons ManagedConnection mc = null; try { mc = (ManagedConnection) event.getSource(); } catch (ClassCastException cce) { Tr.error(tc, "GET_SOURCE_CLASS_CAST_EXCP_J2CA0098", cce); throw new IllegalStateException("ClassCastException occurred attempting to cast event.getSource to ManagedConnection"); } ConnectionEvent errorEvent = new ConnectionEvent(mc, ConnectionEvent.CONNECTION_ERROR_OCCURRED); this.connectionErrorOccurred(errorEvent); RuntimeException rte = new IllegalStateException(e.getMessage()); throw rte; } } else { // Connection Event passed in doesn't match the method called. // This should never happen unless there is an error in the ResourceAdapter. processBadEvent("localTransactionStarted", ConnectionEvent.LOCAL_TRANSACTION_STARTED, event); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(this, tc, "localTransactionStarted"); } return; }
java
@Override public void localTransactionStarted(ConnectionEvent event) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(this, tc, "localTransactionStarted"); } if (event.getId() == ConnectionEvent.LOCAL_TRANSACTION_STARTED) { // // The LocalTransactionStarted event for local transaction connections is analogous to the // InteractionPending event for xa transaction connections. JMS's usage of ManagedSessions // is very dependent on the ability to use these two events for properly enlisting their // unshared connections. When a ManagedSession is first created, it is done under an LTC. // When that LTC ends, some partial cleanup is done on the MCWrapper, but it is not put // back into the pool because the unshared connection handle is still active. One of the // items that gets cleaned up is the coordinator within the MCWrapper. This makes sense // since the LTC has ended. But, when it is determined by JMS that it's time to get // enlisted in the current transaction, a null coordinator causes all kinds of problems // (reference the string of defects that have attempted to correct this situation). The // solution determined seems to be the right one. In both localTransactionStarted // and interactionPending methods, we need to check if the MCWrapper coordinator is null and // if it is null, then go out to the TM and get it updated. // // Note that this special null coordinator processing is due to the SmartHandle support // utilized by JMS and RRA. Without smart handles, the coordinator would have gotten // re-initialized during the handle re-association logic. // // In addition, we have determined that the check for involvedInTransaction() is not necessary // (and causes problems for the scenario described just previous). Since the getCurrentTranWrapper() // already checks for a valid state setting before returning, we can just rely on that method to // do the proper checking instead of calling the involvedInTransaction() method. // UOWCoordinator uowCoordinator = mcWrapper.getUOWCoordinator(); if (uowCoordinator == null) { uowCoordinator = mcWrapper.updateUOWCoordinator(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(this, tc, "uowCoord was null, updating it to current coordinator"); } } // if the coordinator is still null, then we are running with NO transaction // context on the thread. This case currently needs to be supported because // servlets can spin their own threads which would not have context. // Note: it is very rare that users do this. All other occurances are // considered to be an error. if (uowCoordinator == null) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(this, tc, "localTransactionStarted", "no transaction context, return without enlisting"); } return; } /* * We know we are in a transaction but we need to verify that it is not a global transaction * before continuing. */ if (tc.isDebugEnabled() && uowCoordinator.isGlobal()) { IllegalStateException ise = new IllegalStateException("Illegal attempt to start a local transaction within a global (user) transaction"); Tr.debug(this, tc, "ILLEGAL_USE_OF_LOCAL_TRANSACTION_J2CA0295", ise); } /* * The ManagedConnection should be associated with a transaction. And, if it's not, * the getCurrentTranWrapper() method will detect the situation and throw an * exception. * * enlist() the ManagedConnection from the transaction. */ try { mcWrapper.getCurrentTranWrapper().enlist(); } catch (ResourceException e) { /* * // Can't enlist, something went wrong. * // Destroy the connection(s) so it can't cause any future problems. * try { * mcWrapper.markStale(); * mcWrapper.releaseToPoolManager(); * } * catch (Exception ex) { * // Nothing to do here. PoolManager has already logged it. * // Since we are in cleanup mode, we will not surface a Runtime exception to the ResourceAdapter * FFDCFilter.processException(ex, "com.ibm.ejs.j2c.ConnectionEventListener.localTransactionStarted", "473", this); * if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { * Tr.debug(this, tc, "localTransactionStarted: Error when trying to enlist " + mcWrapper.getPoolManager().getPmiName() + * " caught exception, but will continue processing: ", ex); * } * } */ FFDCFilter.processException(e, "com.ibm.ejs.j2c.ConnectionEventListener.localTransactionStarted", "481", this); // add datasource name to message Tr.error(tc, "ENLIST_FAILED_J2CA0074", "localTransactionStarted", e, mcWrapper.gConfigProps.cfName); // Moved event.getSource() inside of catch block for performance reasons ManagedConnection mc = null; try { mc = (ManagedConnection) event.getSource(); } catch (ClassCastException cce) { Tr.error(tc, "GET_SOURCE_CLASS_CAST_EXCP_J2CA0098", cce); throw new IllegalStateException("ClassCastException occurred attempting to cast event.getSource to ManagedConnection"); } ConnectionEvent errorEvent = new ConnectionEvent(mc, ConnectionEvent.CONNECTION_ERROR_OCCURRED); this.connectionErrorOccurred(errorEvent); RuntimeException rte = new IllegalStateException(e.getMessage()); throw rte; } } else { // Connection Event passed in doesn't match the method called. // This should never happen unless there is an error in the ResourceAdapter. processBadEvent("localTransactionStarted", ConnectionEvent.LOCAL_TRANSACTION_STARTED, event); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(this, tc, "localTransactionStarted"); } return; }
[ "@", "Override", "public", "void", "localTransactionStarted", "(", "ConnectionEvent", "event", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "entry", "(", "this", ",", "tc", ",", "\"localTransactionStarted\"", ")", ";", "}", "if", "(", "event", ".", "getId", "(", ")", "==", "ConnectionEvent", ".", "LOCAL_TRANSACTION_STARTED", ")", "{", "//", "// The LocalTransactionStarted event for local transaction connections is analogous to the", "// InteractionPending event for xa transaction connections. JMS's usage of ManagedSessions", "// is very dependent on the ability to use these two events for properly enlisting their", "// unshared connections. When a ManagedSession is first created, it is done under an LTC.", "// When that LTC ends, some partial cleanup is done on the MCWrapper, but it is not put", "// back into the pool because the unshared connection handle is still active. One of the", "// items that gets cleaned up is the coordinator within the MCWrapper. This makes sense", "// since the LTC has ended. But, when it is determined by JMS that it's time to get", "// enlisted in the current transaction, a null coordinator causes all kinds of problems", "// (reference the string of defects that have attempted to correct this situation). The", "// solution determined seems to be the right one. In both localTransactionStarted", "// and interactionPending methods, we need to check if the MCWrapper coordinator is null and", "// if it is null, then go out to the TM and get it updated.", "//", "// Note that this special null coordinator processing is due to the SmartHandle support", "// utilized by JMS and RRA. Without smart handles, the coordinator would have gotten", "// re-initialized during the handle re-association logic.", "//", "// In addition, we have determined that the check for involvedInTransaction() is not necessary", "// (and causes problems for the scenario described just previous). Since the getCurrentTranWrapper()", "// already checks for a valid state setting before returning, we can just rely on that method to", "// do the proper checking instead of calling the involvedInTransaction() method.", "//", "UOWCoordinator", "uowCoordinator", "=", "mcWrapper", ".", "getUOWCoordinator", "(", ")", ";", "if", "(", "uowCoordinator", "==", "null", ")", "{", "uowCoordinator", "=", "mcWrapper", ".", "updateUOWCoordinator", "(", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "Tr", ".", "debug", "(", "this", ",", "tc", ",", "\"uowCoord was null, updating it to current coordinator\"", ")", ";", "}", "}", "// if the coordinator is still null, then we are running with NO transaction", "// context on the thread. This case currently needs to be supported because", "// servlets can spin their own threads which would not have context.", "// Note: it is very rare that users do this. All other occurances are", "// considered to be an error.", "if", "(", "uowCoordinator", "==", "null", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "exit", "(", "this", ",", "tc", ",", "\"localTransactionStarted\"", ",", "\"no transaction context, return without enlisting\"", ")", ";", "}", "return", ";", "}", "/*\n * We know we are in a transaction but we need to verify that it is not a global transaction\n * before continuing.\n */", "if", "(", "tc", ".", "isDebugEnabled", "(", ")", "&&", "uowCoordinator", ".", "isGlobal", "(", ")", ")", "{", "IllegalStateException", "ise", "=", "new", "IllegalStateException", "(", "\"Illegal attempt to start a local transaction within a global (user) transaction\"", ")", ";", "Tr", ".", "debug", "(", "this", ",", "tc", ",", "\"ILLEGAL_USE_OF_LOCAL_TRANSACTION_J2CA0295\"", ",", "ise", ")", ";", "}", "/*\n * The ManagedConnection should be associated with a transaction. And, if it's not,\n * the getCurrentTranWrapper() method will detect the situation and throw an\n * exception.\n *\n * enlist() the ManagedConnection from the transaction.\n */", "try", "{", "mcWrapper", ".", "getCurrentTranWrapper", "(", ")", ".", "enlist", "(", ")", ";", "}", "catch", "(", "ResourceException", "e", ")", "{", "/*\n * // Can't enlist, something went wrong.\n * // Destroy the connection(s) so it can't cause any future problems.\n * try {\n * mcWrapper.markStale();\n * mcWrapper.releaseToPoolManager();\n * }\n * catch (Exception ex) {\n * // Nothing to do here. PoolManager has already logged it.\n * // Since we are in cleanup mode, we will not surface a Runtime exception to the ResourceAdapter\n * FFDCFilter.processException(ex, \"com.ibm.ejs.j2c.ConnectionEventListener.localTransactionStarted\", \"473\", this);\n * if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {\n * Tr.debug(this, tc, \"localTransactionStarted: Error when trying to enlist \" + mcWrapper.getPoolManager().getPmiName() +\n * \" caught exception, but will continue processing: \", ex);\n * }\n * }\n */", "FFDCFilter", ".", "processException", "(", "e", ",", "\"com.ibm.ejs.j2c.ConnectionEventListener.localTransactionStarted\"", ",", "\"481\"", ",", "this", ")", ";", "// add datasource name to message", "Tr", ".", "error", "(", "tc", ",", "\"ENLIST_FAILED_J2CA0074\"", ",", "\"localTransactionStarted\"", ",", "e", ",", "mcWrapper", ".", "gConfigProps", ".", "cfName", ")", ";", "// Moved event.getSource() inside of catch block for performance reasons", "ManagedConnection", "mc", "=", "null", ";", "try", "{", "mc", "=", "(", "ManagedConnection", ")", "event", ".", "getSource", "(", ")", ";", "}", "catch", "(", "ClassCastException", "cce", ")", "{", "Tr", ".", "error", "(", "tc", ",", "\"GET_SOURCE_CLASS_CAST_EXCP_J2CA0098\"", ",", "cce", ")", ";", "throw", "new", "IllegalStateException", "(", "\"ClassCastException occurred attempting to cast event.getSource to ManagedConnection\"", ")", ";", "}", "ConnectionEvent", "errorEvent", "=", "new", "ConnectionEvent", "(", "mc", ",", "ConnectionEvent", ".", "CONNECTION_ERROR_OCCURRED", ")", ";", "this", ".", "connectionErrorOccurred", "(", "errorEvent", ")", ";", "RuntimeException", "rte", "=", "new", "IllegalStateException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "throw", "rte", ";", "}", "}", "else", "{", "// Connection Event passed in doesn't match the method called.", "// This should never happen unless there is an error in the ResourceAdapter.", "processBadEvent", "(", "\"localTransactionStarted\"", ",", "ConnectionEvent", ".", "LOCAL_TRANSACTION_STARTED", ",", "event", ")", ";", "}", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "exit", "(", "this", ",", "tc", ",", "\"localTransactionStarted\"", ")", ";", "}", "return", ";", "}" ]
This method is called by a resource adapter when a CCI local transation begin is called by the application on a connection @param ConnectionEvent
[ "This", "method", "is", "called", "by", "a", "resource", "adapter", "when", "a", "CCI", "local", "transation", "begin", "is", "called", "by", "the", "application", "on", "a", "connection" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/ConnectionEventListener.java#L455-L574
train
OpenLiberty/open-liberty
dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/OSGiInjectionScopeData.java
OSGiInjectionScopeData.hasObjectWithPrefix
public boolean hasObjectWithPrefix(NamingConstants.JavaColonNamespace namespace, String name) throws NamingException { if (namespace == NamingConstants.JavaColonNamespace.COMP) { return hasObjectWithPrefix(compLock, compBindings, name); } if (namespace == NamingConstants.JavaColonNamespace.COMP_ENV) { return hasObjectWithPrefix(compLock, compEnvBindings, name); } if (namespace == this.namespace) { return hasObjectWithPrefix(nonCompEnvLock, nonCompBindings, name); } return false; }
java
public boolean hasObjectWithPrefix(NamingConstants.JavaColonNamespace namespace, String name) throws NamingException { if (namespace == NamingConstants.JavaColonNamespace.COMP) { return hasObjectWithPrefix(compLock, compBindings, name); } if (namespace == NamingConstants.JavaColonNamespace.COMP_ENV) { return hasObjectWithPrefix(compLock, compEnvBindings, name); } if (namespace == this.namespace) { return hasObjectWithPrefix(nonCompEnvLock, nonCompBindings, name); } return false; }
[ "public", "boolean", "hasObjectWithPrefix", "(", "NamingConstants", ".", "JavaColonNamespace", "namespace", ",", "String", "name", ")", "throws", "NamingException", "{", "if", "(", "namespace", "==", "NamingConstants", ".", "JavaColonNamespace", ".", "COMP", ")", "{", "return", "hasObjectWithPrefix", "(", "compLock", ",", "compBindings", ",", "name", ")", ";", "}", "if", "(", "namespace", "==", "NamingConstants", ".", "JavaColonNamespace", ".", "COMP_ENV", ")", "{", "return", "hasObjectWithPrefix", "(", "compLock", ",", "compEnvBindings", ",", "name", ")", ";", "}", "if", "(", "namespace", "==", "this", ".", "namespace", ")", "{", "return", "hasObjectWithPrefix", "(", "nonCompEnvLock", ",", "nonCompBindings", ",", "name", ")", ";", "}", "return", "false", ";", "}" ]
Returns true if a JNDI subcontext exists.
[ "Returns", "true", "if", "a", "JNDI", "subcontext", "exists", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/OSGiInjectionScopeData.java#L403-L414
train
OpenLiberty/open-liberty
dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/OSGiInjectionScopeData.java
OSGiInjectionScopeData.listInstances
public Collection<? extends NameClassPair> listInstances(NamingConstants.JavaColonNamespace namespace, String contextName) throws NamingException { if (namespace == NamingConstants.JavaColonNamespace.COMP) { return listInstances(compLock, compBindings, contextName); } if (namespace == NamingConstants.JavaColonNamespace.COMP_ENV) { return listInstances(compLock, compEnvBindings, contextName); } if (namespace == this.namespace) { return listInstances(nonCompEnvLock, nonCompBindings, contextName); } return Collections.emptyList(); }
java
public Collection<? extends NameClassPair> listInstances(NamingConstants.JavaColonNamespace namespace, String contextName) throws NamingException { if (namespace == NamingConstants.JavaColonNamespace.COMP) { return listInstances(compLock, compBindings, contextName); } if (namespace == NamingConstants.JavaColonNamespace.COMP_ENV) { return listInstances(compLock, compEnvBindings, contextName); } if (namespace == this.namespace) { return listInstances(nonCompEnvLock, nonCompBindings, contextName); } return Collections.emptyList(); }
[ "public", "Collection", "<", "?", "extends", "NameClassPair", ">", "listInstances", "(", "NamingConstants", ".", "JavaColonNamespace", "namespace", ",", "String", "contextName", ")", "throws", "NamingException", "{", "if", "(", "namespace", "==", "NamingConstants", ".", "JavaColonNamespace", ".", "COMP", ")", "{", "return", "listInstances", "(", "compLock", ",", "compBindings", ",", "contextName", ")", ";", "}", "if", "(", "namespace", "==", "NamingConstants", ".", "JavaColonNamespace", ".", "COMP_ENV", ")", "{", "return", "listInstances", "(", "compLock", ",", "compEnvBindings", ",", "contextName", ")", ";", "}", "if", "(", "namespace", "==", "this", ".", "namespace", ")", "{", "return", "listInstances", "(", "nonCompEnvLock", ",", "nonCompBindings", ",", "contextName", ")", ";", "}", "return", "Collections", ".", "emptyList", "(", ")", ";", "}" ]
Lists the contents of a JNDI subcontext.
[ "Lists", "the", "contents", "of", "a", "JNDI", "subcontext", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/OSGiInjectionScopeData.java#L429-L440
train
OpenLiberty/open-liberty
dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/OSGiInjectionScopeData.java
OSGiInjectionScopeData.disableDeferredReferenceData
private synchronized void disableDeferredReferenceData() { deferredReferenceDataEnabled = false; if (parent != null && deferredReferenceDatas != null) { parent.removeDeferredReferenceData(this); deferredReferenceDatas = null; } }
java
private synchronized void disableDeferredReferenceData() { deferredReferenceDataEnabled = false; if (parent != null && deferredReferenceDatas != null) { parent.removeDeferredReferenceData(this); deferredReferenceDatas = null; } }
[ "private", "synchronized", "void", "disableDeferredReferenceData", "(", ")", "{", "deferredReferenceDataEnabled", "=", "false", ";", "if", "(", "parent", "!=", "null", "&&", "deferredReferenceDatas", "!=", "null", ")", "{", "parent", ".", "removeDeferredReferenceData", "(", "this", ")", ";", "deferredReferenceDatas", "=", "null", ";", "}", "}" ]
Unregister this scope data with its parent if necessary for deferred reference data processing.
[ "Unregister", "this", "scope", "data", "with", "its", "parent", "if", "necessary", "for", "deferred", "reference", "data", "processing", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/OSGiInjectionScopeData.java#L467-L473
train
OpenLiberty/open-liberty
dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/OSGiInjectionScopeData.java
OSGiInjectionScopeData.addDeferredReferenceData
public synchronized void addDeferredReferenceData(DeferredReferenceData refData) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(tc, "addDeferredReferenceData", "this=" + this, refData); } if (deferredReferenceDatas == null) { deferredReferenceDatas = new LinkedHashMap<DeferredReferenceData, Boolean>(); if (parent != null && deferredReferenceDataEnabled) { parent.addDeferredReferenceData(this); } } deferredReferenceDatas.put(refData, null); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(tc, "addDeferredReferenceData"); } }
java
public synchronized void addDeferredReferenceData(DeferredReferenceData refData) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(tc, "addDeferredReferenceData", "this=" + this, refData); } if (deferredReferenceDatas == null) { deferredReferenceDatas = new LinkedHashMap<DeferredReferenceData, Boolean>(); if (parent != null && deferredReferenceDataEnabled) { parent.addDeferredReferenceData(this); } } deferredReferenceDatas.put(refData, null); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(tc, "addDeferredReferenceData"); } }
[ "public", "synchronized", "void", "addDeferredReferenceData", "(", "DeferredReferenceData", "refData", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "entry", "(", "tc", ",", "\"addDeferredReferenceData\"", ",", "\"this=\"", "+", "this", ",", "refData", ")", ";", "}", "if", "(", "deferredReferenceDatas", "==", "null", ")", "{", "deferredReferenceDatas", "=", "new", "LinkedHashMap", "<", "DeferredReferenceData", ",", "Boolean", ">", "(", ")", ";", "if", "(", "parent", "!=", "null", "&&", "deferredReferenceDataEnabled", ")", "{", "parent", ".", "addDeferredReferenceData", "(", "this", ")", ";", "}", "}", "deferredReferenceDatas", ".", "put", "(", "refData", ",", "null", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "exit", "(", "tc", ",", "\"addDeferredReferenceData\"", ")", ";", "}", "}" ]
Add a child deferred reference data to this scope.
[ "Add", "a", "child", "deferred", "reference", "data", "to", "this", "scope", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/OSGiInjectionScopeData.java#L478-L494
train
OpenLiberty/open-liberty
dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/OSGiInjectionScopeData.java
OSGiInjectionScopeData.removeDeferredReferenceData
public synchronized void removeDeferredReferenceData(DeferredReferenceData refData) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(tc, "removeDeferredReferenceData", "this=" + this, refData); } if (deferredReferenceDatas != null) { deferredReferenceDatas.remove(refData); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(tc, "removeDeferredReferenceData"); } }
java
public synchronized void removeDeferredReferenceData(DeferredReferenceData refData) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(tc, "removeDeferredReferenceData", "this=" + this, refData); } if (deferredReferenceDatas != null) { deferredReferenceDatas.remove(refData); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(tc, "removeDeferredReferenceData"); } }
[ "public", "synchronized", "void", "removeDeferredReferenceData", "(", "DeferredReferenceData", "refData", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "entry", "(", "tc", ",", "\"removeDeferredReferenceData\"", ",", "\"this=\"", "+", "this", ",", "refData", ")", ";", "}", "if", "(", "deferredReferenceDatas", "!=", "null", ")", "{", "deferredReferenceDatas", ".", "remove", "(", "refData", ")", ";", "}", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "exit", "(", "tc", ",", "\"removeDeferredReferenceData\"", ")", ";", "}", "}" ]
Remove a child deferred reference data to this scope.
[ "Remove", "a", "child", "deferred", "reference", "data", "to", "this", "scope", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/OSGiInjectionScopeData.java#L499-L511
train
OpenLiberty/open-liberty
dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/OSGiInjectionScopeData.java
OSGiInjectionScopeData.processDeferredReferenceData
@Override public boolean processDeferredReferenceData() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(tc, "processDeferredReferenceData", "this=" + this); } Map<DeferredReferenceData, Boolean> deferredReferenceDatas; synchronized (this) { deferredReferenceDatas = this.deferredReferenceDatas; this.deferredReferenceDatas = null; if (parent != null) { parent.removeDeferredReferenceData(this); } } boolean any = false; if (deferredReferenceDatas != null) { for (DeferredReferenceData refData : deferredReferenceDatas.keySet()) { try { any |= refData.processDeferredReferenceData(); } catch (InjectionException ex) { // We're processing all references in an attempt to locate // non-java:comp references, so we don't care about failures // (erroneous or conflicting metadata). Any exception that // is thrown will be rethrown by ReferenceContext.process // when the component is actually used. ex.getClass(); // findbugs } } } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(tc, "processDeferredReferenceData", any); } return any; }
java
@Override public boolean processDeferredReferenceData() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(tc, "processDeferredReferenceData", "this=" + this); } Map<DeferredReferenceData, Boolean> deferredReferenceDatas; synchronized (this) { deferredReferenceDatas = this.deferredReferenceDatas; this.deferredReferenceDatas = null; if (parent != null) { parent.removeDeferredReferenceData(this); } } boolean any = false; if (deferredReferenceDatas != null) { for (DeferredReferenceData refData : deferredReferenceDatas.keySet()) { try { any |= refData.processDeferredReferenceData(); } catch (InjectionException ex) { // We're processing all references in an attempt to locate // non-java:comp references, so we don't care about failures // (erroneous or conflicting metadata). Any exception that // is thrown will be rethrown by ReferenceContext.process // when the component is actually used. ex.getClass(); // findbugs } } } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(tc, "processDeferredReferenceData", any); } return any; }
[ "@", "Override", "public", "boolean", "processDeferredReferenceData", "(", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "entry", "(", "tc", ",", "\"processDeferredReferenceData\"", ",", "\"this=\"", "+", "this", ")", ";", "}", "Map", "<", "DeferredReferenceData", ",", "Boolean", ">", "deferredReferenceDatas", ";", "synchronized", "(", "this", ")", "{", "deferredReferenceDatas", "=", "this", ".", "deferredReferenceDatas", ";", "this", ".", "deferredReferenceDatas", "=", "null", ";", "if", "(", "parent", "!=", "null", ")", "{", "parent", ".", "removeDeferredReferenceData", "(", "this", ")", ";", "}", "}", "boolean", "any", "=", "false", ";", "if", "(", "deferredReferenceDatas", "!=", "null", ")", "{", "for", "(", "DeferredReferenceData", "refData", ":", "deferredReferenceDatas", ".", "keySet", "(", ")", ")", "{", "try", "{", "any", "|=", "refData", ".", "processDeferredReferenceData", "(", ")", ";", "}", "catch", "(", "InjectionException", "ex", ")", "{", "// We're processing all references in an attempt to locate", "// non-java:comp references, so we don't care about failures", "// (erroneous or conflicting metadata). Any exception that", "// is thrown will be rethrown by ReferenceContext.process", "// when the component is actually used.", "ex", ".", "getClass", "(", ")", ";", "// findbugs", "}", "}", "}", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "Tr", ".", "exit", "(", "tc", ",", "\"processDeferredReferenceData\"", ",", "any", ")", ";", "}", "return", "any", ";", "}" ]
Process all child reference datas. @return true if any reference data was processed.
[ "Process", "all", "child", "reference", "datas", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/OSGiInjectionScopeData.java#L518-L555
train
OpenLiberty/open-liberty
dev/com.ibm.websphere.javaee.jsf.2.3/src/javax/faces/component/UIViewParameter.java
UIViewParameter.releaseRenderer
@SuppressWarnings("unused") private static void releaseRenderer() { if (log.isLoggable(Level.FINEST)) { log.finest("releaseRenderer rendererMap -> " + delegateRendererMap.toString()); } ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (log.isLoggable(Level.FINEST)) { log.finest("releaseRenderer classLoader -> " + classLoader.toString() ); log.finest("releaseRenderer renderer -> " + delegateRendererMap.get(classLoader)); } delegateRendererMap.remove(classLoader); if (log.isLoggable(Level.FINEST)) { log.finest("releaseRenderer renderMap -> " + delegateRendererMap.toString()); } }
java
@SuppressWarnings("unused") private static void releaseRenderer() { if (log.isLoggable(Level.FINEST)) { log.finest("releaseRenderer rendererMap -> " + delegateRendererMap.toString()); } ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (log.isLoggable(Level.FINEST)) { log.finest("releaseRenderer classLoader -> " + classLoader.toString() ); log.finest("releaseRenderer renderer -> " + delegateRendererMap.get(classLoader)); } delegateRendererMap.remove(classLoader); if (log.isLoggable(Level.FINEST)) { log.finest("releaseRenderer renderMap -> " + delegateRendererMap.toString()); } }
[ "@", "SuppressWarnings", "(", "\"unused\"", ")", "private", "static", "void", "releaseRenderer", "(", ")", "{", "if", "(", "log", ".", "isLoggable", "(", "Level", ".", "FINEST", ")", ")", "{", "log", ".", "finest", "(", "\"releaseRenderer rendererMap -> \"", "+", "delegateRendererMap", ".", "toString", "(", ")", ")", ";", "}", "ClassLoader", "classLoader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "if", "(", "log", ".", "isLoggable", "(", "Level", ".", "FINEST", ")", ")", "{", "log", ".", "finest", "(", "\"releaseRenderer classLoader -> \"", "+", "classLoader", ".", "toString", "(", ")", ")", ";", "log", ".", "finest", "(", "\"releaseRenderer renderer -> \"", "+", "delegateRendererMap", ".", "get", "(", "classLoader", ")", ")", ";", "}", "delegateRendererMap", ".", "remove", "(", "classLoader", ")", ";", "if", "(", "log", ".", "isLoggable", "(", "Level", ".", "FINEST", ")", ")", "{", "log", ".", "finest", "(", "\"releaseRenderer renderMap -> \"", "+", "delegateRendererMap", ".", "toString", "(", ")", ")", ";", "}", "}" ]
The idea of this method is to be called from AbstractFacesInitializer.
[ "The", "idea", "of", "this", "method", "is", "to", "be", "called", "from", "AbstractFacesInitializer", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.websphere.javaee.jsf.2.3/src/javax/faces/component/UIViewParameter.java#L267-L292
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/Utils.java
Utils.generateNonce
public static String generateNonce(int length) { if (length < 0) { if (tc.isDebugEnabled()) { Tr.debug(tc, "Negative length provided. Will default to nonce of length " + NONCE_LENGTH); } length = NONCE_LENGTH; } StringBuilder randomString = new StringBuilder(); SecureRandom r = new SecureRandom(); for (int i = 0; i < length; i++) { int index = r.nextInt(chars.length); randomString.append(chars[index]); } return randomString.toString(); }
java
public static String generateNonce(int length) { if (length < 0) { if (tc.isDebugEnabled()) { Tr.debug(tc, "Negative length provided. Will default to nonce of length " + NONCE_LENGTH); } length = NONCE_LENGTH; } StringBuilder randomString = new StringBuilder(); SecureRandom r = new SecureRandom(); for (int i = 0; i < length; i++) { int index = r.nextInt(chars.length); randomString.append(chars[index]); } return randomString.toString(); }
[ "public", "static", "String", "generateNonce", "(", "int", "length", ")", "{", "if", "(", "length", "<", "0", ")", "{", "if", "(", "tc", ".", "isDebugEnabled", "(", ")", ")", "{", "Tr", ".", "debug", "(", "tc", ",", "\"Negative length provided. Will default to nonce of length \"", "+", "NONCE_LENGTH", ")", ";", "}", "length", "=", "NONCE_LENGTH", ";", "}", "StringBuilder", "randomString", "=", "new", "StringBuilder", "(", ")", ";", "SecureRandom", "r", "=", "new", "SecureRandom", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "int", "index", "=", "r", ".", "nextInt", "(", "chars", ".", "length", ")", ";", "randomString", ".", "append", "(", "chars", "[", "index", "]", ")", ";", "}", "return", "randomString", ".", "toString", "(", ")", ";", "}" ]
Generates a random string with the specified length. @param length @return
[ "Generates", "a", "random", "string", "with", "the", "specified", "length", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/Utils.java#L50-L64
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.client/src/com/ibm/ws/security/client/internal/authentication/ClientAuthenticationService.java
ClientAuthenticationService.authenticate
public Subject authenticate(CallbackHandler callbackHandler, Subject subject) throws WSLoginFailedException, CredentialException { if (callbackHandler == null) { throw new WSLoginFailedException(TraceNLS.getFormattedMessage( this.getClass(), TraceConstants.MESSAGE_BUNDLE, "JAAS_LOGIN_NO_CALLBACK_HANDLER", new Object[] {}, "CWWKS1170E: The login on the client application failed because the CallbackHandler implementation is null. Ensure a valid CallbackHandler implementation is specified either in the LoginContext constructor or in the client application's deployment descriptor.")); } CallbackHandlerAuthenticationData cAuthData = new CallbackHandlerAuthenticationData(callbackHandler); AuthenticationData authenticationData = null; try { authenticationData = cAuthData.createAuthenticationData(); } catch (IOException e) { throw new WSLoginFailedException(TraceNLS.getFormattedMessage( this.getClass(), TraceConstants.MESSAGE_BUNDLE, "JAAS_LOGIN_UNEXPECTED_EXCEPTION", new Object[] { e.getLocalizedMessage() }, "CWWKS1172E: The login on the client application failed because of an unexpected exception. Review the logs to understand the cause of the exception. The exception is: " + e.getLocalizedMessage())); } catch (UnsupportedCallbackException e) { throw new WSLoginFailedException(TraceNLS.getFormattedMessage( this.getClass(), TraceConstants.MESSAGE_BUNDLE, "JAAS_LOGIN_UNEXPECTED_EXCEPTION", new Object[] { e.getLocalizedMessage() }, "CWWKS1172E: The login on the client application failed because of an unexpected exception. Review the logs to understand the cause of the exception. The exception is: " + e.getLocalizedMessage())); } return createBasicAuthSubject(authenticationData, subject); }
java
public Subject authenticate(CallbackHandler callbackHandler, Subject subject) throws WSLoginFailedException, CredentialException { if (callbackHandler == null) { throw new WSLoginFailedException(TraceNLS.getFormattedMessage( this.getClass(), TraceConstants.MESSAGE_BUNDLE, "JAAS_LOGIN_NO_CALLBACK_HANDLER", new Object[] {}, "CWWKS1170E: The login on the client application failed because the CallbackHandler implementation is null. Ensure a valid CallbackHandler implementation is specified either in the LoginContext constructor or in the client application's deployment descriptor.")); } CallbackHandlerAuthenticationData cAuthData = new CallbackHandlerAuthenticationData(callbackHandler); AuthenticationData authenticationData = null; try { authenticationData = cAuthData.createAuthenticationData(); } catch (IOException e) { throw new WSLoginFailedException(TraceNLS.getFormattedMessage( this.getClass(), TraceConstants.MESSAGE_BUNDLE, "JAAS_LOGIN_UNEXPECTED_EXCEPTION", new Object[] { e.getLocalizedMessage() }, "CWWKS1172E: The login on the client application failed because of an unexpected exception. Review the logs to understand the cause of the exception. The exception is: " + e.getLocalizedMessage())); } catch (UnsupportedCallbackException e) { throw new WSLoginFailedException(TraceNLS.getFormattedMessage( this.getClass(), TraceConstants.MESSAGE_BUNDLE, "JAAS_LOGIN_UNEXPECTED_EXCEPTION", new Object[] { e.getLocalizedMessage() }, "CWWKS1172E: The login on the client application failed because of an unexpected exception. Review the logs to understand the cause of the exception. The exception is: " + e.getLocalizedMessage())); } return createBasicAuthSubject(authenticationData, subject); }
[ "public", "Subject", "authenticate", "(", "CallbackHandler", "callbackHandler", ",", "Subject", "subject", ")", "throws", "WSLoginFailedException", ",", "CredentialException", "{", "if", "(", "callbackHandler", "==", "null", ")", "{", "throw", "new", "WSLoginFailedException", "(", "TraceNLS", ".", "getFormattedMessage", "(", "this", ".", "getClass", "(", ")", ",", "TraceConstants", ".", "MESSAGE_BUNDLE", ",", "\"JAAS_LOGIN_NO_CALLBACK_HANDLER\"", ",", "new", "Object", "[", "]", "{", "}", ",", "\"CWWKS1170E: The login on the client application failed because the CallbackHandler implementation is null. Ensure a valid CallbackHandler implementation is specified either in the LoginContext constructor or in the client application's deployment descriptor.\"", ")", ")", ";", "}", "CallbackHandlerAuthenticationData", "cAuthData", "=", "new", "CallbackHandlerAuthenticationData", "(", "callbackHandler", ")", ";", "AuthenticationData", "authenticationData", "=", "null", ";", "try", "{", "authenticationData", "=", "cAuthData", ".", "createAuthenticationData", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "WSLoginFailedException", "(", "TraceNLS", ".", "getFormattedMessage", "(", "this", ".", "getClass", "(", ")", ",", "TraceConstants", ".", "MESSAGE_BUNDLE", ",", "\"JAAS_LOGIN_UNEXPECTED_EXCEPTION\"", ",", "new", "Object", "[", "]", "{", "e", ".", "getLocalizedMessage", "(", ")", "}", ",", "\"CWWKS1172E: The login on the client application failed because of an unexpected exception. Review the logs to understand the cause of the exception. The exception is: \"", "+", "e", ".", "getLocalizedMessage", "(", ")", ")", ")", ";", "}", "catch", "(", "UnsupportedCallbackException", "e", ")", "{", "throw", "new", "WSLoginFailedException", "(", "TraceNLS", ".", "getFormattedMessage", "(", "this", ".", "getClass", "(", ")", ",", "TraceConstants", ".", "MESSAGE_BUNDLE", ",", "\"JAAS_LOGIN_UNEXPECTED_EXCEPTION\"", ",", "new", "Object", "[", "]", "{", "e", ".", "getLocalizedMessage", "(", ")", "}", ",", "\"CWWKS1172E: The login on the client application failed because of an unexpected exception. Review the logs to understand the cause of the exception. The exception is: \"", "+", "e", ".", "getLocalizedMessage", "(", ")", ")", ")", ";", "}", "return", "createBasicAuthSubject", "(", "authenticationData", ",", "subject", ")", ";", "}" ]
Authenticating on the client will only create a "dummy" basic auth subject and does not truly authenticate anything. This subject is sent to the server ove CSIv2 where the real authentication happens. @param callbackHandler the callbackhandler to get the authentication data from, must not be <null> @param subject the partial subject, can be null @return a basic auth subject with a basic auth credential @throws WSLoginFailedException if a callback handler is not specified @throws CredentialException if there was a problem creating the WSCredential @throws IOException if there is an I/O error
[ "Authenticating", "on", "the", "client", "will", "only", "create", "a", "dummy", "basic", "auth", "subject", "and", "does", "not", "truly", "authenticate", "anything", ".", "This", "subject", "is", "sent", "to", "the", "server", "ove", "CSIv2", "where", "the", "real", "authentication", "happens", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.client/src/com/ibm/ws/security/client/internal/authentication/ClientAuthenticationService.java#L83-L115
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.client/src/com/ibm/ws/security/client/internal/authentication/ClientAuthenticationService.java
ClientAuthenticationService.createBasicAuthSubject
protected Subject createBasicAuthSubject(AuthenticationData authenticationData, Subject subject) throws WSLoginFailedException, CredentialException { Subject basicAuthSubject = subject != null ? subject : new Subject(); String loginRealm = (String) authenticationData.get(AuthenticationData.REALM); String username = (String) authenticationData.get(AuthenticationData.USERNAME); String password = getPassword((char[]) authenticationData.get(AuthenticationData.PASSWORD)); if (username == null || username.isEmpty() || password == null || password.isEmpty()) { throw new WSLoginFailedException(TraceNLS.getFormattedMessage( this.getClass(), TraceConstants.MESSAGE_BUNDLE, "JAAS_LOGIN_MISSING_CREDENTIALS", new Object[] {}, "CWWKS1171E: The login on the client application failed because the user name or password is null. Ensure the CallbackHandler implementation is gathering the necessary credentials.")); } CredentialsService credentialsService = credentialsServiceRef.getServiceWithException(); credentialsService.setBasicAuthCredential(basicAuthSubject, loginRealm, username, password); Principal principal = new WSPrincipal(username, null, WSPrincipal.AUTH_METHOD_BASIC); basicAuthSubject.getPrincipals().add(principal); return basicAuthSubject; }
java
protected Subject createBasicAuthSubject(AuthenticationData authenticationData, Subject subject) throws WSLoginFailedException, CredentialException { Subject basicAuthSubject = subject != null ? subject : new Subject(); String loginRealm = (String) authenticationData.get(AuthenticationData.REALM); String username = (String) authenticationData.get(AuthenticationData.USERNAME); String password = getPassword((char[]) authenticationData.get(AuthenticationData.PASSWORD)); if (username == null || username.isEmpty() || password == null || password.isEmpty()) { throw new WSLoginFailedException(TraceNLS.getFormattedMessage( this.getClass(), TraceConstants.MESSAGE_BUNDLE, "JAAS_LOGIN_MISSING_CREDENTIALS", new Object[] {}, "CWWKS1171E: The login on the client application failed because the user name or password is null. Ensure the CallbackHandler implementation is gathering the necessary credentials.")); } CredentialsService credentialsService = credentialsServiceRef.getServiceWithException(); credentialsService.setBasicAuthCredential(basicAuthSubject, loginRealm, username, password); Principal principal = new WSPrincipal(username, null, WSPrincipal.AUTH_METHOD_BASIC); basicAuthSubject.getPrincipals().add(principal); return basicAuthSubject; }
[ "protected", "Subject", "createBasicAuthSubject", "(", "AuthenticationData", "authenticationData", ",", "Subject", "subject", ")", "throws", "WSLoginFailedException", ",", "CredentialException", "{", "Subject", "basicAuthSubject", "=", "subject", "!=", "null", "?", "subject", ":", "new", "Subject", "(", ")", ";", "String", "loginRealm", "=", "(", "String", ")", "authenticationData", ".", "get", "(", "AuthenticationData", ".", "REALM", ")", ";", "String", "username", "=", "(", "String", ")", "authenticationData", ".", "get", "(", "AuthenticationData", ".", "USERNAME", ")", ";", "String", "password", "=", "getPassword", "(", "(", "char", "[", "]", ")", "authenticationData", ".", "get", "(", "AuthenticationData", ".", "PASSWORD", ")", ")", ";", "if", "(", "username", "==", "null", "||", "username", ".", "isEmpty", "(", ")", "||", "password", "==", "null", "||", "password", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "WSLoginFailedException", "(", "TraceNLS", ".", "getFormattedMessage", "(", "this", ".", "getClass", "(", ")", ",", "TraceConstants", ".", "MESSAGE_BUNDLE", ",", "\"JAAS_LOGIN_MISSING_CREDENTIALS\"", ",", "new", "Object", "[", "]", "{", "}", ",", "\"CWWKS1171E: The login on the client application failed because the user name or password is null. Ensure the CallbackHandler implementation is gathering the necessary credentials.\"", ")", ")", ";", "}", "CredentialsService", "credentialsService", "=", "credentialsServiceRef", ".", "getServiceWithException", "(", ")", ";", "credentialsService", ".", "setBasicAuthCredential", "(", "basicAuthSubject", ",", "loginRealm", ",", "username", ",", "password", ")", ";", "Principal", "principal", "=", "new", "WSPrincipal", "(", "username", ",", "null", ",", "WSPrincipal", ".", "AUTH_METHOD_BASIC", ")", ";", "basicAuthSubject", ".", "getPrincipals", "(", ")", ".", "add", "(", "principal", ")", ";", "return", "basicAuthSubject", ";", "}" ]
Create the basic auth subject using the given authentication data @param authenticationData the user, password and realm to create the subject @param subject the partial subject, can be null @return a basic auth subject that has not been authenticated yet @throws WSLoginFailedException if the user or password are <null> or empty @throws CredentialException if there was a problem creating the WSCredential
[ "Create", "the", "basic", "auth", "subject", "using", "the", "given", "authentication", "data" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.client/src/com/ibm/ws/security/client/internal/authentication/ClientAuthenticationService.java#L126-L145
train
OpenLiberty/open-liberty
dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/RLSSuspendTokenManager.java
RLSSuspendTokenManager.getInstance
static RLSSuspendTokenManager getInstance() { if (tc.isEntryEnabled()) Tr.entry(tc, "getInstance"); if (tc.isEntryEnabled()) Tr.exit(tc, "getInstance", _instance); return _instance; }
java
static RLSSuspendTokenManager getInstance() { if (tc.isEntryEnabled()) Tr.entry(tc, "getInstance"); if (tc.isEntryEnabled()) Tr.exit(tc, "getInstance", _instance); return _instance; }
[ "static", "RLSSuspendTokenManager", "getInstance", "(", ")", "{", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "entry", "(", "tc", ",", "\"getInstance\"", ")", ";", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "exit", "(", "tc", ",", "\"getInstance\"", ",", "_instance", ")", ";", "return", "_instance", ";", "}" ]
Returns the single instance of the RLSSuspendTokenManager
[ "Returns", "the", "single", "instance", "of", "the", "RLSSuspendTokenManager" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/RLSSuspendTokenManager.java#L61-L66
train
OpenLiberty/open-liberty
dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/RLSSuspendTokenManager.java
RLSSuspendTokenManager.registerSuspend
RLSSuspendToken registerSuspend(int timeout) { if (tc.isEntryEnabled()) Tr.entry(tc, "registerSuspend", new Integer(timeout)); // Generate the suspend token // RLSSuspendToken token = new RLSSuspendTokenImpl(); RLSSuspendToken token = Configuration.getRecoveryLogComponent() .createRLSSuspendToken(null); // Alarm reference Alarm alarm = null; // For a timeout value greater than zero, we create an alarm // A zero timeout value indicates that this suspend operation will // never timeout, hence no alarm is required if (timeout > 0) { // Create an alarm // alarm = AlarmManager.createNonDeferrable(((long)timeout) * 1000L, this, token); alarm = Configuration.getAlarmManager(). scheduleAlarm(timeout * 1000L, this, token); if (tc.isEventEnabled()) Tr.event(tc, "Alarm has been created for this suspend call", alarm); } synchronized(_tokenMap) { // Register the token and the alarm with the token map // bearing in mind that this alarm could be null _tokenMap.put(token, alarm); } if (tc.isEntryEnabled()) Tr.exit(tc, "registerSuspend", token); // Return the generated token return token; }
java
RLSSuspendToken registerSuspend(int timeout) { if (tc.isEntryEnabled()) Tr.entry(tc, "registerSuspend", new Integer(timeout)); // Generate the suspend token // RLSSuspendToken token = new RLSSuspendTokenImpl(); RLSSuspendToken token = Configuration.getRecoveryLogComponent() .createRLSSuspendToken(null); // Alarm reference Alarm alarm = null; // For a timeout value greater than zero, we create an alarm // A zero timeout value indicates that this suspend operation will // never timeout, hence no alarm is required if (timeout > 0) { // Create an alarm // alarm = AlarmManager.createNonDeferrable(((long)timeout) * 1000L, this, token); alarm = Configuration.getAlarmManager(). scheduleAlarm(timeout * 1000L, this, token); if (tc.isEventEnabled()) Tr.event(tc, "Alarm has been created for this suspend call", alarm); } synchronized(_tokenMap) { // Register the token and the alarm with the token map // bearing in mind that this alarm could be null _tokenMap.put(token, alarm); } if (tc.isEntryEnabled()) Tr.exit(tc, "registerSuspend", token); // Return the generated token return token; }
[ "RLSSuspendToken", "registerSuspend", "(", "int", "timeout", ")", "{", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "entry", "(", "tc", ",", "\"registerSuspend\"", ",", "new", "Integer", "(", "timeout", ")", ")", ";", "// Generate the suspend token", "// RLSSuspendToken token = new RLSSuspendTokenImpl();", "RLSSuspendToken", "token", "=", "Configuration", ".", "getRecoveryLogComponent", "(", ")", ".", "createRLSSuspendToken", "(", "null", ")", ";", "// Alarm reference", "Alarm", "alarm", "=", "null", ";", "// For a timeout value greater than zero, we create an alarm", "// A zero timeout value indicates that this suspend operation will", "// never timeout, hence no alarm is required", "if", "(", "timeout", ">", "0", ")", "{", "// Create an alarm", "// alarm = AlarmManager.createNonDeferrable(((long)timeout) * 1000L, this, token);", "alarm", "=", "Configuration", ".", "getAlarmManager", "(", ")", ".", "scheduleAlarm", "(", "timeout", "*", "1000L", ",", "this", ",", "token", ")", ";", "if", "(", "tc", ".", "isEventEnabled", "(", ")", ")", "Tr", ".", "event", "(", "tc", ",", "\"Alarm has been created for this suspend call\"", ",", "alarm", ")", ";", "}", "synchronized", "(", "_tokenMap", ")", "{", "// Register the token and the alarm with the token map", "// bearing in mind that this alarm could be null", "_tokenMap", ".", "put", "(", "token", ",", "alarm", ")", ";", "}", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "exit", "(", "tc", ",", "\"registerSuspend\"", ",", "token", ")", ";", "// Return the generated token", "return", "token", ";", "}" ]
Registers that a suspend call has been made on the RecoveryLogService and generates a unique RLSSuspendToken which must be passed in to registerResume to cancel this suspend operation @param timeout the value in seconds in which a corresponding resume call is expected @return A unique token
[ "Registers", "that", "a", "suspend", "call", "has", "been", "made", "on", "the", "RecoveryLogService", "and", "generates", "a", "unique", "RLSSuspendToken", "which", "must", "be", "passed", "in", "to", "registerResume", "to", "cancel", "this", "suspend", "operation" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/RLSSuspendTokenManager.java#L76-L112
train
OpenLiberty/open-liberty
dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/RLSSuspendTokenManager.java
RLSSuspendTokenManager.registerResume
void registerResume(RLSSuspendToken token) throws RLSInvalidSuspendTokenException { if (tc.isEntryEnabled()) Tr.entry(tc, "registerResume", token); if (token != null && _tokenMap.containsKey(token)) { // Cast the token to its actual type // RLSSuspendTokenImpl tokenImpl = (RLSSuspendTokenImpl) token; synchronized(_tokenMap) { // Remove the token and any associated alarm from the map Alarm alarm = (Alarm) _tokenMap.remove(token /*tokenImpl*/); // This suspend token is still active - check if // it has an alarm associated with it, and if so, cancel if (alarm != null) { alarm.cancel(); } } } else { // Supplied token is null or could not be found in token map if (tc.isEventEnabled()) Tr.event(tc, "Throw RLSInvalidSuspendTokenException - suspend token is not recognised"); if (tc.isEntryEnabled()) Tr.exit(tc, "registerResume", "RLSInvalidSuspendTokenException"); throw new RLSInvalidSuspendTokenException(); } if (tc.isEntryEnabled()) Tr.exit(tc, "registerResume"); }
java
void registerResume(RLSSuspendToken token) throws RLSInvalidSuspendTokenException { if (tc.isEntryEnabled()) Tr.entry(tc, "registerResume", token); if (token != null && _tokenMap.containsKey(token)) { // Cast the token to its actual type // RLSSuspendTokenImpl tokenImpl = (RLSSuspendTokenImpl) token; synchronized(_tokenMap) { // Remove the token and any associated alarm from the map Alarm alarm = (Alarm) _tokenMap.remove(token /*tokenImpl*/); // This suspend token is still active - check if // it has an alarm associated with it, and if so, cancel if (alarm != null) { alarm.cancel(); } } } else { // Supplied token is null or could not be found in token map if (tc.isEventEnabled()) Tr.event(tc, "Throw RLSInvalidSuspendTokenException - suspend token is not recognised"); if (tc.isEntryEnabled()) Tr.exit(tc, "registerResume", "RLSInvalidSuspendTokenException"); throw new RLSInvalidSuspendTokenException(); } if (tc.isEntryEnabled()) Tr.exit(tc, "registerResume"); }
[ "void", "registerResume", "(", "RLSSuspendToken", "token", ")", "throws", "RLSInvalidSuspendTokenException", "{", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "entry", "(", "tc", ",", "\"registerResume\"", ",", "token", ")", ";", "if", "(", "token", "!=", "null", "&&", "_tokenMap", ".", "containsKey", "(", "token", ")", ")", "{", "// Cast the token to its actual type", "// RLSSuspendTokenImpl tokenImpl = (RLSSuspendTokenImpl) token;", "synchronized", "(", "_tokenMap", ")", "{", "// Remove the token and any associated alarm from the map", "Alarm", "alarm", "=", "(", "Alarm", ")", "_tokenMap", ".", "remove", "(", "token", "/*tokenImpl*/", ")", ";", "// This suspend token is still active - check if", "// it has an alarm associated with it, and if so, cancel", "if", "(", "alarm", "!=", "null", ")", "{", "alarm", ".", "cancel", "(", ")", ";", "}", "}", "}", "else", "{", "// Supplied token is null or could not be found in token map", "if", "(", "tc", ".", "isEventEnabled", "(", ")", ")", "Tr", ".", "event", "(", "tc", ",", "\"Throw RLSInvalidSuspendTokenException - suspend token is not recognised\"", ")", ";", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "exit", "(", "tc", ",", "\"registerResume\"", ",", "\"RLSInvalidSuspendTokenException\"", ")", ";", "throw", "new", "RLSInvalidSuspendTokenException", "(", ")", ";", "}", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "exit", "(", "tc", ",", "\"registerResume\"", ")", ";", "}" ]
Cancels the suspend request that returned the matching RLSSuspendToken. The suspend call's alarm, if there is one, will also be cancelled In the event that the suspend token is null or not recognized throws an RLSInvalidSuspendTokenException @param token @throws RLSInvalidSuspendTokenException
[ "Cancels", "the", "suspend", "request", "that", "returned", "the", "matching", "RLSSuspendToken", ".", "The", "suspend", "call", "s", "alarm", "if", "there", "is", "one", "will", "also", "be", "cancelled" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/RLSSuspendTokenManager.java#L149-L180
train
OpenLiberty/open-liberty
dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/RLSSuspendTokenManager.java
RLSSuspendTokenManager.isResumable
boolean isResumable() { if (tc.isEntryEnabled()) Tr.entry(tc, "isResumable"); boolean isResumable = true; synchronized(_tokenMap) { if (!_tokenMap.isEmpty()) { isResumable = false; } } if (tc.isEntryEnabled()) Tr.exit(tc, "isResumable", new Boolean(isResumable)); return isResumable; }
java
boolean isResumable() { if (tc.isEntryEnabled()) Tr.entry(tc, "isResumable"); boolean isResumable = true; synchronized(_tokenMap) { if (!_tokenMap.isEmpty()) { isResumable = false; } } if (tc.isEntryEnabled()) Tr.exit(tc, "isResumable", new Boolean(isResumable)); return isResumable; }
[ "boolean", "isResumable", "(", ")", "{", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "entry", "(", "tc", ",", "\"isResumable\"", ")", ";", "boolean", "isResumable", "=", "true", ";", "synchronized", "(", "_tokenMap", ")", "{", "if", "(", "!", "_tokenMap", ".", "isEmpty", "(", ")", ")", "{", "isResumable", "=", "false", ";", "}", "}", "if", "(", "tc", ".", "isEntryEnabled", "(", ")", ")", "Tr", ".", "exit", "(", "tc", ",", "\"isResumable\"", ",", "new", "Boolean", "(", "isResumable", ")", ")", ";", "return", "isResumable", ";", "}" ]
Returns true if there are no tokens in the map indicating that no active suspends exist. @return
[ "Returns", "true", "if", "there", "are", "no", "tokens", "in", "the", "map", "indicating", "that", "no", "active", "suspends", "exist", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/RLSSuspendTokenManager.java#L187-L204
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.core/src/com/ibm/ws/security/wim/util/UniqueNameHelper.java
UniqueNameHelper.formatUniqueName
public static String formatUniqueName(String uniqueName) throws InvalidUniqueNameException { String validName = getValidUniqueName(uniqueName); if (validName == null) { if (tc.isErrorEnabled()) { Tr.error(tc, WIMMessageKey.INVALID_UNIQUE_NAME_SYNTAX, WIMMessageHelper.generateMsgParms(uniqueName)); } throw new InvalidUniqueNameException(WIMMessageKey.INVALID_UNIQUE_NAME_SYNTAX, Tr.formatMessage( tc, WIMMessageKey.INVALID_UNIQUE_NAME_SYNTAX, WIMMessageHelper.generateMsgParms(uniqueName))); } else { return validName; } }
java
public static String formatUniqueName(String uniqueName) throws InvalidUniqueNameException { String validName = getValidUniqueName(uniqueName); if (validName == null) { if (tc.isErrorEnabled()) { Tr.error(tc, WIMMessageKey.INVALID_UNIQUE_NAME_SYNTAX, WIMMessageHelper.generateMsgParms(uniqueName)); } throw new InvalidUniqueNameException(WIMMessageKey.INVALID_UNIQUE_NAME_SYNTAX, Tr.formatMessage( tc, WIMMessageKey.INVALID_UNIQUE_NAME_SYNTAX, WIMMessageHelper.generateMsgParms(uniqueName))); } else { return validName; } }
[ "public", "static", "String", "formatUniqueName", "(", "String", "uniqueName", ")", "throws", "InvalidUniqueNameException", "{", "String", "validName", "=", "getValidUniqueName", "(", "uniqueName", ")", ";", "if", "(", "validName", "==", "null", ")", "{", "if", "(", "tc", ".", "isErrorEnabled", "(", ")", ")", "{", "Tr", ".", "error", "(", "tc", ",", "WIMMessageKey", ".", "INVALID_UNIQUE_NAME_SYNTAX", ",", "WIMMessageHelper", ".", "generateMsgParms", "(", "uniqueName", ")", ")", ";", "}", "throw", "new", "InvalidUniqueNameException", "(", "WIMMessageKey", ".", "INVALID_UNIQUE_NAME_SYNTAX", ",", "Tr", ".", "formatMessage", "(", "tc", ",", "WIMMessageKey", ".", "INVALID_UNIQUE_NAME_SYNTAX", ",", "WIMMessageHelper", ".", "generateMsgParms", "(", "uniqueName", ")", ")", ")", ";", "}", "else", "{", "return", "validName", ";", "}", "}" ]
Formats the specified entity unique name and also check it using the LDAP DN syntax rule. The formatting including remove @param The unique name of the entity to be formatted. @return The formatted entity unique name. @exception InvalidUniqueNameException if the specified member DN does not pass the syntax check.
[ "Formats", "the", "specified", "entity", "unique", "name", "and", "also", "check", "it", "using", "the", "LDAP", "DN", "syntax", "rule", ".", "The", "formatting", "including", "remove" ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.core/src/com/ibm/ws/security/wim/util/UniqueNameHelper.java#L58-L71
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.core/src/com/ibm/ws/security/wim/util/UniqueNameHelper.java
UniqueNameHelper.constructUniqueName
public static String constructUniqueName(String[] RDNs, Entity entity, String parentDN, boolean throwExc) throws WIMException { boolean found = false; String uniqueName = null; String missingPropName = null; for (int i = 0; i < RDNs.length; i++) { String[] localRDNs = getRDNs(RDNs[i]); int size = localRDNs.length; String[] RDNValues = new String[size]; boolean findValue = true; for (int j = 0; j < size && findValue; j++) { String thisRDN = localRDNs[j]; String thisRDNValue = String.valueOf(entity.get(thisRDN)); if (thisRDNValue == null || "null".equalsIgnoreCase(thisRDNValue)) { findValue = false; missingPropName = thisRDN; } else if (thisRDNValue.trim().length() == 0) { String qualifiedEntityType = entity.getTypeName(); throw new InvalidPropertyValueException(WIMMessageKey.CAN_NOT_CONSTRUCT_UNIQUE_NAME, Tr.formatMessage(tc, WIMMessageKey.CAN_NOT_CONSTRUCT_UNIQUE_NAME, WIMMessageHelper.generateMsgParms(thisRDN, qualifiedEntityType))); } else { RDNValues[j] = thisRDNValue; } } if (findValue) { if (!found) { uniqueName = constructUniqueName(localRDNs, RDNValues, parentDN); found = true; } else if (throwExc) { String qualifiedEntityType = entity.getTypeName(); throw new InvalidUniqueNameException(WIMMessageKey.CAN_NOT_CONSTRUCT_UNIQUE_NAME, Tr.formatMessage(tc, WIMMessageKey.CAN_NOT_CONSTRUCT_UNIQUE_NAME, WIMMessageHelper.generateMsgParms(RDNs[i], qualifiedEntityType))); } } } if (missingPropName != null && !found && throwExc) { throw new MissingMandatoryPropertyException(WIMMessageKey.MISSING_MANDATORY_PROPERTY, Tr.formatMessage(tc, WIMMessageKey.MISSING_MANDATORY_PROPERTY, WIMMessageHelper.generateMsgParms(missingPropName))); } return uniqueName; }
java
public static String constructUniqueName(String[] RDNs, Entity entity, String parentDN, boolean throwExc) throws WIMException { boolean found = false; String uniqueName = null; String missingPropName = null; for (int i = 0; i < RDNs.length; i++) { String[] localRDNs = getRDNs(RDNs[i]); int size = localRDNs.length; String[] RDNValues = new String[size]; boolean findValue = true; for (int j = 0; j < size && findValue; j++) { String thisRDN = localRDNs[j]; String thisRDNValue = String.valueOf(entity.get(thisRDN)); if (thisRDNValue == null || "null".equalsIgnoreCase(thisRDNValue)) { findValue = false; missingPropName = thisRDN; } else if (thisRDNValue.trim().length() == 0) { String qualifiedEntityType = entity.getTypeName(); throw new InvalidPropertyValueException(WIMMessageKey.CAN_NOT_CONSTRUCT_UNIQUE_NAME, Tr.formatMessage(tc, WIMMessageKey.CAN_NOT_CONSTRUCT_UNIQUE_NAME, WIMMessageHelper.generateMsgParms(thisRDN, qualifiedEntityType))); } else { RDNValues[j] = thisRDNValue; } } if (findValue) { if (!found) { uniqueName = constructUniqueName(localRDNs, RDNValues, parentDN); found = true; } else if (throwExc) { String qualifiedEntityType = entity.getTypeName(); throw new InvalidUniqueNameException(WIMMessageKey.CAN_NOT_CONSTRUCT_UNIQUE_NAME, Tr.formatMessage(tc, WIMMessageKey.CAN_NOT_CONSTRUCT_UNIQUE_NAME, WIMMessageHelper.generateMsgParms(RDNs[i], qualifiedEntityType))); } } } if (missingPropName != null && !found && throwExc) { throw new MissingMandatoryPropertyException(WIMMessageKey.MISSING_MANDATORY_PROPERTY, Tr.formatMessage(tc, WIMMessageKey.MISSING_MANDATORY_PROPERTY, WIMMessageHelper.generateMsgParms(missingPropName))); } return uniqueName; }
[ "public", "static", "String", "constructUniqueName", "(", "String", "[", "]", "RDNs", ",", "Entity", "entity", ",", "String", "parentDN", ",", "boolean", "throwExc", ")", "throws", "WIMException", "{", "boolean", "found", "=", "false", ";", "String", "uniqueName", "=", "null", ";", "String", "missingPropName", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "RDNs", ".", "length", ";", "i", "++", ")", "{", "String", "[", "]", "localRDNs", "=", "getRDNs", "(", "RDNs", "[", "i", "]", ")", ";", "int", "size", "=", "localRDNs", ".", "length", ";", "String", "[", "]", "RDNValues", "=", "new", "String", "[", "size", "]", ";", "boolean", "findValue", "=", "true", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "size", "&&", "findValue", ";", "j", "++", ")", "{", "String", "thisRDN", "=", "localRDNs", "[", "j", "]", ";", "String", "thisRDNValue", "=", "String", ".", "valueOf", "(", "entity", ".", "get", "(", "thisRDN", ")", ")", ";", "if", "(", "thisRDNValue", "==", "null", "||", "\"null\"", ".", "equalsIgnoreCase", "(", "thisRDNValue", ")", ")", "{", "findValue", "=", "false", ";", "missingPropName", "=", "thisRDN", ";", "}", "else", "if", "(", "thisRDNValue", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "String", "qualifiedEntityType", "=", "entity", ".", "getTypeName", "(", ")", ";", "throw", "new", "InvalidPropertyValueException", "(", "WIMMessageKey", ".", "CAN_NOT_CONSTRUCT_UNIQUE_NAME", ",", "Tr", ".", "formatMessage", "(", "tc", ",", "WIMMessageKey", ".", "CAN_NOT_CONSTRUCT_UNIQUE_NAME", ",", "WIMMessageHelper", ".", "generateMsgParms", "(", "thisRDN", ",", "qualifiedEntityType", ")", ")", ")", ";", "}", "else", "{", "RDNValues", "[", "j", "]", "=", "thisRDNValue", ";", "}", "}", "if", "(", "findValue", ")", "{", "if", "(", "!", "found", ")", "{", "uniqueName", "=", "constructUniqueName", "(", "localRDNs", ",", "RDNValues", ",", "parentDN", ")", ";", "found", "=", "true", ";", "}", "else", "if", "(", "throwExc", ")", "{", "String", "qualifiedEntityType", "=", "entity", ".", "getTypeName", "(", ")", ";", "throw", "new", "InvalidUniqueNameException", "(", "WIMMessageKey", ".", "CAN_NOT_CONSTRUCT_UNIQUE_NAME", ",", "Tr", ".", "formatMessage", "(", "tc", ",", "WIMMessageKey", ".", "CAN_NOT_CONSTRUCT_UNIQUE_NAME", ",", "WIMMessageHelper", ".", "generateMsgParms", "(", "RDNs", "[", "i", "]", ",", "qualifiedEntityType", ")", ")", ")", ";", "}", "}", "}", "if", "(", "missingPropName", "!=", "null", "&&", "!", "found", "&&", "throwExc", ")", "{", "throw", "new", "MissingMandatoryPropertyException", "(", "WIMMessageKey", ".", "MISSING_MANDATORY_PROPERTY", ",", "Tr", ".", "formatMessage", "(", "tc", ",", "WIMMessageKey", ".", "MISSING_MANDATORY_PROPERTY", ",", "WIMMessageHelper", ".", "generateMsgParms", "(", "missingPropName", ")", ")", ")", ";", "}", "return", "uniqueName", ";", "}" ]
Returns the unique name based on the input value. @param RDNs a list possible rdns @param entity the entity DataObject which contains the entity data @param parentDN the unique name of the parent @param throwExc if true, exception is thrown if a uniqueName can not be constructed @return the unique name, null if uniqueName can not be constructed and throwExc is false @exception WIMException if throwExc is true
[ "Returns", "the", "unique", "name", "based", "on", "the", "input", "value", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.core/src/com/ibm/ws/security/wim/util/UniqueNameHelper.java#L130-L171
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.core/src/com/ibm/ws/security/wim/util/UniqueNameHelper.java
UniqueNameHelper.escapeAttributeValue
private static String escapeAttributeValue(String value) { final String escapees = ",=+<>#;\"\\"; char[] chars = value.toCharArray(); StringBuffer buf = new StringBuffer(2 * value.length()); // Find leading and trailing whitespace. int lead; // index of first char that is not leading whitespace for (lead = 0; lead < chars.length; lead++) { if (!isWhitespace(chars[lead])) { break; } } int trail; // index of last char that is not trailing whitespace for (trail = chars.length - 1; trail >= 0; trail--) { if (!isWhitespace(chars[trail])) { break; } } for (int i = 0; i < chars.length; i++) { char c = chars[i]; if ((i < lead) || (i > trail) || (escapees.indexOf(c) >= 0)) { buf.append('\\'); } buf.append(c); } return new String(buf); }
java
private static String escapeAttributeValue(String value) { final String escapees = ",=+<>#;\"\\"; char[] chars = value.toCharArray(); StringBuffer buf = new StringBuffer(2 * value.length()); // Find leading and trailing whitespace. int lead; // index of first char that is not leading whitespace for (lead = 0; lead < chars.length; lead++) { if (!isWhitespace(chars[lead])) { break; } } int trail; // index of last char that is not trailing whitespace for (trail = chars.length - 1; trail >= 0; trail--) { if (!isWhitespace(chars[trail])) { break; } } for (int i = 0; i < chars.length; i++) { char c = chars[i]; if ((i < lead) || (i > trail) || (escapees.indexOf(c) >= 0)) { buf.append('\\'); } buf.append(c); } return new String(buf); }
[ "private", "static", "String", "escapeAttributeValue", "(", "String", "value", ")", "{", "final", "String", "escapees", "=", "\",=+<>#;\\\"\\\\\"", ";", "char", "[", "]", "chars", "=", "value", ".", "toCharArray", "(", ")", ";", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", "2", "*", "value", ".", "length", "(", ")", ")", ";", "// Find leading and trailing whitespace.", "int", "lead", ";", "// index of first char that is not leading whitespace", "for", "(", "lead", "=", "0", ";", "lead", "<", "chars", ".", "length", ";", "lead", "++", ")", "{", "if", "(", "!", "isWhitespace", "(", "chars", "[", "lead", "]", ")", ")", "{", "break", ";", "}", "}", "int", "trail", ";", "// index of last char that is not trailing whitespace", "for", "(", "trail", "=", "chars", ".", "length", "-", "1", ";", "trail", ">=", "0", ";", "trail", "--", ")", "{", "if", "(", "!", "isWhitespace", "(", "chars", "[", "trail", "]", ")", ")", "{", "break", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "chars", ".", "length", ";", "i", "++", ")", "{", "char", "c", "=", "chars", "[", "i", "]", ";", "if", "(", "(", "i", "<", "lead", ")", "||", "(", "i", ">", "trail", ")", "||", "(", "escapees", ".", "indexOf", "(", "c", ")", ">=", "0", ")", ")", "{", "buf", ".", "append", "(", "'", "'", ")", ";", "}", "buf", ".", "append", "(", "c", ")", ";", "}", "return", "new", "String", "(", "buf", ")", ";", "}" ]
Given the value of an attribute, returns a string suitable for inclusion in a DN. If the value is a string, this is accomplished by using backslash (\) to escape the following characters: , = + < > # ; " \ @param value @return
[ "Given", "the", "value", "of", "an", "attribute", "returns", "a", "string", "suitable", "for", "inclusion", "in", "a", "DN", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.core/src/com/ibm/ws/security/wim/util/UniqueNameHelper.java#L226-L253
train
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.core/src/com/ibm/ws/security/wim/util/UniqueNameHelper.java
UniqueNameHelper.unescapeSpaces
public static String unescapeSpaces(String in) { char[] chars = in.toCharArray(); int end = chars.length; StringBuffer out = new StringBuffer(in.length()); for (int i = 0; i < end; i++) { /* * Remove any backslashes that precede spaces. */ boolean isSlashSpace = (chars[i] == '\\') && (i + 1 < end) && (chars[i + 1] == ' '); if (isSlashSpace) { boolean isStart = (i > 0) && (chars[i - 1] == '='); boolean isEnd = (i + 2 >= end) || ((i + 2 < end) && (chars[i + 2] == ',')); if (!isStart && !isEnd) { ++i; } } out.append(chars[i]); } return new String(out); }
java
public static String unescapeSpaces(String in) { char[] chars = in.toCharArray(); int end = chars.length; StringBuffer out = new StringBuffer(in.length()); for (int i = 0; i < end; i++) { /* * Remove any backslashes that precede spaces. */ boolean isSlashSpace = (chars[i] == '\\') && (i + 1 < end) && (chars[i + 1] == ' '); if (isSlashSpace) { boolean isStart = (i > 0) && (chars[i - 1] == '='); boolean isEnd = (i + 2 >= end) || ((i + 2 < end) && (chars[i + 2] == ',')); if (!isStart && !isEnd) { ++i; } } out.append(chars[i]); } return new String(out); }
[ "public", "static", "String", "unescapeSpaces", "(", "String", "in", ")", "{", "char", "[", "]", "chars", "=", "in", ".", "toCharArray", "(", ")", ";", "int", "end", "=", "chars", ".", "length", ";", "StringBuffer", "out", "=", "new", "StringBuffer", "(", "in", ".", "length", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "end", ";", "i", "++", ")", "{", "/*\n * Remove any backslashes that precede spaces.\n */", "boolean", "isSlashSpace", "=", "(", "chars", "[", "i", "]", "==", "'", "'", ")", "&&", "(", "i", "+", "1", "<", "end", ")", "&&", "(", "chars", "[", "i", "+", "1", "]", "==", "'", "'", ")", ";", "if", "(", "isSlashSpace", ")", "{", "boolean", "isStart", "=", "(", "i", ">", "0", ")", "&&", "(", "chars", "[", "i", "-", "1", "]", "==", "'", "'", ")", ";", "boolean", "isEnd", "=", "(", "i", "+", "2", ">=", "end", ")", "||", "(", "(", "i", "+", "2", "<", "end", ")", "&&", "(", "chars", "[", "i", "+", "2", "]", "==", "'", "'", ")", ")", ";", "if", "(", "!", "isStart", "&&", "!", "isEnd", ")", "{", "++", "i", ";", "}", "}", "out", ".", "append", "(", "chars", "[", "i", "]", ")", ";", "}", "return", "new", "String", "(", "out", ")", ";", "}" ]
Replace any unnecessary escaped spaces from the input DN. @param in The input DN. @return The DN without unnecessary escaped spaces.
[ "Replace", "any", "unnecessary", "escaped", "spaces", "from", "the", "input", "DN", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.core/src/com/ibm/ws/security/wim/util/UniqueNameHelper.java#L283-L306
train
OpenLiberty/open-liberty
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/xml/XmlUtils.java
XmlUtils.getChildText
public static String getChildText(Element elem, String childTagName) { NodeList nodeList = elem.getElementsByTagName(childTagName); int len = nodeList.getLength(); if (len == 0) { return null; } return getElementText((Element)nodeList.item(len - 1)); }
java
public static String getChildText(Element elem, String childTagName) { NodeList nodeList = elem.getElementsByTagName(childTagName); int len = nodeList.getLength(); if (len == 0) { return null; } return getElementText((Element)nodeList.item(len - 1)); }
[ "public", "static", "String", "getChildText", "(", "Element", "elem", ",", "String", "childTagName", ")", "{", "NodeList", "nodeList", "=", "elem", ".", "getElementsByTagName", "(", "childTagName", ")", ";", "int", "len", "=", "nodeList", ".", "getLength", "(", ")", ";", "if", "(", "len", "==", "0", ")", "{", "return", "null", ";", "}", "return", "getElementText", "(", "(", "Element", ")", "nodeList", ".", "item", "(", "len", "-", "1", ")", ")", ";", "}" ]
Return content of child element with given tag name. If more than one children with this name are present, the content of the last element is returned. @param elem @param childTagName @return content of child element or null if no child element with this name was found
[ "Return", "content", "of", "child", "element", "with", "given", "tag", "name", ".", "If", "more", "than", "one", "children", "with", "this", "name", "are", "present", "the", "content", "of", "the", "last", "element", "is", "returned", "." ]
ca725d9903e63645018f9fa8cbda25f60af83a5d
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/xml/XmlUtils.java#L67-L78
train