id
stringlengths 7
14
| text
stringlengths 1
106k
|
---|---|
206320_0 | public static Map<String, String> parse( CharSequence seq )
{
Map<String, String> hashMap = new HashMap<String, String>();
parse( seq, hashMap );
return hashMap;
} |
206320_1 | public RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
throws ScmException
{
return (RemoveScmResult) execute( repository, fileSet, parameters );
} |
206320_2 | public RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
throws ScmException
{
return (RemoveScmResult) execute( repository, fileSet, parameters );
} |
206320_3 | public CheckInScmResult checkIn( ScmProviderRepository repository, ScmFileSet fileSet,
CommandParameters parameters )
throws ScmException
{
return (CheckInScmResult) execute( repository, fileSet, parameters );
} |
206320_4 | public CheckInScmResult checkIn( ScmProviderRepository repository, ScmFileSet fileSet,
CommandParameters parameters )
throws ScmException
{
return (CheckInScmResult) execute( repository, fileSet, parameters );
} |
206320_5 | public CheckInScmResult checkIn( ScmProviderRepository repository, ScmFileSet fileSet,
CommandParameters parameters )
throws ScmException
{
return (CheckInScmResult) execute( repository, fileSet, parameters );
} |
206320_6 | public CheckInScmResult checkIn( ScmProviderRepository repository, ScmFileSet fileSet,
CommandParameters parameters )
throws ScmException
{
return (CheckInScmResult) execute( repository, fileSet, parameters );
} |
206320_7 | public CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet,
CommandParameters parameters )
throws ScmException
{
return (CheckOutScmResult) execute( repository, fileSet, parameters );
} |
206320_8 | public CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet,
CommandParameters parameters )
throws ScmException
{
return (CheckOutScmResult) execute( repository, fileSet, parameters );
} |
206320_9 | public CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet,
CommandParameters parameters )
throws ScmException
{
return (CheckOutScmResult) execute( repository, fileSet, parameters );
} |
206322_0 | public static boolean isClassifierValid( String classifier )
{
// @FIXME: Check classifier for trailing dash? "a-0" valid?
// What are the rules for a valid classifier? Somewhere documented? which can be used as a reference?
boolean result = false;
// The following check is only based on an educated guess ;-)
if ( hasClassifier( classifier ) && classifier.matches( "^[a-zA-Z]+[0-9a-zA-Z\\-]*" ) )
{
result = true;
}
return result;
} |
206322_1 | public static boolean isClassifierValid( String classifier )
{
// @FIXME: Check classifier for trailing dash? "a-0" valid?
// What are the rules for a valid classifier? Somewhere documented? which can be used as a reference?
boolean result = false;
// The following check is only based on an educated guess ;-)
if ( hasClassifier( classifier ) && classifier.matches( "^[a-zA-Z]+[0-9a-zA-Z\\-]*" ) )
{
result = true;
}
return result;
} |
206322_2 | public static boolean isClassifierValid( String classifier )
{
// @FIXME: Check classifier for trailing dash? "a-0" valid?
// What are the rules for a valid classifier? Somewhere documented? which can be used as a reference?
boolean result = false;
// The following check is only based on an educated guess ;-)
if ( hasClassifier( classifier ) && classifier.matches( "^[a-zA-Z]+[0-9a-zA-Z\\-]*" ) )
{
result = true;
}
return result;
} |
206322_3 | public static boolean isClassifierValid( String classifier )
{
// @FIXME: Check classifier for trailing dash? "a-0" valid?
// What are the rules for a valid classifier? Somewhere documented? which can be used as a reference?
boolean result = false;
// The following check is only based on an educated guess ;-)
if ( hasClassifier( classifier ) && classifier.matches( "^[a-zA-Z]+[0-9a-zA-Z\\-]*" ) )
{
result = true;
}
return result;
} |
206322_4 | public static boolean isClassifierValid( String classifier )
{
// @FIXME: Check classifier for trailing dash? "a-0" valid?
// What are the rules for a valid classifier? Somewhere documented? which can be used as a reference?
boolean result = false;
// The following check is only based on an educated guess ;-)
if ( hasClassifier( classifier ) && classifier.matches( "^[a-zA-Z]+[0-9a-zA-Z\\-]*" ) )
{
result = true;
}
return result;
} |
206322_5 | public static boolean hasClassifier( String classifier )
{
boolean result = false;
if ( classifier != null && classifier.trim().length() > 0 )
{
result = true;
}
return result;
} |
206322_6 | public static boolean hasClassifier( String classifier )
{
boolean result = false;
if ( classifier != null && classifier.trim().length() > 0 )
{
result = true;
}
return result;
} |
206322_7 | public static boolean hasClassifier( String classifier )
{
boolean result = false;
if ( classifier != null && classifier.trim().length() > 0 )
{
result = true;
}
return result;
} |
206322_8 | public static File getJarFile( File basedir, String finalName, String classifier )
{
if ( basedir == null )
{
throw new IllegalArgumentException( "basedir is not allowed to be null" );
}
if ( finalName == null )
{
throw new IllegalArgumentException( "finalName is not allowed to be null" );
}
StringBuilder fileName = new StringBuilder( finalName );
if ( hasClassifier( classifier ) )
{
fileName.append( "-" ).append( classifier );
}
fileName.append( ".jar" );
return new File( basedir, fileName.toString() );
} |
206322_9 | public static File getJarFile( File basedir, String finalName, String classifier )
{
if ( basedir == null )
{
throw new IllegalArgumentException( "basedir is not allowed to be null" );
}
if ( finalName == null )
{
throw new IllegalArgumentException( "finalName is not allowed to be null" );
}
StringBuilder fileName = new StringBuilder( finalName );
if ( hasClassifier( classifier ) )
{
fileName.append( "-" ).append( classifier );
}
fileName.append( ".jar" );
return new File( basedir, fileName.toString() );
} |
206350_0 | public Collection<Module> createModules(Module... standardModules)
throws ServletException {
Set<String> existingModules = new HashSet<>();
Collection<Module> modules = new ArrayList<>();
if (standardModules != null) {
for (Module module : standardModules) {
modules.add(module);
existingModules.add(module.getClass().getName());
}
}
String extraModules = configuration.getInitParameter(EXTRA_MODULES_PARAMETER);
if (extraModules != null) {
StringTokenizer toks = new StringTokenizer(extraModules, ", \n\r");
while (toks.hasMoreTokens()) {
String moduleName = toks.nextToken();
if (!existingModules.add(moduleName)) {
continue;
}
Module module;
try {
module = (Module) Util.getJavaClass(moduleName).newInstance();
} catch (Exception e) {
String message = String.format("Error instantiating custom DI module '%s' by filter '%s': %s",
moduleName, getClass().getName(), e.getMessage());
throw new ServletException(message, e);
}
modules.add(module);
}
}
return modules;
} |
206350_1 | public Collection<Module> createModules(Module... standardModules)
throws ServletException {
Set<String> existingModules = new HashSet<>();
Collection<Module> modules = new ArrayList<>();
if (standardModules != null) {
for (Module module : standardModules) {
modules.add(module);
existingModules.add(module.getClass().getName());
}
}
String extraModules = configuration.getInitParameter(EXTRA_MODULES_PARAMETER);
if (extraModules != null) {
StringTokenizer toks = new StringTokenizer(extraModules, ", \n\r");
while (toks.hasMoreTokens()) {
String moduleName = toks.nextToken();
if (!existingModules.add(moduleName)) {
continue;
}
Module module;
try {
module = (Module) Util.getJavaClass(moduleName).newInstance();
} catch (Exception e) {
String message = String.format("Error instantiating custom DI module '%s' by filter '%s': %s",
moduleName, getClass().getName(), e.getMessage());
throw new ServletException(message, e);
}
modules.add(module);
}
}
return modules;
} |
206350_2 | public Collection<Module> createModules(Module... standardModules)
throws ServletException {
Set<String> existingModules = new HashSet<>();
Collection<Module> modules = new ArrayList<>();
if (standardModules != null) {
for (Module module : standardModules) {
modules.add(module);
existingModules.add(module.getClass().getName());
}
}
String extraModules = configuration.getInitParameter(EXTRA_MODULES_PARAMETER);
if (extraModules != null) {
StringTokenizer toks = new StringTokenizer(extraModules, ", \n\r");
while (toks.hasMoreTokens()) {
String moduleName = toks.nextToken();
if (!existingModules.add(moduleName)) {
continue;
}
Module module;
try {
module = (Module) Util.getJavaClass(moduleName).newInstance();
} catch (Exception e) {
String message = String.format("Error instantiating custom DI module '%s' by filter '%s': %s",
moduleName, getClass().getName(), e.getMessage());
throw new ServletException(message, e);
}
modules.add(module);
}
}
return modules;
} |
206350_3 | public String getConfigurationLocation() {
String configurationLocation = configuration
.getInitParameter(CONFIGURATION_LOCATION_PARAMETER);
if (configurationLocation != null) {
return configurationLocation;
}
String name = configuration.getFilterName();
if (name == null) {
return null;
}
if (!name.endsWith(".xml")) {
name = name + ".xml";
}
return name;
} |
206350_4 | public String getConfigurationLocation() {
String configurationLocation = configuration
.getInitParameter(CONFIGURATION_LOCATION_PARAMETER);
if (configurationLocation != null) {
return configurationLocation;
}
String name = configuration.getFilterName();
if (name == null) {
return null;
}
if (!name.endsWith(".xml")) {
name = name + ".xml";
}
return name;
} |
206350_5 | public String getConfigurationLocation() {
String configurationLocation = configuration
.getInitParameter(CONFIGURATION_LOCATION_PARAMETER);
if (configurationLocation != null) {
return configurationLocation;
}
String name = configuration.getFilterName();
if (name == null) {
return null;
}
if (!name.endsWith(".xml")) {
name = name + ".xml";
}
return name;
} |
206350_6 | public String getConfigurationLocation() {
String configurationLocation = configuration
.getInitParameter(CONFIGURATION_LOCATION_PARAMETER);
if (configurationLocation != null) {
return configurationLocation;
}
String name = configuration.getFilterName();
if (name == null) {
return null;
}
if (!name.endsWith(".xml")) {
name = name + ".xml";
}
return name;
} |
206350_7 | public Map<String, String> getParameters() {
Enumeration<?> en = configuration.getInitParameterNames();
if (!en.hasMoreElements()) {
return Collections.emptyMap();
}
Map<String, String> parameters = new HashMap<>();
while (en.hasMoreElements()) {
String key = (String) en.nextElement();
parameters.put(key, configuration.getInitParameter(key));
}
return parameters;
} |
206350_8 | public Map<String, String> getOtherParameters() {
Map<String, String> parameters = getParameters();
if (!parameters.isEmpty()) {
parameters.remove(CONFIGURATION_LOCATION_PARAMETER);
parameters.remove(EXTRA_MODULES_PARAMETER);
}
return parameters;
} |
206350_9 | @Override
public void init(FilterConfig config) throws ServletException {
checkAlreadyConfigured(config.getServletContext());
this.servletContext = config.getServletContext();
WebConfiguration configAdapter = new WebConfiguration(config);
String configurationLocation = configAdapter.getConfigurationLocation();
String[] configurationLocations = null;
if (configurationLocation != null) {
configurationLocations = configurationLocation.split(",\\s*");
}
Collection<Module> modules = configAdapter.createModules();
modules.addAll(getAdditionalModules());
String dataDomainName = configAdapter.getDataDomainName();
ServerRuntime runtime = ServerRuntime.builder(dataDomainName)
.addConfigs(configurationLocations)
.addModules(modules).build();
WebUtil.setCayenneRuntime(config.getServletContext(), runtime);
} |
206364_0 | public static String nextString(int type) {
byte[] bytes = next(type);
try {
return new String(bytes, "ISO-8859-1");
} catch (Exception e) {
return new String(bytes);
}
} |
206364_1 | public static String nextHex(int type) {
return Base16Encoder.encode(next(type));
} |
206364_2 | public static String nextString(int type) {
byte[] bytes = next(type);
try {
return new String(bytes, "ISO-8859-1");
} catch (Exception e) {
return new String(bytes);
}
} |
206364_3 | public static String nextHex(int type) {
return Base16Encoder.encode(next(type));
} |
206364_4 | public static String nextHex(int type) {
return Base16Encoder.encode(next(type));
} |
206364_5 | static long getTime() {
if (RANDOM == null)
initializeForType1();
long newTime = getUUIDTime();
if (newTime <= _lastMillis) {
incrementSequence();
newTime = getUUIDTime();
}
_lastMillis = newTime;
return newTime;
} |
206364_6 | public static byte[] createType1() {
if (type1Initialized == false) {
initializeForType1();
}
// set ip addr
byte[] uuid = new byte[16];
System.arraycopy(IP, 0, uuid, 10, IP.length);
// Set time info. Have to do this processing within a synchronized
// block because of the statics...
long now = 0;
synchronized (UUIDGenerator.class) {
// Get the time to use for this uuid. This method has the side
// effect of modifying the clock sequence, as well.
now = getTime();
// Insert the resulting clock sequence into the uuid
uuid[IDX_TIME_SEQ] = (byte) ((_seq & 0x3F00) >>> 8);
uuid[IDX_VARIATION] |= 0x80;
uuid[IDX_TIME_SEQ+1] = (byte) (_seq & 0xFF);
}
// have to break up time because bytes are spread through uuid
byte[] timeBytes = Bytes.toBytes(now);
// Copy time low
System.arraycopy(timeBytes, TS_TIME_LO_IDX, uuid, IDX_TIME_LO,
TS_TIME_LO_LEN);
// Copy time mid
System.arraycopy(timeBytes, TS_TIME_MID_IDX, uuid, IDX_TIME_MID,
TS_TIME_MID_LEN);
// Copy time hi
System.arraycopy(timeBytes, TS_TIME_HI_IDX, uuid, IDX_TIME_HI,
TS_TIME_HI_LEN);
//Set version (time-based)
uuid[IDX_TYPE] |= TYPE_TIME_BASED; // 0001 0000
return uuid;
} |
206364_7 | public static String[] split(String str, String token, int max) {
if (str == null || str.length() == 0) {
return EMPTY_STRING_ARRAY;
}
if (token == null || token.length() == 0) {
throw new IllegalArgumentException("token: [" + token + "]");
}
// split on token
List<String> ret = new ArrayList<>();
int start = 0;
int len = str.length();
int tlen = token.length();
int pos = 0;
while (pos != -1) {
pos = str.indexOf(token, start);
if (pos != -1) {
ret.add(str.substring(start, pos));
start = pos + tlen;
}
}
if (start < len) {
ret.add(str.substring(start));
}
else if (start == len) {
ret.add("");
}
// now take max into account; this isn't the most efficient way
// of doing things since we split the maximum number of times
// regardless of the given parameters, but it makes things easy
if (max == 0) {
int size = ret.size();
// discard any trailing empty splits
while (ret.get(--size).isEmpty()) {
ret.remove(size);
}
}
else if (max > 0 && ret.size() > max) {
// move all splits over max into the last split
StringBuilder sb = new StringBuilder(256);
sb.append(ret.get(max - 1));
ret.remove(max - 1);
while (ret.size() >= max) {
sb.append(token).append(ret.get(max - 1));
ret.remove(max - 1);
}
ret.add(sb.toString());
}
return ret.toArray(new String[ret.size()]);
} |
206364_8 | public static String[] split(String str, String token, int max) {
if (str == null || str.length() == 0) {
return EMPTY_STRING_ARRAY;
}
if (token == null || token.length() == 0) {
throw new IllegalArgumentException("token: [" + token + "]");
}
// split on token
List<String> ret = new ArrayList<>();
int start = 0;
int len = str.length();
int tlen = token.length();
int pos = 0;
while (pos != -1) {
pos = str.indexOf(token, start);
if (pos != -1) {
ret.add(str.substring(start, pos));
start = pos + tlen;
}
}
if (start < len) {
ret.add(str.substring(start));
}
else if (start == len) {
ret.add("");
}
// now take max into account; this isn't the most efficient way
// of doing things since we split the maximum number of times
// regardless of the given parameters, but it makes things easy
if (max == 0) {
int size = ret.size();
// discard any trailing empty splits
while (ret.get(--size).isEmpty()) {
ret.remove(size);
}
}
else if (max > 0 && ret.size() > max) {
// move all splits over max into the last split
StringBuilder sb = new StringBuilder(256);
sb.append(ret.get(max - 1));
ret.remove(max - 1);
while (ret.size() >= max) {
sb.append(token).append(ret.get(max - 1));
ret.remove(max - 1);
}
ret.add(sb.toString());
}
return ret.toArray(new String[ret.size()]);
} |
206364_9 | public static String[] split(String str, String token, int max) {
if (str == null || str.length() == 0) {
return EMPTY_STRING_ARRAY;
}
if (token == null || token.length() == 0) {
throw new IllegalArgumentException("token: [" + token + "]");
}
// split on token
List<String> ret = new ArrayList<>();
int start = 0;
int len = str.length();
int tlen = token.length();
int pos = 0;
while (pos != -1) {
pos = str.indexOf(token, start);
if (pos != -1) {
ret.add(str.substring(start, pos));
start = pos + tlen;
}
}
if (start < len) {
ret.add(str.substring(start));
}
else if (start == len) {
ret.add("");
}
// now take max into account; this isn't the most efficient way
// of doing things since we split the maximum number of times
// regardless of the given parameters, but it makes things easy
if (max == 0) {
int size = ret.size();
// discard any trailing empty splits
while (ret.get(--size).isEmpty()) {
ret.remove(size);
}
}
else if (max > 0 && ret.size() > max) {
// move all splits over max into the last split
StringBuilder sb = new StringBuilder(256);
sb.append(ret.get(max - 1));
ret.remove(max - 1);
while (ret.size() >= max) {
sb.append(token).append(ret.get(max - 1));
ret.remove(max - 1);
}
ret.add(sb.toString());
}
return ret.toArray(new String[ret.size()]);
} |
206402_0 | @Override
public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
final String method = request.getMethod();
if (method.equalsIgnoreCase("CONNECT")) {
return;
}
final HttpClientContext clientContext = HttpClientContext.adapt(context);
// Obtain the client connection (required)
final RouteInfo route = clientContext.getHttpRoute();
if (route == null) {
LOG.debug("Connection route not set in the context");
return;
}
if (route.getHopCount() == 1 || route.isTunnelled()) {
if (!request.containsHeader(HttpHeaders.CONNECTION)) {
request.addHeader(HttpHeaders.CONNECTION, HeaderElements.KEEP_ALIVE);
}
}
} |
206402_1 | @Override
public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
final String method = request.getMethod();
if (method.equalsIgnoreCase("CONNECT")) {
return;
}
final HttpClientContext clientContext = HttpClientContext.adapt(context);
// Obtain the client connection (required)
final RouteInfo route = clientContext.getHttpRoute();
if (route == null) {
LOG.debug("Connection route not set in the context");
return;
}
if (route.getHopCount() == 1 || route.isTunnelled()) {
if (!request.containsHeader(HttpHeaders.CONNECTION)) {
request.addHeader(HttpHeaders.CONNECTION, HeaderElements.KEEP_ALIVE);
}
}
} |
206402_2 | @Override
public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
final String method = request.getMethod();
if (method.equalsIgnoreCase("CONNECT")) {
return;
}
final HttpClientContext clientContext = HttpClientContext.adapt(context);
// Obtain the client connection (required)
final RouteInfo route = clientContext.getHttpRoute();
if (route == null) {
LOG.debug("Connection route not set in the context");
return;
}
if (route.getHopCount() == 1 || route.isTunnelled()) {
if (!request.containsHeader(HttpHeaders.CONNECTION)) {
request.addHeader(HttpHeaders.CONNECTION, HeaderElements.KEEP_ALIVE);
}
}
} |
206402_3 | @Override
public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
final String method = request.getMethod();
if (method.equalsIgnoreCase("CONNECT")) {
return;
}
final HttpClientContext clientContext = HttpClientContext.adapt(context);
// Obtain the client connection (required)
final RouteInfo route = clientContext.getHttpRoute();
if (route == null) {
LOG.debug("Connection route not set in the context");
return;
}
if (route.getHopCount() == 1 || route.isTunnelled()) {
if (!request.containsHeader(HttpHeaders.CONNECTION)) {
request.addHeader(HttpHeaders.CONNECTION, HeaderElements.KEEP_ALIVE);
}
}
} |
206402_4 | @Override
public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
final String method = request.getMethod();
if (method.equalsIgnoreCase("CONNECT")) {
return;
}
final HttpClientContext clientContext = HttpClientContext.adapt(context);
// Obtain the client connection (required)
final RouteInfo route = clientContext.getHttpRoute();
if (route == null) {
LOG.debug("Connection route not set in the context");
return;
}
if (route.getHopCount() == 1 || route.isTunnelled()) {
if (!request.containsHeader(HttpHeaders.CONNECTION)) {
request.addHeader(HttpHeaders.CONNECTION, HeaderElements.KEEP_ALIVE);
}
}
} |
206402_5 | @Override
public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
final String method = request.getMethod();
if (method.equalsIgnoreCase("CONNECT")) {
return;
}
final HttpClientContext clientContext = HttpClientContext.adapt(context);
// Obtain the client connection (required)
final RouteInfo route = clientContext.getHttpRoute();
if (route == null) {
LOG.debug("Connection route not set in the context");
return;
}
if (route.getHopCount() == 1 || route.isTunnelled()) {
if (!request.containsHeader(HttpHeaders.CONNECTION)) {
request.addHeader(HttpHeaders.CONNECTION, HeaderElements.KEEP_ALIVE);
}
}
} |
206402_6 | @Override
public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
final String method = request.getMethod();
if (method.equalsIgnoreCase("CONNECT")) {
return;
}
if (this.defaultHeaders != null) {
for (final Header defHeader : this.defaultHeaders) {
if(!request.containsHeader(defHeader.getName())) {
request.addHeader(defHeader);
}
}
}
} |
206402_7 | @Override
public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
final String method = request.getMethod();
if (method.equalsIgnoreCase("CONNECT")) {
return;
}
if (this.defaultHeaders != null) {
for (final Header defHeader : this.defaultHeaders) {
if(!request.containsHeader(defHeader.getName())) {
request.addHeader(defHeader);
}
}
}
} |
206402_8 | @Override
public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
final String method = request.getMethod();
if (method.equalsIgnoreCase("CONNECT")) {
return;
}
if (this.defaultHeaders != null) {
for (final Header defHeader : this.defaultHeaders) {
if(!request.containsHeader(defHeader.getName())) {
request.addHeader(defHeader);
}
}
}
} |
206402_9 | @Override
public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
Args.notNull(context, "HTTP context");
final String method = request.getMethod();
if (method.equalsIgnoreCase("CONNECT") || method.equalsIgnoreCase("TRACE")) {
return;
}
final HttpClientContext clientContext = HttpClientContext.adapt(context);
// Obtain cookie store
final CookieStore cookieStore = clientContext.getCookieStore();
if (cookieStore == null) {
LOG.debug("Cookie store not specified in HTTP context");
return;
}
// Obtain the registry of cookie specs
final Lookup<CookieSpecFactory> registry = clientContext.getCookieSpecRegistry();
if (registry == null) {
LOG.debug("CookieSpec registry not specified in HTTP context");
return;
}
// Obtain the route (required)
final RouteInfo route = clientContext.getHttpRoute();
if (route == null) {
LOG.debug("Connection route not set in the context");
return;
}
final RequestConfig config = clientContext.getRequestConfig();
String cookieSpecName = config.getCookieSpec();
if (cookieSpecName == null) {
cookieSpecName = StandardCookieSpec.STRICT;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Cookie spec selected: {}", cookieSpecName);
}
final URIAuthority authority = request.getAuthority();
String path = request.getPath();
if (TextUtils.isEmpty(path)) {
path = "/";
}
String hostName = authority != null ? authority.getHostName() : null;
if (hostName == null) {
hostName = route.getTargetHost().getHostName();
}
int port = authority != null ? authority.getPort() : -1;
if (port < 0) {
port = route.getTargetHost().getPort();
}
final CookieOrigin cookieOrigin = new CookieOrigin(hostName, port, path, route.isSecure());
// Get an instance of the selected cookie policy
final CookieSpecFactory factory = registry.lookup(cookieSpecName);
if (factory == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Unsupported cookie spec: {}", cookieSpecName);
}
return;
}
final CookieSpec cookieSpec = factory.create(clientContext);
// Get all cookies available in the HTTP state
final List<Cookie> cookies = cookieStore.getCookies();
// Find cookies matching the given origin
final List<Cookie> matchedCookies = new ArrayList<>();
final Date now = new Date();
boolean expired = false;
for (final Cookie cookie : cookies) {
if (!cookie.isExpired(now)) {
if (cookieSpec.match(cookie, cookieOrigin)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Cookie {} match {}", cookie, cookieOrigin);
}
matchedCookies.add(cookie);
}
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Cookie {} expired", cookie);
}
expired = true;
}
}
// Per RFC 6265, 5.3
// The user agent must evict all expired cookies if, at any time, an expired cookie
// exists in the cookie store
if (expired) {
cookieStore.clearExpired(now);
}
// Generate Cookie request headers
if (!matchedCookies.isEmpty()) {
final List<Header> headers = cookieSpec.formatCookies(matchedCookies);
for (final Header header : headers) {
request.addHeader(header);
}
}
// Stick the CookieSpec and CookieOrigin instances to the HTTP context
// so they could be obtained by the response interceptor
context.setAttribute(HttpClientContext.COOKIE_SPEC, cookieSpec);
context.setAttribute(HttpClientContext.COOKIE_ORIGIN, cookieOrigin);
} |
206403_0 | void write(Node node, int maxLevels) throws RepositoryException, IOException {
write(node, 0, maxLevels);
} |
206403_1 | public static Builder builder() {
return new Builder();
} |
206403_2 | public static List<String> tokenizeList(String list) {
String[] split = list.split(",");
if (split.length == 1) {
return Collections.singletonList(split[0].trim());
} else {
List<String> result = new ArrayList<String>();
String inCodedUrl = null;
for (String t : split) {
String trimmed = t.trim();
// handle quoted-url containing ","
if (trimmed.startsWith("<") && !trimmed.endsWith(">")) {
inCodedUrl = trimmed + ",";
} else if (inCodedUrl != null && trimmed.endsWith(">")) {
inCodedUrl += trimmed;
result.add(inCodedUrl);
inCodedUrl = null;
} else {
if (trimmed.length() != 0) {
result.add(trimmed);
}
}
}
return Collections.unmodifiableList(result);
}
} |
206418_0 | public MavenProject getMavenProject( ContinuumProjectBuildingResult result, File file )
{
MavenProject project;
try
{
// TODO: This seems like code that is shared with DefaultMaven, so it should be moved to the project
// builder perhaps
Settings settings = getSettings();
if ( log.isDebugEnabled() )
{
writeSettings( settings );
}
ProfileManager profileManager = new DefaultProfileManager( container, settings );
project = projectBuilder.build( file, getRepository( settings ), profileManager, false );
if ( log.isDebugEnabled() )
{
writePom( project );
writeActiveProfileStatement( project );
}
}
catch ( ProjectBuildingException e )
{
StringBuffer messages = new StringBuffer();
Throwable cause = e.getCause();
if ( cause != null )
{
while ( ( cause.getCause() != null ) && ( cause instanceof ProjectBuildingException ) )
{
cause = cause.getCause();
}
}
if ( e instanceof InvalidProjectModelException )
{
InvalidProjectModelException ex = (InvalidProjectModelException) e;
ModelValidationResult validationResult = ex.getValidationResult();
if ( validationResult != null && validationResult.getMessageCount() > 0 )
{
for ( String valmsg : (List<String>) validationResult.getMessages() )
{
result.addError( ContinuumProjectBuildingResult.ERROR_VALIDATION, valmsg );
messages.append( valmsg );
messages.append( "\n" );
}
}
}
if ( cause instanceof ArtifactNotFoundException )
{
result.addError( ContinuumProjectBuildingResult.ERROR_ARTIFACT_NOT_FOUND, ( cause ).toString() );
return null;
}
result.addError( ContinuumProjectBuildingResult.ERROR_PROJECT_BUILDING, e.getMessage() );
String msg = "Cannot build maven project from " + file + " (" + e.getMessage() + ").\n" + messages;
log.error( msg );
return null;
}
// TODO catch all exceptions is bad
catch ( Exception e )
{
result.addError( ContinuumProjectBuildingResult.ERROR_PROJECT_BUILDING, e.getMessage() );
String msg = "Cannot build maven project from " + file + " (" + e.getMessage() + ").";
log.error( msg );
return null;
}
// ----------------------------------------------------------------------
// Validate the MavenProject using some Continuum rules
// ----------------------------------------------------------------------
// SCM connection
Scm scm = project.getScm();
if ( scm == null )
{
result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_SCM, getProjectName( project ) );
log.error( "Missing 'scm' element in the " + getProjectName( project ) + " POM." );
return null;
}
String url = scm.getConnection();
if ( StringUtils.isEmpty( url ) )
{
result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_SCM_CONNECTION, getProjectName( project ) );
log.error( "Missing 'connection' element in the 'scm' element in the " + getProjectName( project ) +
" POM." );
return null;
}
return project;
} |
206418_1 | public void executeTask( Task task )
throws TaskExecutionException
{
BuildProjectTask buildProjectTask = (BuildProjectTask) task;
int projectId = buildProjectTask.getProjectId();
try
{
log.info( "Initializing build (projectId={})", projectId );
BuildContext context = buildContextManager.getBuildContext( projectId );
initializeBuildContext( context );
if ( !checkScmResult( context ) )
{
return;
}
log.info( "Checking if project '{}' should build", context.getProjectName() );
if ( !shouldBuild( context ) )
{
return;
}
log.info( "Starting build of {}", context.getProjectName() );
startBuild( context );
try
{
try
{
performAction( "update-project-from-agent-working-directory", context );
}
catch ( TaskExecutionException e )
{
updateBuildResult( context, ContinuumBuildAgentUtil.throwableToString( e ) );
//just log the error but don't stop the build from progressing in order not to suppress any build result messages there
log.error( "Error executing action update-project-from-agent-working-directory '", e );
}
performAction( "execute-agent-builder", context );
log.info( "Updating build result of project '{}'", context.getProjectName() );
updateBuildResult( context, null );
}
finally
{
log.info( "End build of project '{}'", context.getProjectName() );
endBuild( context );
}
}
catch ( TaskExecutionException e )
{
log.error( "Error while trying to build the project {}: {}", projectId, e.getMessage() );
}
} |
206418_2 | public void executeTask( Task task )
throws TaskExecutionException
{
BuildProjectTask buildProjectTask = (BuildProjectTask) task;
int projectId = buildProjectTask.getProjectId();
try
{
log.info( "Initializing build (projectId={})", projectId );
BuildContext context = buildContextManager.getBuildContext( projectId );
initializeBuildContext( context );
if ( !checkScmResult( context ) )
{
return;
}
log.info( "Checking if project '{}' should build", context.getProjectName() );
if ( !shouldBuild( context ) )
{
return;
}
log.info( "Starting build of {}", context.getProjectName() );
startBuild( context );
try
{
try
{
performAction( "update-project-from-agent-working-directory", context );
}
catch ( TaskExecutionException e )
{
updateBuildResult( context, ContinuumBuildAgentUtil.throwableToString( e ) );
//just log the error but don't stop the build from progressing in order not to suppress any build result messages there
log.error( "Error executing action update-project-from-agent-working-directory '", e );
}
performAction( "execute-agent-builder", context );
log.info( "Updating build result of project '{}'", context.getProjectName() );
updateBuildResult( context, null );
}
finally
{
log.info( "End build of project '{}'", context.getProjectName() );
endBuild( context );
}
}
catch ( TaskExecutionException e )
{
log.error( "Error while trying to build the project {}: {}", projectId, e.getMessage() );
}
} |
206418_3 | public void executeTask( Task task )
throws TaskExecutionException
{
BuildProjectTask buildProjectTask = (BuildProjectTask) task;
int projectId = buildProjectTask.getProjectId();
try
{
log.info( "Initializing build (projectId={})", projectId );
BuildContext context = buildContextManager.getBuildContext( projectId );
initializeBuildContext( context );
if ( !checkScmResult( context ) )
{
return;
}
log.info( "Checking if project '{}' should build", context.getProjectName() );
if ( !shouldBuild( context ) )
{
return;
}
log.info( "Starting build of {}", context.getProjectName() );
startBuild( context );
try
{
try
{
performAction( "update-project-from-agent-working-directory", context );
}
catch ( TaskExecutionException e )
{
updateBuildResult( context, ContinuumBuildAgentUtil.throwableToString( e ) );
//just log the error but don't stop the build from progressing in order not to suppress any build result messages there
log.error( "Error executing action update-project-from-agent-working-directory '", e );
}
performAction( "execute-agent-builder", context );
log.info( "Updating build result of project '{}'", context.getProjectName() );
updateBuildResult( context, null );
}
finally
{
log.info( "End build of project '{}'", context.getProjectName() );
endBuild( context );
}
}
catch ( TaskExecutionException e )
{
log.error( "Error while trying to build the project {}: {}", projectId, e.getMessage() );
}
} |
206418_4 | public static int getProjectId( final String href )
{
String requestPathInfo = StringUtils.defaultString( href );
// Remove prefix ie /workingcopy/blah becomes /blah
requestPathInfo = removePrefix( requestPathInfo );
// Remove prefixing slash as the project id doesn't contain it;
if ( requestPathInfo.startsWith( "/" ) )
{
requestPathInfo = requestPathInfo.substring( 1 );
}
int projectId = 0;
try
{
// Find first element, if slash exists.
int slash = requestPathInfo.indexOf( '/' );
if ( slash > 0 )
{
// Filtered: "1/src/main/java/" -> "1"
projectId = Integer.parseInt( requestPathInfo.substring( 0, slash ) );
}
else
{
projectId = Integer.parseInt( requestPathInfo );
}
}
catch ( NumberFormatException e )
{
}
return projectId;
} |
206418_5 | public static String getLogicalResource( final String href )
{
String logicalResource = null;
String requestPathInfo = StringUtils.defaultString( href );
//remove prefix ie /workingcopy/blah becomes /blah
requestPathInfo = removePrefix( requestPathInfo );
// Remove prefixing slash as the project id doesn't contain it;
if ( requestPathInfo.startsWith( "/" ) )
{
requestPathInfo = requestPathInfo.substring( 1 );
}
int slash = requestPathInfo.indexOf( '/' );
if ( slash > 0 )
{
logicalResource = requestPathInfo.substring( slash );
if ( logicalResource.endsWith( "/.." ) )
{
logicalResource += "/";
}
if ( logicalResource != null && logicalResource.startsWith( "//" ) )
{
logicalResource = logicalResource.substring( 1 );
}
if ( logicalResource == null )
{
logicalResource = "/";
}
}
else
{
logicalResource = "/";
}
return logicalResource;
} |
206418_6 | public DavResource createResource( final DavResourceLocator locator, final DavSession davSession )
throws DavException
{
ContinuumBuildAgentDavResourceLocator continuumLocator = checkLocatorIsInstanceOfContinuumBuildAgentLocator(
locator );
String logicalResource = WorkingCopyPathUtil.getLogicalResource( locator.getResourcePath() );
if ( logicalResource.startsWith( "/" ) )
{
logicalResource = logicalResource.substring( 1 );
}
File resourceFile = getResourceFile( continuumLocator.getProjectId(), logicalResource );
if ( !resourceFile.exists() || ( continuumLocator.getHref( false ).endsWith( "/" ) &&
!resourceFile.isDirectory() ) )
{
// force a resource not found
log.error( "Resource file '" + resourceFile.getAbsolutePath() + "' does not exist" );
throw new DavException( HttpServletResponse.SC_NOT_FOUND, "Resource does not exist" );
}
else
{
return createResource( resourceFile, logicalResource, davSession, continuumLocator );
}
} |
206418_7 | public DavResource createResource( final DavResourceLocator locator, final DavSession davSession )
throws DavException
{
ContinuumBuildAgentDavResourceLocator continuumLocator = checkLocatorIsInstanceOfContinuumBuildAgentLocator(
locator );
String logicalResource = WorkingCopyPathUtil.getLogicalResource( locator.getResourcePath() );
if ( logicalResource.startsWith( "/" ) )
{
logicalResource = logicalResource.substring( 1 );
}
File resourceFile = getResourceFile( continuumLocator.getProjectId(), logicalResource );
if ( !resourceFile.exists() || ( continuumLocator.getHref( false ).endsWith( "/" ) &&
!resourceFile.isDirectory() ) )
{
// force a resource not found
log.error( "Resource file '" + resourceFile.getAbsolutePath() + "' does not exist" );
throw new DavException( HttpServletResponse.SC_NOT_FOUND, "Resource does not exist" );
}
else
{
return createResource( resourceFile, logicalResource, davSession, continuumLocator );
}
} |
206418_8 | public boolean attachSession( WebdavRequest request )
throws DavException
{
if ( !isAuthorized( request ) )
{
throw new DavException( HttpServletResponse.SC_UNAUTHORIZED );
}
request.setDavSession( new ContinuumBuildAgentDavSession() );
return true;
} |
206418_9 | public void releaseSession( WebdavRequest request )
{
request.setDavSession( null );
} |
206437_0 | public void setWkDirPath( URI wkDirPath )
{
protect( "wkDirPath" );
this.wkDirPath = new File( wkDirPath );
} |
206437_1 | public long count( PartitionTxn partitionTxn ) throws LdapException
{
return forward.count( partitionTxn );
} |
206437_2 | @Override
public long greaterThanCount( PartitionTxn partitionTxn, K attrVal ) throws LdapException
{
return forward.greaterThanCount( partitionTxn, attrVal );
} |
206437_3 | @Override
public long lessThanCount( PartitionTxn partitionTxn, K attrVal ) throws LdapException
{
return forward.lessThanCount( partitionTxn, attrVal );
} |
206437_4 | public void setWkDirPath( URI wkDirPath )
{
//.out.println( "IDX Defining a WorkingDir : " + wkDirPath );
protect( "wkDirPath" );
this.wkDirPath = new File( wkDirPath );
} |
206437_5 | public long count( PartitionTxn partitionTxn ) throws LdapException
{
return forward.count( partitionTxn );
} |
206437_6 | @Override
public long greaterThanCount( PartitionTxn partitionTxn, K attrVal ) throws LdapException
{
return forward.greaterThanCount( partitionTxn, attrVal );
} |
206437_7 | @Override
public long lessThanCount( PartitionTxn partitionTxn, K attrVal ) throws LdapException
{
return forward.lessThanCount( partitionTxn, attrVal );
} |
206437_8 | public ConfigWriter( SchemaManager schemaManager, ConfigBean configBean )
{
this.schemaManager = schemaManager;
this.configBean = configBean;
} |
206437_9 | public AdsBaseBean readConfig( Entry entry ) throws Exception
{
// Let's instantiate the bean we need. The upper ObjectClass's name
// will be used to do that
ObjectClass objectClass = findObjectClass( entry.get( SchemaConstants.OBJECT_CLASS_AT ) );
// Instantiating the bean
AdsBaseBean bean = createBean( objectClass );
// Setting its DN
bean.setDn( entry.getDn() );
// Getting the class of the bean
Class<?> beanClass = bean.getClass();
// A flag to know when we reached the 'AdsBaseBean' class when
// looping on the class hierarchy of the bean
boolean adsBaseBeanClassFound = false;
// Looping until the 'AdsBaseBean' class has been found
while ( !adsBaseBeanClassFound )
{
// Checking if we reached the 'AdsBaseBean' class
if ( beanClass == AdsBaseBean.class )
{
adsBaseBeanClassFound = true;
}
// Looping on all fields of the bean
Field[] fields = beanClass.getDeclaredFields();
for ( Field field : fields )
{
// Making the field accessible (we get an exception if we don't do that)
field.setAccessible( true );
// Getting the class of the field
Class<?> fieldClass = field.getType();
// Looking for the @ConfigurationElement annotation
ConfigurationElement configurationElement = field.getAnnotation( ConfigurationElement.class );
if ( configurationElement != null )
{
// Getting the annotation's values
String fieldAttributeType = configurationElement.attributeType();
String fieldObjectClass = configurationElement.objectClass();
String container = configurationElement.container();
boolean isOptional = configurationElement.isOptional();
// Checking if we have a value for the attribute type
if ( ( fieldAttributeType != null ) && ( !"".equals( fieldAttributeType ) ) )
{
readFieldValue( bean, field, entry, fieldAttributeType, !isOptional );
}
// Checking if we have a value for the object class
else if ( ( fieldObjectClass != null ) && ( !"".equals( fieldObjectClass ) ) )
{
// Checking if this is a multi-valued field (which values are stored in a container)
if ( isMultiple( fieldClass ) && ( container != null )
&& ( !"".equals( container ) ) )
{
// Creating the DN of the container
Dn newBase = entry.getDn().add( "ou=" + container );
// Looking for the field values
Collection<AdsBaseBean> fieldValues = read( newBase, fieldObjectClass,
SearchScope.ONELEVEL, !isOptional );
// Setting the values to the field
if ( ( fieldValues != null ) && !fieldValues.isEmpty() )
{
field.set( bean, fieldValues );
}
}
// This is a single-value field
else
{
// Looking for the field values
List<AdsBaseBean> fieldValues = read( entry.getDn(), fieldObjectClass,
SearchScope.ONELEVEL, !isOptional );
// Setting the value to the field
if ( ( fieldValues != null ) && !fieldValues.isEmpty() )
{
field.set( bean, fieldValues.get( 0 ) );
}
}
}
}
}
// Moving to the upper class in the class hierarchy
beanClass = beanClass.getSuperclass();
}
return bean;
} |
206444_0 | @Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
throws Exception {
if (in.readableBytes() < 4) {
return;
}
in.markReaderIndex();
int msgSize = in.readInt();
checkSize(msgSize);
if (in.readableBytes() < msgSize) {
// Incomplete message in buffer.
in.resetReaderIndex();
return;
}
try {
ByteBuffer nioBuffer = maybeDecrypt(in.nioBuffer(in.readerIndex(), msgSize));
Input kryoIn = new Input(new ByteBufferInputStream(nioBuffer));
Object msg = kryos.get().readClassAndObject(kryoIn);
LOG.trace("Decoded message of type {} ({} bytes)",
msg != null ? msg.getClass().getName() : msg, msgSize);
out.add(msg);
} finally {
in.skipBytes(msgSize);
}
} |
206444_1 | public Future<Void> call(Object msg) {
return call(msg, Void.class);
} |
206444_2 | public static Promise<Rpc> createClient(
Map<String, String> config,
final NioEventLoopGroup eloop,
String host,
int port,
final String clientId,
final String secret,
final RpcDispatcher dispatcher) throws Exception {
final RpcConfiguration rpcConf = new RpcConfiguration(config);
int connectTimeoutMs = (int) rpcConf.getConnectTimeoutMs();
final ChannelFuture cf = new Bootstrap()
.group(eloop)
.handler(new ChannelInboundHandlerAdapter() { })
.channel(NioSocketChannel.class)
.option(ChannelOption.SO_KEEPALIVE, true)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeoutMs)
.connect(host, port);
final Promise<Rpc> promise = eloop.next().newPromise();
final AtomicReference<Rpc> rpc = new AtomicReference<Rpc>();
// Set up a timeout to undo everything.
final Runnable timeoutTask = new Runnable() {
@Override
public void run() {
promise.setFailure(new TimeoutException("Timed out waiting to connect to HiveServer2."));
}
};
final ScheduledFuture<?> timeoutFuture = eloop.schedule(timeoutTask,
connectTimeoutMs, TimeUnit.MILLISECONDS);
// The channel listener instantiates the Rpc instance when the connection is established,
// and initiates the SASL handshake.
cf.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture cf) throws Exception {
if (cf.isSuccess()) {
SaslClientHandler saslHandler = new SaslClientHandler(rpcConf, clientId, promise,
timeoutFuture, secret, dispatcher);
Rpc rpc = createRpc(rpcConf, saslHandler, (SocketChannel) cf.channel(), eloop);
saslHandler.rpc = rpc;
saslHandler.sendHello(cf.channel());
} else {
promise.setFailure(cf.cause());
}
}
});
// Handle cancellation of the promise.
promise.addListener(new GenericFutureListener<Promise<Rpc>>() {
@Override
public void operationComplete(Promise<Rpc> p) {
if (p.isCancelled()) {
cf.cancel(true);
}
}
});
return promise;
} |
206444_3 | public Future<Void> call(Object msg) {
return call(msg, Void.class);
} |
206444_4 | public Future<Void> call(Object msg) {
return call(msg, Void.class);
} |
206444_5 | public static Promise<Rpc> createClient(
Map<String, String> config,
final NioEventLoopGroup eloop,
String host,
int port,
final String clientId,
final String secret,
final RpcDispatcher dispatcher) throws Exception {
final RpcConfiguration rpcConf = new RpcConfiguration(config);
int connectTimeoutMs = (int) rpcConf.getConnectTimeoutMs();
final ChannelFuture cf = new Bootstrap()
.group(eloop)
.handler(new ChannelInboundHandlerAdapter() { })
.channel(NioSocketChannel.class)
.option(ChannelOption.SO_KEEPALIVE, true)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeoutMs)
.connect(host, port);
final Promise<Rpc> promise = eloop.next().newPromise();
final AtomicReference<Rpc> rpc = new AtomicReference<Rpc>();
// Set up a timeout to undo everything.
final Runnable timeoutTask = new Runnable() {
@Override
public void run() {
promise.setFailure(new TimeoutException("Timed out waiting to connect to HiveServer2."));
}
};
final ScheduledFuture<?> timeoutFuture = eloop.schedule(timeoutTask,
connectTimeoutMs, TimeUnit.MILLISECONDS);
// The channel listener instantiates the Rpc instance when the connection is established,
// and initiates the SASL handshake.
cf.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture cf) throws Exception {
if (cf.isSuccess()) {
SaslClientHandler saslHandler = new SaslClientHandler(rpcConf, clientId, promise,
timeoutFuture, secret, dispatcher);
Rpc rpc = createRpc(rpcConf, saslHandler, (SocketChannel) cf.channel(), eloop);
saslHandler.rpc = rpc;
saslHandler.sendHello(cf.channel());
} else {
promise.setFailure(cf.cause());
}
}
});
// Handle cancellation of the promise.
promise.addListener(new GenericFutureListener<Promise<Rpc>>() {
@Override
public void operationComplete(Promise<Rpc> p) {
if (p.isCancelled()) {
cf.cancel(true);
}
}
});
return promise;
} |
206444_6 | public static Promise<Rpc> createClient(
Map<String, String> config,
final NioEventLoopGroup eloop,
String host,
int port,
final String clientId,
final String secret,
final RpcDispatcher dispatcher) throws Exception {
final RpcConfiguration rpcConf = new RpcConfiguration(config);
int connectTimeoutMs = (int) rpcConf.getConnectTimeoutMs();
final ChannelFuture cf = new Bootstrap()
.group(eloop)
.handler(new ChannelInboundHandlerAdapter() { })
.channel(NioSocketChannel.class)
.option(ChannelOption.SO_KEEPALIVE, true)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeoutMs)
.connect(host, port);
final Promise<Rpc> promise = eloop.next().newPromise();
final AtomicReference<Rpc> rpc = new AtomicReference<Rpc>();
// Set up a timeout to undo everything.
final Runnable timeoutTask = new Runnable() {
@Override
public void run() {
promise.setFailure(new TimeoutException("Timed out waiting to connect to HiveServer2."));
}
};
final ScheduledFuture<?> timeoutFuture = eloop.schedule(timeoutTask,
connectTimeoutMs, TimeUnit.MILLISECONDS);
// The channel listener instantiates the Rpc instance when the connection is established,
// and initiates the SASL handshake.
cf.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture cf) throws Exception {
if (cf.isSuccess()) {
SaslClientHandler saslHandler = new SaslClientHandler(rpcConf, clientId, promise,
timeoutFuture, secret, dispatcher);
Rpc rpc = createRpc(rpcConf, saslHandler, (SocketChannel) cf.channel(), eloop);
saslHandler.rpc = rpc;
saslHandler.sendHello(cf.channel());
} else {
promise.setFailure(cf.cause());
}
}
});
// Handle cancellation of the promise.
promise.addListener(new GenericFutureListener<Promise<Rpc>>() {
@Override
public void operationComplete(Promise<Rpc> p) {
if (p.isCancelled()) {
cf.cancel(true);
}
}
});
return promise;
} |
206444_7 | public Future<Void> call(Object msg) {
return call(msg, Void.class);
} |
206444_8 | @VisibleForTesting
static RuntimeException convertToSerializableSparkException(Throwable error) {
RuntimeException serializableThrowable = new RuntimeException(
error.getClass().getName() + ": " + Objects.toString(error.getMessage(), ""),
error.getCause() == null ? null : convertToSerializableSparkException(
error.getCause()));
serializableThrowable.setStackTrace(error.getStackTrace());
Arrays.stream(error.getSuppressed())
.map(JobResultSerializer::convertToSerializableSparkException)
.forEach(serializableThrowable::addSuppressed);
return serializableThrowable;
} |
206444_9 | @VisibleForTesting
static RuntimeException convertToSerializableSparkException(Throwable error) {
RuntimeException serializableThrowable = new RuntimeException(
error.getClass().getName() + ": " + Objects.toString(error.getMessage(), ""),
error.getCause() == null ? null : convertToSerializableSparkException(
error.getCause()));
serializableThrowable.setStackTrace(error.getStackTrace());
Arrays.stream(error.getSuppressed())
.map(JobResultSerializer::convertToSerializableSparkException)
.forEach(serializableThrowable::addSuppressed);
return serializableThrowable;
} |
206451_0 | public Node evaluateNode(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
List retVal = evaluate(cexp, ctx);
if (retVal.size() == 0 || retVal.size() > 1) {
StringBuffer msg = new StringBuffer((retVal.size() == 0) ? "No results for expression: '" : "Multiple results for expression: '");
if (cexp instanceof OXPath10Expression) {
msg.append(((OXPath10Expression)cexp).getXpath());
} else {
msg.append(cexp.toString());
}
msg.append('\'');
if (ctx.getRootNode() != null) {
msg.append(" against '");
msg.append(DOMUtils.domToString(ctx.getRootNode()));
msg.append('\'');
}
if (retVal.size() == 0)
throw new FaultException(cexp.getOwner().getConstants().getQnSelectionFailure(), msg.toString(), new Throwable("ignoreMissingFromData"));
if (retVal.size() > 1)
throw new FaultException(cexp.getOwner().getConstants().getQnSelectionFailure(), msg.toString());
}
return (Node) retVal.get(0);
} |
206451_1 | public Node evaluateNode(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
List retVal = evaluate(cexp, ctx);
if (retVal.size() == 0 || retVal.size() > 1) {
StringBuffer msg = new StringBuffer((retVal.size() == 0) ? "No results for expression: '" : "Multiple results for expression: '");
if (cexp instanceof OXPath10Expression) {
msg.append(((OXPath10Expression)cexp).getXpath());
} else {
msg.append(cexp.toString());
}
msg.append('\'');
if (ctx.getRootNode() != null) {
msg.append(" against '");
msg.append(DOMUtils.domToString(ctx.getRootNode()));
msg.append('\'');
}
if (retVal.size() == 0)
throw new FaultException(cexp.getOwner().getConstants().getQnSelectionFailure(), msg.toString(), new Throwable("ignoreMissingFromData"));
if (retVal.size() > 1)
throw new FaultException(cexp.getOwner().getConstants().getQnSelectionFailure(), msg.toString());
}
return (Node) retVal.get(0);
} |
206451_2 | public Node evaluateNode(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
List retVal = evaluate(cexp, ctx);
if (retVal.size() == 0 || retVal.size() > 1) {
StringBuffer msg = new StringBuffer((retVal.size() == 0) ? "No results for expression: '" : "Multiple results for expression: '");
if (cexp instanceof OXPath10Expression) {
msg.append(((OXPath10Expression)cexp).getXpath());
} else {
msg.append(cexp.toString());
}
msg.append('\'');
if (ctx.getRootNode() != null) {
msg.append(" against '");
msg.append(DOMUtils.domToString(ctx.getRootNode()));
msg.append('\'');
}
if (retVal.size() == 0)
throw new FaultException(cexp.getOwner().getConstants().getQnSelectionFailure(), msg.toString(), new Throwable("ignoreMissingFromData"));
if (retVal.size() > 1)
throw new FaultException(cexp.getOwner().getConstants().getQnSelectionFailure(), msg.toString());
}
return (Node) retVal.get(0);
} |
206451_3 | public Node evaluateNode(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
List retVal = evaluate(cexp, ctx);
if (retVal.size() == 0 || retVal.size() > 1) {
StringBuffer msg = new StringBuffer((retVal.size() == 0) ? "No results for expression: '" : "Multiple results for expression: '");
if (cexp instanceof OXPath10Expression) {
msg.append(((OXPath10Expression)cexp).getXpath());
} else {
msg.append(cexp.toString());
}
msg.append('\'');
if (ctx.getRootNode() != null) {
msg.append(" against '");
msg.append(DOMUtils.domToString(ctx.getRootNode()));
msg.append('\'');
}
if (retVal.size() == 0)
throw new FaultException(cexp.getOwner().getConstants().getQnSelectionFailure(), msg.toString(), new Throwable("ignoreMissingFromData"));
if (retVal.size() > 1)
throw new FaultException(cexp.getOwner().getConstants().getQnSelectionFailure(), msg.toString());
}
return (Node) retVal.get(0);
} |
206451_4 | public Node evaluateNode(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
List retVal = evaluate(cexp, ctx);
if (retVal.size() == 0 || retVal.size() > 1) {
StringBuffer msg = new StringBuffer((retVal.size() == 0) ? "No results for expression: '" : "Multiple results for expression: '");
if (cexp instanceof OXPath10Expression) {
msg.append(((OXPath10Expression)cexp).getXpath());
} else {
msg.append(cexp.toString());
}
msg.append('\'');
if (ctx.getRootNode() != null) {
msg.append(" against '");
msg.append(DOMUtils.domToString(ctx.getRootNode()));
msg.append('\'');
}
if (retVal.size() == 0)
throw new FaultException(cexp.getOwner().getConstants().getQnSelectionFailure(), msg.toString(), new Throwable("ignoreMissingFromData"));
if (retVal.size() > 1)
throw new FaultException(cexp.getOwner().getConstants().getQnSelectionFailure(), msg.toString());
}
return (Node) retVal.get(0);
} |
206451_5 | @SuppressWarnings("unchecked")
public List evaluate(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
List result;
Object someRes = null;
try {
someRes = evaluate(cexp, ctx, XPathConstants.NODESET);
} catch (Exception e) {
someRes = evaluate(cexp, ctx, XPathConstants.STRING);
}
if (someRes instanceof List) {
result = (List) someRes;
if (__log.isDebugEnabled()) {
__log.debug("Returned list of size " + result.size());
}
if ((result.size() == 1) && !(result.get(0) instanceof Node)) {
// Dealing with a Java class
Object simpleType = result.get(0);
// Dates get a separate treatment as we don't want to call toString on them
String textVal;
if (simpleType instanceof Date) {
textVal = ISO8601DateParser.format((Date) simpleType);
} else if (simpleType instanceof DurationValue) {
textVal = ((DurationValue)simpleType).getStringValue();
} else {
textVal = simpleType.toString();
}
// Wrapping in a document
Document document = DOMUtils.newDocument();
// Giving our node a parent just in case it's an LValue expression
Element wrapper = document.createElement("wrapper");
Text text = document.createTextNode(textVal);
wrapper.appendChild(text);
document.appendChild(wrapper);
result = Collections.singletonList(text);
}
} else if (someRes instanceof NodeList) {
NodeList retVal = (NodeList) someRes;
if (__log.isDebugEnabled()) {
__log.debug("Returned node list of size " + retVal.getLength());
}
result = new ArrayList(retVal.getLength());
for(int m = 0; m < retVal.getLength(); ++m) {
Node val = retVal.item(m);
if (val.getNodeType() == Node.DOCUMENT_NODE) {
val = ((Document)val).getDocumentElement();
}
result.add(val);
}
} else if (someRes instanceof String) {
// Wrapping in a document
Document document = DOMUtils.newDocument();
Element wrapper = document.createElement("wrapper");
Text text = document.createTextNode((String) someRes);
wrapper.appendChild(text);
document.appendChild(wrapper);
result = Collections.singletonList(text);
} else {
result = null;
}
return result;
} |
206451_6 | @SuppressWarnings("unchecked")
public List evaluate(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
List result;
Object someRes = null;
try {
someRes = evaluate(cexp, ctx, XPathConstants.NODESET);
} catch (Exception e) {
someRes = evaluate(cexp, ctx, XPathConstants.STRING);
}
if (someRes instanceof List) {
result = (List) someRes;
if (__log.isDebugEnabled()) {
__log.debug("Returned list of size " + result.size());
}
if ((result.size() == 1) && !(result.get(0) instanceof Node)) {
// Dealing with a Java class
Object simpleType = result.get(0);
// Dates get a separate treatment as we don't want to call toString on them
String textVal;
if (simpleType instanceof Date) {
textVal = ISO8601DateParser.format((Date) simpleType);
} else if (simpleType instanceof DurationValue) {
textVal = ((DurationValue)simpleType).getStringValue();
} else {
textVal = simpleType.toString();
}
// Wrapping in a document
Document document = DOMUtils.newDocument();
// Giving our node a parent just in case it's an LValue expression
Element wrapper = document.createElement("wrapper");
Text text = document.createTextNode(textVal);
wrapper.appendChild(text);
document.appendChild(wrapper);
result = Collections.singletonList(text);
}
} else if (someRes instanceof NodeList) {
NodeList retVal = (NodeList) someRes;
if (__log.isDebugEnabled()) {
__log.debug("Returned node list of size " + retVal.getLength());
}
result = new ArrayList(retVal.getLength());
for(int m = 0; m < retVal.getLength(); ++m) {
Node val = retVal.item(m);
if (val.getNodeType() == Node.DOCUMENT_NODE) {
val = ((Document)val).getDocumentElement();
}
result.add(val);
}
} else if (someRes instanceof String) {
// Wrapping in a document
Document document = DOMUtils.newDocument();
Element wrapper = document.createElement("wrapper");
Text text = document.createTextNode((String) someRes);
wrapper.appendChild(text);
document.appendChild(wrapper);
result = Collections.singletonList(text);
} else {
result = null;
}
return result;
} |
206451_7 | public boolean containsAll(CorrelationKeySet c) {
Iterator<CorrelationKey> e = c.iterator();
while (e.hasNext())
if (!contains(e.next()))
return false;
return true;
} |
206451_8 | public List<CorrelationKeySet> findSubSets() {
List<CorrelationKeySet> subSets = new ArrayList<CorrelationKeySet>();
// if the key set contains a opaque key and at least one non-opaque key, take out the opaque key
CorrelationKey opaqueKey = null;
boolean containsNonOpaque = false;
CorrelationKeySet explicitKeySet = new CorrelationKeySet();
for( CorrelationKey ckey : correlationKeys ) {
// assumes only ONE opaque key if there is
if( ckey.getCorrelationSetName().equals("-1") ) {
opaqueKey = ckey;
} else {
containsNonOpaque = true;
}
explicitKeySet.add(ckey);
}
if( opaqueKey != null && containsNonOpaque ) {
explicitKeySet.correlationKeys.remove(opaqueKey);
}
// we are generating (2 powered by the number of correlation keys) number of sub-sets
for( int setIndex = 0; setIndex < Math.pow(2, explicitKeySet.correlationKeys.size()); setIndex++ ) {
CorrelationKeySet subKeySet = new CorrelationKeySet();
int bitPattern = setIndex; // the bitPattern will be 0b0000, 0b0001, 0b0010 and so on
Iterator<CorrelationKey> ckeys = explicitKeySet.iterator();
while( ckeys.hasNext() && bitPattern > 0 ) { // bitPattern > 0 condition saves half of the iterations
CorrelationKey ckey = ckeys.next();
if( (bitPattern & 0x01) > 0 ) {
subKeySet.add(ckey);
}
bitPattern = bitPattern >> 1;
}
if(!subKeySet.isEmpty()) { // we don't want an empty set
subSets.add(subKeySet);
}
}
if( subSets.isEmpty() ) {
subSets.add(new CorrelationKeySet());
}
return subSets;
} |
206451_9 | public List<String> getNodeIds() throws DatabaseException {
Connection con = null;
PreparedStatement ps = null;
try {
con = getConnection();
ps = con.prepareStatement(GET_NODEIDS, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = ps.executeQuery();
ArrayList<String> nodes = new ArrayList<String>();
while (rs.next()) {
String nodeId = rs.getString(1);
if (nodeId != null)
nodes.add(rs.getString(1));
}
if (__log.isDebugEnabled())
__log.debug("getNodeIds: " + nodes);
return nodes;
} catch (SQLException se) {
throw new DatabaseException(se);
} finally {
close(ps);
close(con);
}
} |
206452_0 | public static String expandProperties(String input, Map props) {
if (input == null) {
return null;
}
Matcher matcher = EXPANSION_PATTERN.matcher(input);
StringBuffer expanded = new StringBuffer(input.length());
while (matcher.find()) {
String propName = matcher.group(2);
String value = (String) props.get(propName);
// if no value is found, use a value equal to the original expression
if (value == null) {
value = matcher.group(0);
}
// Fake a literal replacement since Matcher.quoteReplacement() is not present in 1.4.
matcher.appendReplacement(expanded, "");
expanded.append(value);
}
matcher.appendTail(expanded);
return expanded.toString();
} |
206452_1 | public static String expandSystemProperties(String input) {
return expandProperties(input, System.getProperties());
} |
206452_2 | public static String encodeEmail(String str) {
// obfuscate mailto's: turns them into hex encoded,
// so that browsers can still understand the mailto link
Matcher mailtoMatch = MAILTO_PATTERN.matcher(str);
while (mailtoMatch.find()) {
String email = mailtoMatch.group(1);
//System.out.println("email=" + email);
String hexed = encode(email);
str = str.replaceFirst("mailto:"+email, "mailto:"+hexed);
}
return obfuscateEmail(str);
} |
206452_3 | public static String obfuscateEmail(String str) {
Matcher emailMatch = EMAIL_PATTERN.matcher(str);
while (emailMatch.find()) {
String at = emailMatch.group(1);
//System.out.println("at=" + at);
str = str.replaceFirst(at, "-AT-");
String dot = emailMatch.group(2) + emailMatch.group(3) + emailMatch.group(4);
String newDot = emailMatch.group(2) + "-DOT-" + emailMatch.group(4);
//System.out.println("dot=" + dot);
str = str.replaceFirst(dot, newDot);
}
return str;
} |
206452_4 | public static String encodeEmail(String str) {
// obfuscate mailto's: turns them into hex encoded,
// so that browsers can still understand the mailto link
Matcher mailtoMatch = MAILTO_PATTERN.matcher(str);
while (mailtoMatch.find()) {
String email = mailtoMatch.group(1);
//System.out.println("email=" + email);
String hexed = encode(email);
str = str.replaceFirst("mailto:"+email, "mailto:"+hexed);
}
return obfuscateEmail(str);
} |
206452_5 | public synchronized void purge()
{
cache.clear();
} |
206452_6 | public boolean isBannedwordslisted(String str) {
return isBannedwordslisted(str, null, null);
} |