id
stringlengths
7
14
text
stringlengths
1
37.2k
514315_100
@POST @Path("/{clazz}/{keyName}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.key-indices.class.object.post", absolute = true) public Response postIndexKey(@PathParam("graphname") final String graphName, @PathParam("clazz") final String clazz, @PathParam("keyName") final String keyName) { final Class keyClass; if (clazz.equals(Tokens.VERTEX)) { keyClass = Vertex.class; } else if (clazz.equals(Tokens.EDGE)) { keyClass = Edge.class; } else { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()); } if (keyName == null || keyName.isEmpty()) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()); } final RexsterApplicationGraph rag = this.getRexsterApplicationGraph(graphName); final KeyIndexableGraph graph = this.getKeyIndexableGraph(graphName); try { graph.createKeyIndex(keyName, keyClass); rag.tryCommit(); this.resultObject.put(Tokens.QUERY_TIME, this.sh.stopWatch()); } catch (JSONException ex) { logger.error(ex); rag.tryRollback(); final JSONObject error = generateErrorObjectJsonFail(ex); throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build()); } return Response.ok(this.resultObject).build(); }
520116_111
public void printUsage() { HelpFormatter formatter = new HelpFormatter(); String usage = "java -classpath path com.bc.ceres.standalone.MetadataEngineMain -t /path/targetItem.suff -v templateX=/path/metadata.txt.vm [-v templateY=/path/report.xml.vm] [optional options] [arg1] [arg2] ..."; formatter.printHelp(usage, options); }
520146_100
@Override public long getBinIndex(double lat, double lon) { final int row = getRowIndex(lat); final int col = getColIndex(lon, row); return baseBin[row] + col; }
525255_0
public void visit(IndexVisitor<Key, Value> visitor) { root().visit(this, visitor); }
526139_189
boolean hasValidArea() { return area != null && !area.isEmpty(); }
533032_1
public void orWith(DocIdSetCardinality other) { min = Math.max(min, other.min); max = Math.min(1.0, max + other.max); }
536958_2
Node createFilterNode(Document doc) { Node filterNode = doc.createElement("filter"); Node filterNameNode = doc.createElement("filter-name"); filterNameNode.appendChild(doc.createTextNode("infrared")); Node filterClassNode = doc.createElement("filter-class"); filterClassNode.appendChild(doc.createTextNode(FILTER_CLASS)); filterNode.appendChild(filterNameNode); filterNode.appendChild(filterClassNode); return filterNode; }
540945_11
public static Context context(int ioThreads) { return new Context(ioThreads); }
542927_85
public Object[] getJobIds() { return workflow.getJobIds(); }
551254_19
public static File createTempDirectory() throws IOException { File tmp = File.createTempFile("bpelunit", ""); tmp.delete(); tmp.mkdir(); return tmp; }
558963_40
public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); }
574877_37
@Override public AmazonServiceException handle(HttpResponse response) throws Exception { JsonContent jsonContent = JsonContent.createJsonContent(response, jsonFactory); byte[] rawContent = jsonContent.getRawContent(); String errorCode = errorCodeParser.parseErrorCode(response, jsonContent); AmazonServiceException ase = createException(errorCode, response, jsonContent.getJsonNode(), rawContent); // The marshallers instantiate the exception without providing a // message. If the Exception included a message member find it and // add it here. if (ase.getErrorMessage() == null) { ase.setErrorMessage(errorMessageParser.parseErrorMessage(response, jsonContent.getJsonNode())); } ase.setErrorCode(errorCode); ase.setServiceName(response.getRequest().getServiceName()); ase.setStatusCode(response.getStatusCode()); ase.setErrorType(getErrorTypeFromStatusCode(response.getStatusCode())); ase.setRawResponse(rawContent); String requestId = getRequestIdFromHeaders(response.getHeaders()); if (requestId != null) { ase.setRequestId(requestId); } ase.setHttpHeaders(response.getHeaders()); return ase; }
578435_68
public static String dasherize(String word) { return word.replaceAll("_", "-"); }
581866_1
public static IOTransition.IOLetter fullLetter(String message) { Matcher matcher = lettersPattern.matcher(message); if (matcher.matches()) { if (matcher.group(1).equals("^")) { if (matcher.group(2) == null) { return new IOTransition.IOLetter(new Message(matcher.group(5), matcher.group(5), matcher.group(6)), IOAlphabetType.INTERNAL); } else { if (matcher.group(4).equals("->")) { return new IOTransition.IOLetter(new Message(matcher.group(3), matcher.group(5), matcher.group(6)), IOAlphabetType.INTERNAL); } else { return new IOTransition.IOLetter(new Message(matcher.group(5), matcher.group(3), matcher.group(6)), IOAlphabetType.INTERNAL); } } } if (matcher.group(1).equals("!")) { if (matcher.group(4).equals("->")) { return new IOTransition.IOLetter(new Message(matcher.group(3), matcher.group(5), matcher.group(6)), IOAlphabetType.OUTPUT); } else { return new IOTransition.IOLetter(new Message(matcher.group(5), matcher.group(3), matcher.group(6)), IOAlphabetType.OUTPUT); } } else { if (matcher.group(4).equals("->")) { return new IOTransition.IOLetter(new Message(matcher.group(3), matcher.group(5), matcher.group(6)), IOAlphabetType.INPUT); } else { return new IOTransition.IOLetter(new Message(matcher.group(5), matcher.group(3), matcher.group(6)), IOAlphabetType.INPUT); } } } throw rejectLetter(message); }
585380_4
public boolean isCloserTo(KUID key, KUID otherId) { return compareTo(key, otherId) < 0; }
589869_0
public void reset(int i, int j) { this.i = i; this.j = j; x = 0; y = 0; detector = 0; view_zenith = 0.0; sun_zenith = 0.0; delta_azimuth = 0.0; sun_azimuth = 0.0; mus = 0.0; muv = 0.0; airMass = 0.0; altitude = 0.0; windu = 0.0; windv = 0.0; press_ecmwf = 0.0; ozone_ecmwf = 0.0; l1flags = 0; l2flags = 0; SATURATED_F = 0; ANNOT_F = 0; for (int n = 0; n < Constants.L1_BAND_NUM; n++) { TOAR[n] = 0.0; rho_ag[n] = 0.0; rho_toa[n] = 0.0; rho_top[n] = 0.0; rhoR[n] = 0.0; transRv[n] = 0.0; transRs[n] = 0.0; sphalbR[n] = 0.0; } }
590532_4
public static String encode(String raw) { String[] parts = parseId(raw); return shorten(toBigInteger(parts[0])) + "-" + shorten(toBigInteger(parts[1], parts[2])) + "-" + shorten(new BigInteger(parts[3])); }
591784_24
public void checkMetadata( RepositorySystemSession session, UpdateCheck<Metadata, MetadataTransferException> check ) { if ( check.getLocalLastUpdated() != 0 && !isUpdatedRequired( session, check.getLocalLastUpdated(), check.getPolicy() ) ) { if ( logger.isDebugEnabled() ) { logger.debug( "Skipped remote update check for " + check.getItem() + ", locally installed metadata up-to-date." ); } check.setRequired( false ); return; } Metadata metadata = check.getItem(); RemoteRepository repository = check.getRepository(); File metadataFile = check.getFile(); if ( metadataFile == null ) { throw new IllegalArgumentException( String.format( "The metadata '%s' has no file attached", metadata ) ); } boolean fileExists = check.isFileValid() && metadataFile.exists(); File touchFile = getTouchFile( metadata, metadataFile ); Properties props = read( touchFile ); String updateKey = getUpdateKey( metadataFile, repository ); String dataKey = getDataKey( metadata, metadataFile, check.getAuthoritativeRepository() ); String error = getError( props, dataKey ); long lastUpdated; if ( error == null ) { if ( fileExists ) { // last update was successful lastUpdated = getLastUpdated( props, dataKey ); } else { // this is the first attempt ever lastUpdated = 0; } } else if ( error.length() <= 0 ) { // metadata did not exist lastUpdated = getLastUpdated( props, dataKey ); } else { // metadata could not be transferred String transferKey = getTransferKey( metadata, metadataFile, repository ); lastUpdated = getLastUpdated( props, transferKey ); } if ( isAlreadyUpdated( session.getData(), updateKey ) ) { if ( logger.isDebugEnabled() ) { logger.debug( "Skipped remote update check for " + check.getItem() + ", already updated during this session." ); } check.setRequired( false ); if ( error != null ) { check.setException( newException( error, metadata, repository ) ); } } else if ( lastUpdated == 0 ) { check.setRequired( true ); } else if ( isUpdatedRequired( session, lastUpdated, check.getPolicy() ) ) { check.setRequired( true ); } else if ( fileExists ) { if ( logger.isDebugEnabled() ) { logger.debug( "Skipped remote update check for " + check.getItem() + ", locally cached metadata up-to-date." ); } check.setRequired( false ); } else { if ( error == null || error.length() <= 0 ) { check.setRequired( false ); check.setException( newException( error, metadata, repository ) ); } else { if ( session.isTransferErrorCachingEnabled() ) { check.setRequired( false ); check.setException( newException( error, metadata, repository ) ); } else { check.setRequired( true ); } } } }
597631_48
@Override public int getMinScore() { return 0; }
608316_15
@Override public boolean isNew(Persistent persistent) { return isNew; }
608843_3
public native void setIntArray(int address, int[] ints, int offset, throws NullPointerException, ;
618103_0
@Override protected Void doInBackground(final String... args) { errors = new ArrayList<>(); List<Bank> banks; if (bankId != -1) { banks = new ArrayList<>(); banks.add(getBankFromDb(bankId, parent)); } else { banks = getBanksFromDb(parent); } getDialog().setMax(banks.size()); int i = 0; for (final Bank bank : banks) { publishProgress(i, bank); if (isListingAllBanks() && bank.isDisabled()) { LoggingUtils.logDisabledBank(bank); continue; } try { bank.update(); bank.updateAllTransactions(); bank.closeConnection(); saveBank(bank, parent); i++; LoggingUtils.logBankUpdate(bank, true); } catch (final BankException e) { this.errors.add(bank.getName() + " (" + bank.getUsername() + ")"); Timber.e(e, "Could not update bank."); } catch (final LoginException e) { this.errors.add(bank.getName() + " (" + bank.getUsername() + ")"); DBAdapter.disable(bank, parent); } catch (BankChoiceException e) { this.errors.add(bank.getName() + " (" + bank.getUsername() + ")"); } catch (IOException e) { this.errors.add(bank.getName() + " (" + bank.getUsername() + ")"); if (NetworkUtils.isInternetAvailable()) { Timber.e(e, "IO error talking to bank"); } } if (isContentProviderEnabled()) { final ArrayList<Account> accounts = bank.getAccounts(); for (final Account account : accounts) { AutoRefreshService.broadcastTransactionUpdate(parent, bank.getDbId(), account.getId()); } } } publishProgress(i, null); return null; }
618492_55
public static double bytesToDouble(final byte[] bytes) { if (bytes.length < 8) { throw new IllegalArgumentException("Byte array must be 8 bytes wide."); } return Double.longBitsToDouble(bytesToLong(bytes)); }
618681_8
@Override public List<String> loadNBSP(String lang) { if (lang == null || lang.isEmpty()) { throw new IllegalArgumentException("Lang must be filled to search for file!"); } List<String> result = loadForKey(lang); if (result == null) { int index = lang.indexOf('_'); if (index < 0) return null; // cannot split key result = loadForKey(lang.substring(0, index)); } return result; }
620505_0
private List<String> getHosts(List<NodeMetadata> nodes) { return Lists.transform(Lists.newArrayList(nodes), ew Function<NodeMetadata, String>() { @Override public String apply(NodeMetadata node) { tring publicIp = Iterables.get(node.getPublicAddresses(), 0) .getHostName(); eturn String.format("%s:%d", publicIp, CLIENT_PORT); } }); }
625665_0
protected void resize(int newcount) { byte newbuf[] = new byte[Math.max(buf.length << 1, newcount)]; System.arraycopy(buf, 0, newbuf, 0, pos); buf = newbuf; }
643234_13
public void show(String scenario, String step) { sendContextMessage(step); }
651333_3
public static Expression parse(String text) { text = text.replaceAll("\\s*,\\s*", ","); StringTokenizer st = new StringTokenizer(text, "$%,\'[])", true); MethodExpression root = new MethodExpression("eval"); Stack<MethodExpression> stack = new Stack<MethodExpression>(); stack.push(root); try { while (st.hasMoreTokens()) { String token = st.nextToken(); if (token.equals("%")) { if (st.hasMoreTokens()) { String s = st.nextToken(); s = Character.toUpperCase(s.charAt(0)) + s.substring(1); stack.peek().addExpression(new ParameterExpression(s)); if (st.hasMoreTokens() && !st.nextToken().equals("%")) { break; } } } else if (token.equals("$")) { if (st.hasMoreTokens()) { String s = st.nextToken(); s = s.substring(0, s.length() - 1); MethodExpression m = new MethodExpression(s); stack.peek().addExpression(m); stack.push(m); } } else if (token.equals(")") || token.equals("]")) { stack.pop(); } else if (token.equals(",")) { //ignore } else if (token.equals("\'")) { StringBuilder sb = new StringBuilder(); while (st.hasMoreTokens()) { String str = st.nextToken(); if (str.equals("\'")) break; sb.append(str); } stack.peek().addExpression(new TextExpression(sb.toString())); } else if (token.equals("[")) { MethodExpression m = new MethodExpression("notNull"); stack.peek().addExpression(m); stack.push(m); } else { stack.peek().addExpression(new TextExpression(token)); } } } catch (Exception e) { e.printStackTrace(); } ArrayList<Expression> e = root.getExpressions(); if (e.size() == 1) { return e.get(0); } else { return root; } }
657157_0
@Override public org.apache.lucene.search.Query parse(String query) throws ParseException { String q = ""; for (int i = 0; i < query.length(); i++) { if (query.charAt(i) == '"' && i + 1 < query.length() && !Character.isWhitespace(query.charAt(i + 1))) { if (i > 0 && !Character.isWhitespace(query.charAt(i - 1))) { q += '\\'; } } q += query.charAt(i); } return super.parse(q); }
662539_11
public static void validateSourceProducts(String[] sourceFilePaths) throws IOException { final int sourceProductLength = sourceFilePaths[0].length(); for (String sourceFilePath : sourceFilePaths) { if (sourceFilePath.length() != sourceProductLength) { throw new IOException("Inconsistent source products names (have not same length) - must be checked!"); } } final int ccProductPrefixIndex = sourceFilePaths[0].indexOf("_CCL"); for (String sourceFilePath : sourceFilePaths) { if (sourceFilePath.indexOf("_CCL") != ccProductPrefixIndex) { throw new IOException("Inconsistent source products names (CC identifiers not at same position) - must be checked!"); } if (!sourceFilePath.substring(ccProductPrefixIndex, ccProductPrefixIndex + 6). equals(sourceFilePaths[0].substring(ccProductPrefixIndex, ccProductPrefixIndex + 6))) { throw new IOException("Inconsistent source products names (CC identifiers different) - must be checked!"); } } }
663418_71
@Override public String toString(Object obj) { if(obj==null) return "null"; if(obj.toString().trim().equals("")) return "blank"; return obj.toString(); }
666662_0
public void append(char c) { if (isFull()) { removeFirst(); } insertLast(c); }
667236_1
protected String extractPackageNameFromAndroidManifest(File androidManifestFile) throws MojoExecutionException { final URL xmlURL; try { xmlURL = androidManifestFile.toURI().toURL(); } catch (MalformedURLException e) { throw new MojoExecutionException("Error while trying to figure out package name from inside AndroidManifest.xml file " + androidManifestFile, e); } final DocumentContainer documentContainer = new DocumentContainer(xmlURL); final Object packageName = JXPathContext.newContext(documentContainer).getValue("manifest/@package", String.class); return (String) packageName; }
678267_10
public static DateTime parseXSDDateTime(String input) { Matcher m = XSD_DATETIME.matcher(input); if (!m.find()) { throw new IllegalArgumentException(input + " is not a valid XML Schema 1.1 dateTime."); } int year = Integer.parseInt(m.group(1)); int month = Integer.parseInt(m.group(3)); int day = Integer.parseInt(m.group(4)); int hour = 0, minute = 0, second = 0, millis = 0; boolean hasEndOfDayFrag = m.group(11) != null; if (!hasEndOfDayFrag) { hour = Integer.parseInt(m.group(6)); minute = Integer.parseInt(m.group(7)); second = Integer.parseInt(m.group(8)); // Parse fractional seconds // m.group(9), if not null/empty should be Strings such as ".5" or // ".050" which convert to 500 and 50, respectively. if (m.group(9) != null && !m.group(9).isEmpty()) { // parse as Double as a quick hack to drop trailing 0s. // e.g. ".0500" becomes 0.05 double d = Double.parseDouble(m.group(9)); // Something like the following would allow for int-sized // precision, but joda-time 1.6 only supports millis (i.e. <= 999). // see: org.joda.time.field.FieldUtils.verifyValueBounds // int digits = String.valueOf(d).length() - 2; // fractionalSeconds = (int) (d * Math.pow(10, digits)); millis = (int) (d * 1000); } } DateTimeZone zone = null; if (m.group(13) != null) { String tmp = m.group(13); if (tmp.equals("Z")) { tmp = "+00:00"; } zone = DateTimeZone.forID(tmp); } DateTime dt = new DateTime(year, month, day, hour, minute, second, millis, zone); if (hasEndOfDayFrag) { return dt.plusDays(1); } return dt; }
684382_1
public static boolean validateMinJREVersion(String runtimeVersion, String minVersion){ String[] requestedVersioning = minVersion.split("\\."); String[] clientVersioning = runtimeVersion.split("\\."); if (requestedVersioning.length < 3 || clientVersioning.length < 3) return false; // First major update if (Integer.parseInt(clientVersioning[0]) > Integer.parseInt(requestedVersioning[0])) return true; else{ // Checking Java version if (Integer.parseInt(clientVersioning[1]) > Integer.parseInt(requestedVersioning[1])) return true; // Checking update else if (Integer.parseInt(clientVersioning[1]) == Integer.parseInt(requestedVersioning[1])){ // non-GA or non-FCS release won't be supported if(clientVersioning[2].indexOf("-") != -1) return false; int rUpdatePart1 = 0; int rUpdatePart2 = 0; int underbar = requestedVersioning[2].indexOf("_"); if ( underbar == -1){ rUpdatePart1 = Integer.parseInt(requestedVersioning[2]); } else { rUpdatePart1 = Integer.parseInt(requestedVersioning[2].substring(0, underbar)); rUpdatePart2 = Integer.parseInt(requestedVersioning[2].substring(underbar + 1, requestedVersioning[2].length())); } int cUpdatePart1 = 0; int cUpdatePart2 = 0; underbar = clientVersioning[2].indexOf("_"); if ( underbar == -1) { cUpdatePart1 = Integer.parseInt(clientVersioning[2]); } else { cUpdatePart1 = Integer.parseInt(clientVersioning[2].substring(0, underbar)); cUpdatePart2 = Integer.parseInt(clientVersioning[2].substring(underbar + 1, clientVersioning[2].length())); } if (cUpdatePart1 > rUpdatePart1) return true; else if (cUpdatePart1 == rUpdatePart1) { if (cUpdatePart2 > rUpdatePart2 || cUpdatePart2 == rUpdatePart2) return true; else return false; } else return false; } else return false; } }
688360_72
@Override public void writePublicKey(PublicKey key, String comment, OutputStream out) throws IOException, GeneralSecurityException { StringBuilder b = new StringBuilder(82); PublicKeyEntry.appendPublicKeyEntry(b, key); // Append first line of comment - if available String line = firstLine(comment); if (GenericUtils.isNotEmpty(line)) { b.append(' ').append(line); } write(out, b.toString()); }
690050_71
protected String generateCode() { return UUID.randomUUID().toString(); }
692484_7
@Override public int getPartition(GramKey key, Gram value, int numPartitions) { // see: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/lib/partition/BinaryPartitioner.java?revision=816664&view=markup int length = key.getLength()-1; int right = (offset + length) % length; int hash = WritableComparator.hashBytes(key.getBytes(), right); return (hash & Integer.MAX_VALUE) % numPartitions; }
697210_2
public String[] readNext() throws IOException { while (recordsQueue.isEmpty() && !eof) { char[] data = new char[CHUNK_SIZE]; int size = r.read(data); if (size == -1) { break; } processChunk(data, size); } if (recordsQueue.isEmpty()) { if (wasEscapeOrNotOpeningQuote) { handlePreviousEscapeOrQuote(null); } if (quotedField) { throw new IllegalStateException("Missing quote character to close the quote char at [" + quotedFieldStartRow + "," + quotedFieldStartCol + "]"); } if (openRecord.isEmpty()) { return null; } else { if (openField.length() > 0) { openRecord.add(openField.toString()); openField.delete(0, openField.length()); } String[] result = openRecord.toArray(new String[]{}); openRecord.clear(); return result; } } return recordsQueue.removeFirst(); }
702991_21
public static void closeDocumentQuietly(COSDocument document) { try { if (document != null) { document.close(); } } catch (IOException e) { logger.warn("Error occured during the close of a COSDocument : " + e.getMessage()); } }
710733_1
@Override public byte[] create(T value) throws AvroBaseException { switch (createType) { case CUSTOM: { // loop until we don't get an ID collision byte[] row; do { row = keygen.get(); } while (!put(row, value, 0)); return row; } case RANDOM: { // loop until we don't get a random ID collision byte[] row; do { row = Bytes.toBytes(random.nextLong()); } while (!put(row, value, 0)); return row; } case SEQUENTIAL: { HTableInterface table = getTable(); try { byte[] row; do { row = getNextRow(table, family); } while (!put(row, value, 0)); return row; } catch (IOException e) { throw new AvroBaseException("Failed to increment column", e); } finally { pool.putTable(table); } } case TIMESTAMP: case REVERSE_TIMESTAMP: { HTableInterface table = getTable(); try { byte[] row; do { long l = createType == CreateType.TIMESTAMP ? TIMESTAMP_GENERATOR.getTimestamp() : TIMESTAMP_GENERATOR.getInvertedTimestamp(); row = Bytes.toBytes(l); } while (!put(row, value, 0)); return row; } finally { pool.putTable(table); } } } return null; }
711931_2
public boolean checkAuth() { throw new RuntimeException("This method is not available on this protocol"); }
726694_18
@Override public double findMaximumDistanceToLeaf() { return this.findMaximumDistanceToLeaf(0.0); }
747707_9
public static void writeBytes(PrintStream print, byte[] bytes) { writeBytes(print, bytes, 0, bytes.length); }
749137_19
protected static JSONObject parseJsonPart(Reader reader) throws JSONException { return (JSONObject)(new JSONTokener(reader).nextValue()); }
762097_13
public static void bind(AnnotationBindingContext bindingContext) { List<AnnotationInstance> annotations = bindingContext.getIndex().getAnnotations( JPADotNames.NAMED_QUERY ); for ( AnnotationInstance query : annotations ) { bindNamedQuery( bindingContext.getMetadataImplementor(), query ); } annotations = bindingContext.getIndex().getAnnotations( JPADotNames.NAMED_QUERIES ); for ( AnnotationInstance queries : annotations ) { for ( AnnotationInstance query : JandexHelper.getValue( queries, "value", AnnotationInstance[].class ) ) { bindNamedQuery( bindingContext.getMetadataImplementor(), query ); } } annotations = bindingContext.getIndex().getAnnotations( JPADotNames.NAMED_NATIVE_QUERY ); for ( AnnotationInstance query : annotations ) { bindNamedNativeQuery( bindingContext.getMetadataImplementor(), query ); } annotations = bindingContext.getIndex().getAnnotations( JPADotNames.NAMED_NATIVE_QUERIES ); for ( AnnotationInstance queries : annotations ) { for ( AnnotationInstance query : JandexHelper.getValue( queries, "value", AnnotationInstance[].class ) ) { bindNamedNativeQuery( bindingContext.getMetadataImplementor(), query ); } } annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.NAMED_QUERY ); for ( AnnotationInstance query : annotations ) { bindNamedQuery( bindingContext.getMetadataImplementor(), query ); } annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.NAMED_QUERIES ); for ( AnnotationInstance queries : annotations ) { for ( AnnotationInstance query : JandexHelper.getValue( queries, "value", AnnotationInstance[].class ) ) { bindNamedQuery( bindingContext.getMetadataImplementor(), query ); } } annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.NAMED_NATIVE_QUERY ); for ( AnnotationInstance query : annotations ) { bindNamedNativeQuery( bindingContext.getMetadataImplementor(), query ); } annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.NAMED_NATIVE_QUERIES ); for ( AnnotationInstance queries : annotations ) { for ( AnnotationInstance query : JandexHelper.getValue( queries, "value", AnnotationInstance[].class ) ) { bindNamedNativeQuery( bindingContext.getMetadataImplementor(), query ); } } }
763770_9
@Override public List<TopicModelImpl> fetchTopicsByPropertyRange(String propUri, Number from, Number to) { return buildTopics(queryIndexByPropertyRange(topicIndex, propUri, from, to)); }
766240_36
public void tick(final double progress) { if (progress < 0 || progress > 1.0) { throw new IllegalStateException("New progress must be between 0 and 1"); } if (isCancelled()) { throw new IllegalStateException("Animation is cancelled"); } if (!isRunning()) { throw new IllegalStateException("Animation is not currently in progress"); } if (isFinished()) { throw new IllegalStateException("Animation is already finished"); } if (progress == 0.0) { logic.onStart(); } logic.onUpdate(logic.interpolate(progress)); if (progress == 1.0) { logic.onComplete(); } currentProgress = progress; }
766548_687
private Principal getPrincipal() { try { SecurityContext securityCtx = SecurityContextHolder.getContext(); if (securityCtx == null) { throw new AuthorizationException("No security context available."); } Authentication auth = securityCtx.getAuthentication(); if (auth == null) { return null; } Object obj = auth.getPrincipal(); if (obj instanceof UserDetails) { UserDetails user = (UserDetails) obj; ExtendedUserDetails extUser = (ExtendedUserDetails) user; return new DefaultPrincipal(extUser.getUsername(), extUser.getPerson().getOpenSocialId(), extUser .getPerson().getId()); } else { return null; } } catch (Exception ex) { logger.error("Error occurred populating Principal object for current request.", ex); if (exceptionOnError) { throw new AuthorizationException("Error occurred populating Principal object for current request."); } else { return null; } } }
771158_3
@Override public int compare(Statement first, Statement second) { // Cannot use Statement.equals as it does not take Context into account, // but can check for reference equality (==) if (first == second) { return EQUAL; } if (first.getSubject().equals(second.getSubject())) { if (first.getPredicate().equals(second.getPredicate())) { if (first.getObject().equals(second.getObject())) { // Context is the only part of a statement that should legitimately be null if (first.getContext() == null) { if (second.getContext() == null) { return EQUAL; } else { return BEFORE; } } else if (second.getContext() == null) { return AFTER; } else { return ValueComparator.getInstance().compare(first.getContext(), second.getContext()); } } else { return ValueComparator.getInstance().compare(first.getObject(), second.getObject()); } } else { return ValueComparator.getInstance().compare(first.getPredicate(), second.getPredicate()); } } else { return ValueComparator.getInstance().compare(first.getSubject(), second.getSubject()); } }
774619_99
public static void validate(String xml) { byte[] bytes = null; String encoding = getEncoding(xml); if (encoding != null) { try { bytes = xml.getBytes(encoding); } catch (UnsupportedEncodingException e) { // ignore, handled below } } if (bytes == null) { // no encoding in declaration or unsupported encoding // fall back to platform default bytes = xml.getBytes(); } InputStream input = null; try { input = new ByteArrayInputStream(bytes); validate(input); } finally { if (input != null) { try { input.close(); } catch (IOException e) { // we tried } } } }
774658_11
static Protocol determineProtocol(String server) { checkNotNull(server); String[] splitServer = server.split(":"); Protocol protocol = Protocol.HTTPS; if (splitServer.length > 1) { String port = splitServer[1]; String protocolInTheUrl = splitServer[0].toLowerCase(); if (splitServer[1].startsWith("//")) { if (Objects.equal(protocolInTheUrl, "http")) return Protocol.HTTP; else if (Objects.equal(protocolInTheUrl, "https")) return Protocol.HTTPS; port = splitServer[2]; } if (!"443".equals(port)) { protocol = Protocol.HTTP; } } return protocol; }
782257_47
@Override public Connection open( final String aName ) throws IOException { return open( aName, ConnectorService.READ_WRITE ); }
790859_125
public void destroy() { _log.debug("Destroying deployment " + getName()); // Clean up our list of activations, just in case something's left _serviceBindings.clear(); _components.clear(); _referenceBindings.clear(); getValidatorRegistryLoader().unregisterValidators(); getTransformerRegistryLoader().unregisterTransformers(); getDomain().getEventPublisher().publish(new ApplicationUndeployedEvent(this)); getDomain().destroy(); }
806019_7
@Override public Short getShort() { return value.shortValue(); }
811072_0
public String sayHelloEJB(String name) { return "Hello " + name; }
812511_8
public static X500Principal toPrincipal(String globusID) { if (globusID == null) { return null; } String id = globusID.trim(); StringBuilder buf = new StringBuilder(id.length()); if (!id.isEmpty()) { final int IDLE = 0; final int VALUE = 1; final int KEY = 2; int state = IDLE; int cEnd = 0; char[] asChars = id.toCharArray(); /* * walk in reverse order and split into RDN */ for (int i = asChars.length - 1; i >= 0; i--) { char c = asChars[i]; switch (state) { case KEY: if (c == '/' || c == ' ') { /* handle names with comma according rfc1779 */ String s = id.substring(i + 1, cEnd + 1); int commaIndex = s.indexOf(','); if (commaIndex != -1) { s = s.substring(0, commaIndex) + "\\" + s.substring(commaIndex); } buf.append(s).append(','); state = IDLE; } break; case VALUE: if (c == '=') { state = KEY; } break; case IDLE: default: // idle if (c == '/' || c == ' ') { continue; } else { cEnd = i; state = VALUE; } } } // delete last extra comma buf.deleteCharAt(buf.length() - 1); } String dn = buf.toString(); return new X500Principal(dn, KEYWORD_MAP); }
816192_4
public String getName() { return "BeanShell Plugin"; }
819907_5
static String annotationToString(Annotation annotation) { StringBuilder string = new StringBuilder(); string.append('@').append(annotation.annotationType().getName()).append('('); String classAffix = ".class"; String quotationMark = "\""; try { List<Method> methods = Arrays.asList(annotation.annotationType().getDeclaredMethods()); methods.sort(new Comparator<Method>() { @Override public int compare(Method o1, Method o2) { return o1.toGenericString().compareTo(o2.toGenericString()); } }); for (int i = 0; i < methods.size(); i++) { string.append(methods.get(i).getName()).append('='); Object value = methods.get(i).invoke(annotation); if (value instanceof boolean[]) { appendInBraces(string, Arrays.toString((boolean[]) value)); } else if (value instanceof byte[]) { appendInBraces(string, Arrays.toString((byte[]) value)); } else if (value instanceof short[]) { appendInBraces(string, Arrays.toString((short[]) value)); } else if (value instanceof int[]) { appendInBraces(string, Arrays.toString((int[]) value)); } else if (value instanceof long[]) { appendInBraces(string, Arrays.toString((long[]) value)); } else if (value instanceof float[]) { appendInBraces(string, Arrays.toString((float[]) value)); } else if (value instanceof double[]) { appendInBraces(string, Arrays.toString((double[]) value)); } else if (value instanceof char[]) { appendInBraces(string, Arrays.toString((char[]) value)); } else if (value instanceof String[]) { String[] strings = (String[]) value; String[] quoted = new String[strings.length]; for (int j = 0; j < strings.length; j++) { quoted[j] = quotationMark + strings[j] + quotationMark; } appendInBraces(string, Arrays.toString(quoted)); } else if (value instanceof Class<?>[]) { Class<?>[] classes = (Class<?>[]) value; String[] names = new String[classes.length]; for (int j = 0; j < classes.length; j++) { names[j] = classes[j].getName() + classAffix; } appendInBraces(string, Arrays.toString(names)); } else if (value instanceof Object[]) { appendInBraces(string, Arrays.toString((Object[]) value)); } else if (value instanceof String) { string.append('"').append(value).append('"'); } else if (value instanceof Class<?>) { string.append(((Class<?>) value).getName()).append(classAffix); } else { string.append(value); } if (i < methods.size() - 1) { string.append(", "); } } } catch (IllegalAccessException | IllegalArgumentException | SecurityException | InvocationTargetException ex) { // we cannot do it our way, revert to default Annotation.toString() ProbeLogger.LOG.cannotUseUnifiedAnnotationToStringConversion(ex); return annotation.toString(); } return string.append(')').toString(); }
828909_18
@Override public void preCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> e, final Store store, final List<StoreFile> candidates) throws IOException { requirePermission(getTableName(e.getEnvironment()), null, null, Action.ADMIN); }
832025_13
public Blog getBlogEntries() throws IOException { Response<BlogFeedDto> response = blogApi.getBlogEntries().execute(); return response.body().toBlog(); }
832676_97
void addFeatureRepositories(Object featureService) throws MojoExecutionException { if (featureRepositories != null) { try { Class<? extends Object> serviceClass = featureService.getClass(); Method addRepositoryMethod = serviceClass.getMethod("addRepository", URI.class); for (String featureRepo : featureRepositories) { addRepositoryMethod.invoke(featureService, URI.create(featureRepo)); } } catch (Exception e) { throw new MojoExecutionException("Failed to add feature repositories to karaf", e); } } }
832679_7
@Override public String render(OsFamily arg0) { return exec( "git clone " + (vcsBranch != null ? "-b " + vcsBranch + " " : "") + url + " " + MODULES_DIR + module).render(arg0); }
832680_187
@Override public synchronized Class loadClass( String name ) throws ClassNotFoundException { if ( childDelegation ) { Class<?> c = findLoadedClass( name ); if ( c == null ) { try { c = findClass( name ); } catch ( ClassNotFoundException e ) { if ( parent == null ) { throw e; } else { c = parent.loadClass( name ); } } } return c; } else { return super.loadClass( name ); } }
834344_39
public static boolean isZipCode(final String zipCode) { if (zipCode != null) { return zipCode.matches("\\d{5}((-| +)\\d{4})?$"); } return false; }
844592_1
public ExceptionHandlingStrategy makeExceptionHandlingStrategy( final Level logLevel, final PrintStream originalPrintStream) { return new LogPerLineExceptionHandlingStrategy(logLevel); }
846296_0
public SourceTemplate(Writer writer, String className, List<BsonDocumentObjectElement> annotatedElements) { this.writer = writer; this.className = className; this.annotatedElements = annotatedElements; }
851175_3
static boolean mfgAlbedoFileNameMatches(String fileName) { if (!(fileName.matches("MSA_Albedo_L2.0_V[0-9].[0-9]{2}_[0-9]{3}_[0-9]{4}_[0-9]{3}_[0-9]{3}.(?i)(hdf)"))) { throw new IllegalArgumentException("Input file name '" + fileName + "' does not match naming convention: 'MSA_Albedo_L2.0_Vm.nn_sss_yyyy_fff_lll.HDF'"); } return true; }
859322_0
public static byte[] execute(URL url, InputStream input, String encoding) throws IOException { byte[] bytes; try { StringBuilder sb = new StringBuilder(); UnicodeReader reader = new UnicodeReader(input, encoding); try { char[] cbuf = new char[32]; int r; while ((r = reader.read(cbuf, 0, 32)) != -1) { sb.append(cbuf, 0, r); } String str = sb.toString(); if (!str.contains("ui:component")) { try { String fileEncoding = reader.getEncoding(); InputSource is = new InputSource(new StringReader(str)); is.setEncoding(fileEncoding); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMLDocumentFilter[] filters = { new Writer(baos, fileEncoding) { protected void printStartElement(QName element, XMLAttributes attributes) { fPrinter.print('<'); fPrinter.print(element.rawname); int attrCount = attributes != null ? attributes.getLength() : 0; for (int i = 0; i < attrCount; i++) { String aname = attributes.getQName(i); String avalue = attributes.getValue(i); fPrinter.print(' '); fPrinter.print(aname); fPrinter.print("=\""); printAttributeValue(avalue); fPrinter.print('"'); } if (HTMLElements.getElement(element.rawname).isEmpty()) { fPrinter.print(' '); fPrinter.print('/'); } fPrinter.print('>'); fPrinter.flush(); } protected void printAttributeValue(String text) { fPrinter.print(StringEscapeUtils.escapeHtml(text)); fPrinter.flush(); } protected void printEntity(String name) { fPrinter.print('&'); fPrinter.print('#'); fPrinter.print(HTMLEntities.get(name)); fPrinter.print(';'); fPrinter.flush(); } }}; DOMParser parser = new DOMParser(); parser.setFeature("http://cyberneko.org/html/features/balance-tags", false); parser.setFeature("http://cyberneko.org/html/features/scanner/notify-builtin-refs", true); parser.setProperty("http://cyberneko.org/html/properties/default-encoding", fileEncoding); parser.setProperty("http://cyberneko.org/html/properties/names/elems", "lower"); parser.setProperty("http://cyberneko.org/html/properties/filters", filters); parser.parse(is); str = "<!DOCTYPE html>" + baos.toString(fileEncoding); } catch (Exception e) { logger.error(e.getMessage(), e); } if (url.getFile().contains("META-INF/templates")) { str = "<ui:component xmlns:ui=\"http://java.sun.com/jsf/facelets\">" + Pattern.compile("(<\\!DOCTYPE html>)|(</?html[^>]*>)|(<title>[^<]*</title>)", Pattern.CASE_INSENSITIVE).matcher(str).replaceAll("").replaceAll( "\\$\\{template\\.body\\}", "<ui:insert />") + "</ui:component>"; } } bytes = str.getBytes(reader.getEncoding()); } finally { reader.close(); } } catch (IOException e) { throw e; } return bytes; }
860694_1
public static void zipDir(final File zipFile, final File srcDir, final String prefix) throws IOException { ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile)); try { addZipPrefixes(srcDir, out, prefix); addZipDir(srcDir, out, prefix); } finally { // Complete the ZIP file IOUtils.closeQuietly(out); } }
860937_24
@Override public final DoubleVector subtractFrom(double v) { DenseDoubleVector newv = new DenseDoubleVector(vector.length); for (int i = 0; i < vector.length; i++) { newv.set(i, v - vector[i]); } return newv; }
862445_0
@Override public Iterator<Document> iterator() { if (inputStream != null) { throw new IllegalStateException("already fetched inputStream!"); } return new MultiXmlDocumentIterator(); }
870849_0
public static RuntimeException exceptionWithFriendlyMessageFor(Exception e) { Throwable cause = getRootCause(e); String message = cause.getMessage(); if (message == null) { message = cause.getClass().getSimpleName(); } if (cause instanceof JSchException) { message = "SSH: " + message; } return new RuntimeException(message, cause); }
876766_2
@Override public void execute() throws MojoExecutionException, MojoFailureException { client = new DefaultHttpClient(); if (hasProxy()) { enableAxisProxy(); configureHttpClientProxy(); } initializeConfluenceTemplate(); boolean isVersion30AndAbove = isConfluenceVersion30andAbove(); try { confluenceTemplate.export(client, exportSpaces, isVersion30AndAbove, this.outputDirectory); } catch (RemoteException e) { throw new MojoExecutionException(e.getMessage(), e); } catch (IOException e) { throw new MojoExecutionException(e.getMessage() , e); } catch (ServiceException e) { throw new MojoExecutionException(e.getMessage() , e.getLinkedCause()); } catch (HttpException e){ throw new MojoExecutionException(e.getMessage() , e); } finally{ client.getConnectionManager().shutdown(); } }
884758_0
public static GrizzlyExecutorService createInstance() { return createInstance(ThreadPoolConfig.DEFAULT); }
889932_13
@Override public String getSignatureMethod() { return METHOD; }
892275_5
@SuppressWarnings("ConstantConditions") // Guarding public API nullability. public static RxJava3CallAdapterFactory createWithScheduler(Scheduler scheduler) { if (scheduler == null) throw new NullPointerException("scheduler == null"); return new RxJava3CallAdapterFactory(scheduler, false); }
899555_4
static Collection<String> elemental2ElementTags(final MetaClass type) { final Collection<String> customElementTags = customElementTags(type); if (!customElementTags.isEmpty()) { return customElementTags; } return Elemental2TagMapping.getTags(type.asClass()); }
901534_1
@Override public UmlModel loadModel(File modelFile) throws UmlModelException { if (modelFile == null) { return new UmlModel(UmlModelProducer.getInstance().createUmlModel(null)); } try { Model model = getUmlRootModel(modelFile); UmlModel umlModel = new UmlModel(model); return umlModel; } catch (IOException e) { logger.error(e, "Canot load Template " + modelFile.getName()); throw new UmlModelException("Cannot load Template " + modelFile.getName(), e); } catch (RuntimeException re) { logger.error(re, "Canot load Template " + modelFile.getName()); throw new UmlModelException("Cannot load Template " + modelFile.getName(), re); } }
904044_3
;
904873_9
public String getResourceName() { return m_resourceName; }
905232_85
public void register( final String[] protocols, final URLStreamHandlerService urlStreamHandlerService ) { LOGGER.debug( "Registering protocols [" + Arrays.toString( protocols ) + "] to service [" + urlStreamHandlerService + "]" ); NullArgumentException.validateNotEmptyContent( protocols, true, "Protocol" ); NullArgumentException.validateNotNull( urlStreamHandlerService, "URL stream handler service" ); for( String protocol : protocols ) { m_proxies.put( protocol, createProxy( urlStreamHandlerService ) ); } }
906854_11
public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); }
907274_29
public <T extends EventBus> T register(Class<T> busType, Object subscriber) { return this.register(busType,subscriber,null); }
908709_29
public static String cleanTerm(String term) { term = term.toLowerCase().trim(); if (term.matches("[0-9\\-\\.:]+")) return "<NUM>"; if (term.startsWith("http:") || term.startsWith("ftp:")) return "<URL>"; while (term.length() > 0 && term.startsWith("-")) term = term.substring(1, term.length()); while (term.length() > 0 && term.endsWith("-")) term = term.substring(0, term.length()-1); term = term.replaceAll("\"", ""); term = term.replaceAll("\'", ""); term = term.replaceAll("\\[", ""); term = term.replaceAll("\\]", ""); term = term.replaceAll("\\?", ""); term = term.replaceAll("\\*", ""); term = term.replaceAll("\\(", ""); term = term.replaceAll("\\)", ""); term = term.replaceAll("\\^", ""); term = term.replaceAll("\\+", ""); term = term.replaceAll("//", ""); term = term.replaceAll(";", ""); term = term.replaceAll("%", ""); term = term.replaceAll(",", ""); term = term.replaceAll("!", ""); return term.trim(); }
909809_66
void addFreeMarker(final Marker marker, final double xPos, final double yPos) { markers.add(new FreeMarker(marker, xPos, yPos)); }
912291_21
public byte[] encode(String val, String delimiters) { return codecs[0].encode(val); }
915029_21
@Override public E remove(final int index) { return d_inner.remove((int) d_indices.get(index)); }
917362_1
Solve() { }
917947_24
public boolean canProxy(final Class<?> type) { return !Modifier.isFinal(type.getModifiers()); }
918574_14
public static String normalizeResourcePath(final String path) { if (path == null) { return null; } String normalizedPath = replaceSlashes(path.trim()); if (normalizedPath.startsWith("/") && normalizedPath.length() > 1) { normalizedPath = normalizedPath.substring(1); } return normalizedPath; }
921110_24
@Override public DatabagItem apply(String from) { DatabagItem bootstrapConfig = api.getDatabagItem(databag, from); checkState(bootstrapConfig != null, "databag item %s/%s not found", databag, from); return bootstrapConfig; }
922437_16
@Override public Contribution addContribution(final BigDecimal amount, final String comment) throws NotEnoughMoneyException, UnauthorizedOperationException { tryAccess(new RgtFeature.Contribute(), Action.WRITE); // For exception safety keep the order. if (AuthToken.getAsTeam() != null) { if (AuthToken.getAsTeam().getUserTeamRight(AuthToken.getMember()).contains(UserTeamRight.BANK)) { Log.model().trace("Doing a contribution in the name of a team: " + AuthToken.getAsTeam().getId()); } else { throw new UnauthorizedOperationException(SpecialCode.TEAM_CONTRIBUTION_WITHOUT_BANK); } } final DaoContribution contribution = getDao().addContribution(AuthToken.getMember().getDao(), DaoGetter.get(AuthToken.getAsTeam()), amount, comment); // setStateObject(getStateObject().eventAddContribution()); // Contributing automatically puts the feature in your follow list follow(AuthToken.getMember()); return Contribution.create(contribution); }
922501_4
public static List<String> getEntries(File root) { return walk(root.toURI(), root); }
927454_3
static boolean waitUntil(Duration timeout, BooleanSupplier condition) throws InterruptedException { int waited = 0; while (!condition.getAsBoolean() && waited < timeout.toMillis()) { Thread.sleep(100L); waited = +100; } return condition.getAsBoolean(); }
936063_9
public void process(ISO9660Config iso9660Config, RockRidgeConfig rrConfig, JolietConfig jolietConfig, ElToritoConfig elToritoConfig) throws HandlerException { if (iso9660Config == null) { throw new NullPointerException("Cannot create ISO without ISO9660Config."); } ((LogicalSectorPaddingHandler) streamHandler).setPadEnd(iso9660Config.getPadEnd()); // Last handler added processes data first if (jolietConfig != null) { streamHandler = new JolietHandler(streamHandler, root, jolietConfig); } if (elToritoConfig != null) { streamHandler = new ElToritoHandler(streamHandler, elToritoConfig); } streamHandler = new ISO9660Handler(streamHandler, root, iso9660Config, rrConfig); streamHandler = new FileHandler(streamHandler, root); streamHandler.startDocument(); // System Area streamHandler.startElement(new ISO9660Element("SA")); streamHandler.endElement(); // Volume Descriptor Set streamHandler.startElement(new ISO9660Element("VDS")); streamHandler.endElement(); // Boot Info Area streamHandler.startElement(new ISO9660Element("BIA")); streamHandler.endElement(); // Path Table Area streamHandler.startElement(new ISO9660Element("PTA")); streamHandler.endElement(); // Directory Records Area streamHandler.startElement(new ISO9660Element("DRA")); streamHandler.endElement(); // Boot Data Area streamHandler.startElement(new ISO9660Element("BDA")); streamHandler.endElement(); // File Contents Area streamHandler.startElement(new ISO9660Element("FCA")); streamHandler.endElement(); streamHandler.endDocument(); }
940337_6
static String getRelativeFileInternal(File canonicalBaseFile, File canonicalFileToRelativize) { ArrayList<String> basePath = getPathComponents(canonicalBaseFile); ArrayList<String> pathToRelativize = getPathComponents(canonicalFileToRelativize); //if the roots aren't the same (i.e. different drives on a windows machine), we can't construct a relative //path from one to the other, so just return the canonical file if (!basePath.get(0).equals(pathToRelativize.get(0))) { return canonicalFileToRelativize.getPath(); } int commonDirs; StringBuilder sb = new StringBuilder(); for (commonDirs=1; commonDirs<basePath.size() && commonDirs<pathToRelativize.size(); commonDirs++) { if (!basePath.get(commonDirs).equals(pathToRelativize.get(commonDirs))) { break; } } boolean first = true; for (int i=commonDirs; i<basePath.size(); i++) { if (!first) { sb.append(File.separatorChar); } else { first = false; } sb.append(".."); } first = true; for (int i=commonDirs; i<pathToRelativize.size(); i++) { if (first) { if (sb.length() != 0) { sb.append(File.separatorChar); } first = false; } else { sb.append(File.separatorChar); } sb.append(pathToRelativize.get(i)); } if (sb.length() == 0) { return "."; } return sb.toString(); }
944926_18
public void register(Object object) { subscribeAll(finder.findAllSubscribers(object)); }
947990_0
@Override public boolean isValid(Asociado asociado, ConstraintValidatorContext context) { if (asociado == null || asociado.getFechaNacimiento() == null) return true; context.disableDefaultConstraintViolation(); if (Strings.isNullOrEmpty(asociado.getDni())) { boolean mayorDeEdad = asociado.getFechaNacimiento().plus(18, ChronoUnit.YEARS).isBefore(LocalDate.now()); if (mayorDeEdad) { context.buildConstraintViolationWithTemplate(MSG_REQUERIDO_MAYOR_EDAD).addConstraintViolation(); return false; } else { return true; } } return validarDniNie(asociado.getDni(), context); }
952585_7
public void setSecurityDispatcher(SecurityDispatcher securityDispatcher) { this.securityDispatcher = securityDispatcher; }