Exemplo n.º 1
0
 public DocumentAffiliation(String id, String index, String rawText) {
   this.id = id;
   this.index = ContentCleaner.clean(index);
   if (rawText.matches(".+ \\([^\\(\\)]*\\)$")) {
     rawText = StringUtils.reverse(rawText).replaceFirst("\\)", "").replaceFirst("\\( ", " ,");
     rawText = StringUtils.reverse(rawText);
   }
   this.rawText = MetadataTools.cleanAndNormalize(rawText);
   this.tokens = new ArrayList<Token<AffiliationLabel>>();
 }
Exemplo n.º 2
0
 /**
  * parse IPV6 ARPA domain to IP bytes.
  *
  * @param name an ARPA string.
  * @return ARPA.
  */
 private static NetworkInBytes parseIpV6Arpa(String name) {
   LOGGER.debug("parseIp6Arpa, name:" + name);
   String arpa = StringUtils.removeEndIgnoreCase(name, CHAR_DOT + DomainUtil.IPV6_ARPA_SUFFIX);
   arpa = StringUtils.remove(arpa, CHAR_DOT);
   String ip = StringUtils.reverse(arpa);
   String fullIp = StringUtils.rightPad(ip, 32, '0');
   byte[] startIpBytes = DatatypeConverter.parseHexBinary(fullIp);
   int networkMask = StringUtils.length(arpa) * 4;
   IPv6Address fromByteArray = IPv6Address.fromByteArray(startIpBytes);
   IPv6Network network =
       IPv6Network.fromAddressAndMask(
           fromByteArray, IPv6NetworkMask.fromPrefixLength(networkMask));
   NetworkInBytes result =
       new NetworkInBytes(
           IpVersion.V6, network.getFirst().toByteArray(), network.getLast().toByteArray());
   return result;
 }
Exemplo n.º 3
0
 private String getHash(String data) {
   String reversedHash = StringUtils.reverse(data);
   String reversedHashMd5 = cryptoUtils.getDigest(reversedHash);
   return reversedHashMd5;
 }
 public static void identifyDuplicateJars(
     List<File> jarFileListInDistribution,
     File distributionVersion,
     HashSet<String> distributionDuplicateJarList,
     ArrayList<String> unidentifiedVersionJars) {
   Iterator<File> itJarList = jarFileListInDistribution.iterator();
   ArrayList<String> tempArr = new ArrayList<String>();
   ArrayList<File> pathListForAddedJarToJarVersions = new ArrayList<File>();
   HashMap<String, String> jarVersions = new HashMap<String, String>();
   StringBuilder builder = new StringBuilder();
   Pattern numeric = Pattern.compile("[^0-9_.-]");
   Pattern nonNumeric = Pattern.compile("[a-zA-Z]");
   while (itJarList.hasNext()) {
     File jarFilePath = itJarList.next();
     String jarName = (jarFilePath).getName();
     if (!jarFilePath
         .getAbsolutePath()
         .contains(
             distributionVersion.getName().replaceAll(".zip", "")
                 + File.separator
                 + TEMP_DIRECTORY
                 + File.separator)) {
       for (int letter = jarName.length() - 1; letter >= 0; letter--) {
         char singleChar = jarName.charAt(letter);
         Matcher matcher = numeric.matcher(Character.toString(singleChar));
         // Find all matches
         if (!matcher.find()) {
           // Get the matching string
           builder.append(singleChar);
         } else if (nonNumeric.matcher(Character.toString(singleChar)).find()) {
           if (builder.length() > 1) {
             tempArr.add(builder.toString());
             builder.setLength(0);
           } else {
             builder.setLength(0);
           }
         }
       }
       int max;
       int previousMax = 0;
       String[] version = new String[1];
       for (String element : tempArr) {
         max = element.length();
         if (max > previousMax) {
           previousMax = max;
           version[0] = element;
         }
       }
       tempArr.clear();
       if (version[0] != null) {
         String jar = jarName.split((StringUtils.reverse(version[0])))[0];
         if (jar.length() >= 2) {
           if (jarVersions.containsKey(jar)) {
             if (!jarVersions.get(jar).equals(jarName.split(jar)[1])) {
               // removing patches - plugins duplication
               if (distributionDuplicateJarList.toString().contains(jarName)) {
                 for (String itemDistributionDuplicateJarList : distributionDuplicateJarList) {
                   if (itemDistributionDuplicateJarList.contains(jarName)
                       && (itemDistributionDuplicateJarList.contains("patches")
                           || itemDistributionDuplicateJarList.contains("plugins"))) {
                     if (!(jarFilePath.getAbsolutePath().contains("patches")
                         || jarFilePath.getAbsolutePath().contains("plugins"))) {
                       distributionDuplicateJarList.add(jarFilePath.getAbsolutePath());
                     }
                   }
                 }
               } else {
                 distributionDuplicateJarList.add(jarFilePath.getAbsolutePath());
               }
               for (File pathListForAddedJarToJarVersion : pathListForAddedJarToJarVersions) {
                 String path = pathListForAddedJarToJarVersion.toString();
                 if (path.contains(jar + jarVersions.get(jar))) {
                   distributionDuplicateJarList.add(path);
                   break;
                 }
               }
             }
           } else {
             jarVersions.put(jar, jarName.split(jar)[1]);
             pathListForAddedJarToJarVersions.add(jarFilePath);
           }
         } else {
           log.info("Unable to identify the version " + jar);
           unidentifiedVersionJars.add(jarFilePath.getAbsolutePath());
         }
       } else {
         jarVersions.put(jarName, null);
         pathListForAddedJarToJarVersions.add(jarFilePath);
       }
     }
   }
 }