Example usage for java.util HashMap values

List of usage examples for java.util HashMap values

Introduction

In this page you can find the example usage for java.util HashMap values.

Prototype

public Collection<V> values() 

Source Link

Document

Returns a Collection view of the values contained in this map.

Usage

From source file:ch.puzzle.itc.mobiliar.business.deploy.boundary.DeploymentBoundary.java

private List<DeploymentEntity> latestPerContextAndGroup(List<DeploymentEntity> resultList) {
    HashMap<ContextEntity, HashMap<ResourceGroupEntity, DeploymentEntity>> latestByContext = new HashMap<>();
    for (DeploymentEntity deployment : resultList) {
        if (!latestByContext.containsKey(deployment.getContext())) {
            HashMap<ResourceGroupEntity, DeploymentEntity> latestByResourceGrp = new HashMap<>();
            latestByResourceGrp.put(deployment.getResourceGroup(), deployment);
            latestByContext.put(deployment.getContext(), latestByResourceGrp);
        } else {/*from  ww w  .j a  v a 2  s . c om*/
            HashMap<ResourceGroupEntity, DeploymentEntity> innerMap = latestByContext
                    .get(deployment.getContext());
            if (!innerMap.containsKey(deployment.getResourceGroup())) {
                innerMap.put(deployment.getResourceGroup(), deployment);
            } else {
                DeploymentEntity latestSoFar = innerMap.get(deployment.getResourceGroup());
                if (deployment.getDeploymentDate().after(latestSoFar.getDeploymentDate())) {
                    innerMap.put(deployment.getResourceGroup(), deployment);
                } else if (deployment.getDeploymentDate().equals(latestSoFar.getDeploymentDate())
                        && deployment.getId() > latestSoFar.getId()) {
                    innerMap.put(deployment.getResourceGroup(), deployment);
                }
            }
        }
    }
    List<DeploymentEntity> latestList = new ArrayList<>();
    for (HashMap<ResourceGroupEntity, DeploymentEntity> groupedDeployments : latestByContext.values()) {
        latestList.addAll(groupedDeployments.values());
    }
    return latestList;
}

From source file:com.tesora.dve.sql.schema.PETable.java

protected void updateExistingKeys(SchemaContext pc, UserTable ut) throws PEException {
    HashMap<String, Key> persKeys = new HashMap<String, Key>();
    HashMap<String, Key> persCons = new HashMap<String, Key>();
    HashMap<String, PEKey> transKeys = new HashMap<String, PEKey>();
    HashMap<String, PEForeignKey> transCons = new HashMap<String, PEForeignKey>();
    for (PEKey c : getKeys(pc)) {
        if (c.isForeign())
            transCons.put(c.getName().getCapitalized().get(), (PEForeignKey) c);
        else/*from  ww w.  j a  v  a  2  s .c o  m*/
            transKeys.put(c.getName().getCapitalized().get(), c);
    }
    for (Key uc : ut.getKeys()) {
        String name = uc.getName().toUpperCase().trim();
        if (uc.isForeignKey()) {
            PEForeignKey was = transCons.remove(name);
            boolean same = (was != null);
            if (same) {
                PEForeignKey apc = PEForeignKey.load(uc, pc, null);
                updateColumnPositions(pc, was, apc);
                String anydiffs = was.differs(pc, apc, true);
                if (anydiffs != null) {
                    same = false;
                    transCons.put(name, was);
                }
            }
            if (!same)
                persCons.put(name, uc);
        } else {
            PEKey was = transKeys.remove(name);
            boolean same = (was != null);
            if (same) {
                PEKey apc = PEKey.load(uc, pc, null);
                updateColumnPositions(pc, was, apc);
                String anydiffs = was.differs(pc, apc, true);
                if (anydiffs != null) {
                    same = false;
                    transKeys.put(name, was);
                }
            }
            if (!same)
                persKeys.put(name, uc);
        }
    }
    // now transCols has columns not in persCols, and persCols has columns not in transCols
    // the former are additions, the latter are removals
    for (Key uc : persCons.values()) {
        ut.removeKey(uc);
    }
    for (Key uc : persKeys.values()) {
        ut.removeKey(uc);
    }
    pc.beginSaveContext();
    try {
        for (PEKey c : transKeys.values()) {
            ut.addKey(c.persistTree(pc));
        }
        for (PEForeignKey c : transCons.values()) {
            ut.addKey(c.persistTree(pc));
        }
    } finally {
        pc.endSaveContext();
    }
}

From source file:de.joinout.criztovyl.tools.directory.DirectoryChanges.java

/**
 * Locates all changed files, does not include new or deleted files.<br>
 * As first there is created/received a map with hash-strings as keys and
 * {@link Path}s as values for the current and previous
 * {@link FileList} via {@link FileList#getMappedHashedModifications()}.
 * Then all keys of the previous map are removed from the current map and
 * the remaining values are returned.<br>
 * Only files which content changed are included.
 * /*from  w w w.  ja  v  a 2 s.  c  o  m*/
 * @return a {@link Set} of {@link Path}s
 * @param forceRecalculate whether there should be a recalculation of the changed files
 * @see FileList#getMappedHashedModifications()
 */
public Set<Path> getChangedFiles(boolean forceRecalculate) {

    if (forceRecalculate || changed == null) { //(Re-)calculate if is wanted or there is no previous calculation

        // Get all new and deleted files, they are not included in the modified
        // files, add them to list which files are ignored
        final Set<Path> ignore = new HashSet<>();
        ignore.addAll(getDeletedFiles());
        ignore.addAll(getNewFiles());

        if (logger.isDebugEnabled())
            logger.debug("Files ignored: {}", new TreeSet<>(ignore));

        // Create a map for modificated files and put modifications map from current directory
        final HashMap<String, Path> mod = new HashMap<>(current.getMappedHashedModifications(ignore));

        //Receive modifications from previous directory
        Map<String, Path> mod_p = previous.getMappedHashedModifications(ignore);

        //Intersect map keys
        Set<String> intersection = new HashSet<>(mod.keySet());
        intersection.retainAll(mod_p.keySet());

        if (logger.isDebugEnabled()) {

            if (!(mod_p.size() > 500))
                logger.debug("Modifications map of previous list: {}", new TreeMap<>(mod_p));
            else
                logger.debug("Previous modification map is bigger than 500 elements, will not print out.");

            if (!(mod_p.size() > 500))
                logger.debug("Modifications map of current list: {}", new TreeMap<>(mod));
            else
                logger.debug("Current modification map is bigger than 500 elements, will not print out.");

            if (!(mod_p.size() > 500))
                logger.debug("Intersection of above: {}", intersection);
            else
                logger.debug("Intersection set is bigger than 500 elements, will not print out.");
        }

        //Merge maps
        mod.putAll(mod_p);

        // Remove everything which is in both maps
        mod.keySet().removeAll(new TreeSet<>(intersection));

        //Only files which contents changed stay in map
        //Iterate over keys
        for (Iterator<String> i = mod.keySet().iterator(); i.hasNext();) {

            //Get path
            Path path = mod.get(i.next());

            //Check if file has changed (may throw I/O exception)
            try {
                if (contentChanged(path))

                    //Remove if is not newer then complement file
                    if (!FileUtils.isFileNewer(path.getFile(), getComplementPath(path).getFile()))
                        i.remove();
                    else
                        ;

                //Has not changed, remove from map
                else
                    i.remove();
            } catch (IOException e) { //Catch IOException, remove from map to avoid further errors
                i.remove();
                if (logger.isWarnEnabled())
                    logger.warn(
                            "Caught IOException while testing if file is newer: \"{}\". Removing from modifications to prevent further errors.",
                            path);
                if (logger.isDebugEnabled())
                    logger.debug(e);
            }
        }

        //Save for reuse
        changed = new HashSet<>(mod.values());
    }

    //Return changed files
    return changed;
}

From source file:ca.inverse.sogo.engine.source.SOGoUtilities.java

/**
        /* ww w  .  j  a v a  2  s.  co  m*/
Sample output of c_settings :
        
 Calendar = {
 DragHandleVertical = 122;
 FolderColors = {
     "flachapelle:Calendar/personal" = "#FF6666";
     "lmarcotte:Calendar/2633-49F5AB80-1-ECD55D0" = "#CC33FF";
     "lmarcotte:Calendar/personal" = "#99FF99";
 };
 FolderShowAlarms = {
     "lmarcotte:Calendar/personal" = YES;
 };
 FolderShowTasks = {
     "lmarcotte:Calendar/personal" = YES;
 };
 FolderSyncTags = {
     "lmarcotte:Calendar/2633-49F5AB80-1-ECD55D0" = "a bb oo";
     "lmarcotte:Calendar/personal" = toto;
 };
 InactiveFolders = (
 );
 SubscribedFolders = (
     "flachapelle:Calendar/personal"
 );
 View = weekview;
  };
          
  As an example, for :
          
  FolderSyncTags = {
     "lmarcotte:Calendar/2633-49F5AB80-1-ECD55D0" = "a bb oo";
  };
        
  we'll eventually check, in sogo_folder_info:
          
  c_folder_type = 'Appointment' AND
  c_path2 = 'lmarcotte' AND
  c_path ENDS WITH 'Calendar/2633-49F5AB80-1-ECD55D0'
          
 */
public static HashMap getSyncTags(SOGoSyncSource source, int type, SyncContext context, String username,
        FunambolLogger log) {
    Vector<String> folders;
    HashMap h;

    h = new HashMap();

    // For now, we only support sync tags for calendars (events and tasks). So if we detect
    // a contact source, we return immediately.
    if (type == SOGoSyncSource.SOGO_CONTACT)
        return h;

    folders = new Vector<String>();

    try {
        ResultSet rs;
        Statement s;

        // We first fetch the user's time zone
        s = source.getDBConnection().createStatement();
        rs = s.executeQuery("SELECT c_settings FROM sogo_user_profile WHERE c_uid = '" + username + "'");

        if (rs.next()) {
            String data;

            data = rs.getString(1);

            // We've got no c_settings, return immediately
            if (data == null || data.length() == 0) {
                rs.close();
                s.close();
                return h;
            }

            try {
                JSONObject json, jsonCalendar;
                log.info("About to parse: " + data);
                json = (JSONObject) JSONValue.parse(data);

                if (json != null) {
                    jsonCalendar = (JSONObject) json.get("Calendar");

                    if (jsonCalendar != null) {
                        String key, value;
                        Iterator it;

                        json = (JSONObject) jsonCalendar.get("FolderSyncTags");
                        if (json != null) {
                            it = json.keySet().iterator();
                            while (it != null && it.hasNext()) {
                                key = it.next().toString();
                                value = (String) json.get(key);
                                h.put(value.toLowerCase(), key);
                            }
                        }

                        json = (JSONObject) jsonCalendar.get("FolderSynchronize");
                        if (json != null) {
                            it = json.keySet().iterator();
                            while (it != null && it.hasNext()) {
                                folders.add(it.next().toString());
                            }
                        }
                    }
                }
            } catch (Exception pe) {
                log.error("Exception occured in getSyncTags(): " + pe.toString(), pe);
            }
        }

        // We cleanup what we have to sync, if necessary. We only keep
        // the keys that are actually in "folders". 
        h.values().retainAll(folders);
        rs.close();
        s.close();

    } catch (Exception e) {
        log.error("Exception occured in getSyncTags(): " + e.toString(), e);
    }

    return h;
}

From source file:com.wasteofplastic.askyblock.commands.Challenges.java

/**
 * Checks if a player has enough for a challenge. Supports two types of
 * checks, inventory and island. Removes items if required.
 * //from w w  w. j av a 2 s  .c om
 * @param player
 * @param challenge
 * @param type
 * @return true if the player has everything required
 */

public boolean hasRequired(final Player player, final String challenge, final String type) {
    // Check money
    double moneyReq = 0D;
    if (Settings.useEconomy) {
        moneyReq = getChallengeConfig().getDouble("challenges.challengeList." + challenge + ".requiredMoney",
                0D);
        if (moneyReq > 0D) {
            if (!VaultHelper.econ.has(player, Settings.worldName, moneyReq)) {
                player.sendMessage(
                        ChatColor.RED + plugin.myLocale(player.getUniqueId()).challengeserrorNotEnoughItems);
                String desc = ChatColor.translateAlternateColorCodes('&',
                        getChallengeConfig().getString("challenges.challengeList." + challenge + ".description")
                                .replace("[label]", Settings.ISLANDCOMMAND));
                List<String> result = new ArrayList<String>();
                if (desc.contains("|")) {
                    result.addAll(Arrays.asList(desc.split("\\|")));
                } else {
                    result.add(desc);
                }
                for (String line : result) {
                    player.sendMessage(ChatColor.RED + line);
                }
                return false;
            }
        }
    }
    final String reqList = getChallengeConfig()
            .getString("challenges.challengeList." + challenge + ".requiredItems");
    // The format of the requiredItems is as follows:
    // Material:Qty
    // or
    // Material:DamageModifier:Qty
    // This second one is so that items such as potions or variations on
    // standard items can be collected
    if (type.equalsIgnoreCase("inventory")) {
        List<ItemStack> toBeRemoved = new ArrayList<ItemStack>();
        Material reqItem;
        int reqAmount = 0;
        if (!reqList.isEmpty()) {
            for (final String s : reqList.split(" ")) {
                final String[] part = s.split(":");
                // Material:Qty
                if (part.length == 2) {
                    try {
                        // Correct some common mistakes
                        if (part[0].equalsIgnoreCase("potato")) {
                            part[0] = "POTATO_ITEM";
                        } else if (part[0].equalsIgnoreCase("brewing_stand")) {
                            part[0] = "BREWING_STAND_ITEM";
                        } else if (part[0].equalsIgnoreCase("carrot")) {
                            part[0] = "CARROT_ITEM";
                        } else if (part[0].equalsIgnoreCase("cauldron")) {
                            part[0] = "CAULDRON_ITEM";
                        } else if (part[0].equalsIgnoreCase("skull")) {
                            part[0] = "SKULL_ITEM";
                        }
                        // TODO: add netherwart vs. netherstalk?
                        if (StringUtils.isNumeric(part[0])) {
                            reqItem = Material.getMaterial(Integer.parseInt(part[0]));
                        } else {
                            reqItem = Material.getMaterial(part[0].toUpperCase());
                        }
                        reqAmount = Integer.parseInt(part[1]);
                        ItemStack item = new ItemStack(reqItem);
                        if (DEBUG) {
                            plugin.getLogger().info("DEBUG: required item = " + reqItem.toString());
                            plugin.getLogger().info("DEBUG: item amount = " + reqAmount);
                        }
                        if (!player.getInventory().contains(reqItem)) {
                            if (DEBUG)
                                plugin.getLogger().info("DEBUG: item not in inventory");
                            return false;
                        } else {
                            // check amount
                            int amount = 0;
                            if (DEBUG)
                                plugin.getLogger().info("DEBUG: Amount in inventory = "
                                        + player.getInventory().all(reqItem).size());
                            // Go through all the inventory and try to find
                            // enough required items
                            for (Entry<Integer, ? extends ItemStack> en : player.getInventory().all(reqItem)
                                    .entrySet()) {
                                // Get the item
                                ItemStack i = en.getValue();
                                // If the item is enchanted, skip - it doesn't count
                                if (!i.getEnchantments().isEmpty()) {
                                    if (DEBUG)
                                        plugin.getLogger().info("DEBUG: item has enchantment - doesn't count");
                                    continue;
                                }
                                // Map needs special handling because the
                                // durability increments every time a new one is
                                // made by the player
                                // TODO: if there are any other items that act
                                // in the same way, they need adding too...
                                if (i.getDurability() == 0
                                        || (reqItem == Material.MAP && i.getType() == Material.MAP)) {
                                    // Clear any naming, or lore etc.
                                    //i.setItemMeta(null);
                                    //player.getInventory().setItem(en.getKey(), i);
                                    // #1 item stack qty + amount is less than
                                    // required items - take all i
                                    // #2 item stack qty + amount = required
                                    // item -
                                    // take all
                                    // #3 item stack qty + amount > req items -
                                    // take
                                    // portion of i
                                    // amount += i.getAmount();
                                    if ((amount + i.getAmount()) < reqAmount) {
                                        // Remove all of this item stack - clone
                                        // otherwise it will keep a reference to
                                        // the
                                        // original
                                        toBeRemoved.add(i.clone());
                                        amount += i.getAmount();
                                        if (DEBUG)
                                            plugin.getLogger()
                                                    .info("DEBUG: amount is <= req Remove " + i.toString() + ":"
                                                            + i.getDurability() + " x " + i.getAmount());
                                    } else if ((amount + i.getAmount()) == reqAmount) {
                                        if (DEBUG)
                                            plugin.getLogger()
                                                    .info("DEBUG: amount is = req Remove " + i.toString() + ":"
                                                            + i.getDurability() + " x " + i.getAmount());
                                        toBeRemoved.add(i.clone());
                                        amount += i.getAmount();
                                        break;
                                    } else {
                                        // Remove a portion of this item
                                        if (DEBUG)
                                            plugin.getLogger()
                                                    .info("DEBUG: amount is > req Remove " + i.toString() + ":"
                                                            + i.getDurability() + " x " + i.getAmount());

                                        item.setAmount(reqAmount - amount);
                                        item.setDurability(i.getDurability());
                                        toBeRemoved.add(item);
                                        amount += i.getAmount();
                                        break;
                                    }
                                }
                            }
                            if (DEBUG)
                                plugin.getLogger().info("DEBUG: amount " + amount);
                            if (amount < reqAmount) {
                                return false;
                            }
                        }
                    } catch (Exception e) {
                        plugin.getLogger().severe("Problem with " + s + " in challenges.yml!");
                        player.sendMessage(
                                ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady);
                        String materialList = "";
                        boolean hint = false;
                        for (Material m : Material.values()) {
                            materialList += m.toString() + ",";
                            if (m.toString().contains(s.substring(0, 3).toUpperCase())) {
                                plugin.getLogger().severe("Did you mean " + m.toString() + "?");
                                hint = true;
                            }
                        }
                        if (!hint) {
                            plugin.getLogger()
                                    .severe("Sorry, I have no idea what " + s + " is. Pick from one of these:");
                            plugin.getLogger().severe(materialList.substring(0, materialList.length() - 1));
                        } else {
                            plugin.getLogger().severe("Correct challenges.yml with the correct material.");
                        }
                        return false;
                    }
                } else if (part.length == 3) {
                    if (DEBUG)
                        plugin.getLogger().info("DEBUG: Item with durability");
                    // This handles items with durability
                    // Correct some common mistakes
                    if (part[0].equalsIgnoreCase("potato")) {
                        part[0] = "POTATO_ITEM";
                    } else if (part[0].equalsIgnoreCase("brewing_stand")) {
                        part[0] = "BREWING_STAND_ITEM";
                    } else if (part[0].equalsIgnoreCase("carrot")) {
                        part[0] = "CARROT_ITEM";
                    } else if (part[0].equalsIgnoreCase("cauldron")) {
                        part[0] = "CAULDRON_ITEM";
                    } else if (part[0].equalsIgnoreCase("skull")) {
                        part[0] = "SKULL_ITEM";
                    }
                    if (StringUtils.isNumeric(part[0])) {
                        reqItem = Material.getMaterial(Integer.parseInt(part[0]));
                    } else {
                        reqItem = Material.getMaterial(part[0].toUpperCase());
                    }
                    reqAmount = Integer.parseInt(part[2]);
                    int reqDurability = Integer.parseInt(part[1]);
                    ItemStack item = new ItemStack(reqItem);

                    // Item
                    item.setDurability((short) reqDurability);
                    // check amount
                    int amount = 0;
                    // Go through all the inventory and try to find
                    // enough required items
                    for (Entry<Integer, ? extends ItemStack> en : player.getInventory().all(reqItem)
                            .entrySet()) {
                        // Get the item
                        ItemStack i = en.getValue();
                        if (i.hasItemMeta()) {
                            continue;
                        }
                        if (i.getDurability() == reqDurability) {
                            // Clear any naming, or lore etc.
                            //i.setItemMeta(null);
                            // player.getInventory().setItem(en.getKey(), i);
                            // #1 item stack qty + amount is less than
                            // required items - take all i
                            // #2 item stack qty + amount = required
                            // item -
                            // take all
                            // #3 item stack qty + amount > req items -
                            // take
                            // portion of i
                            // amount += i.getAmount();
                            if ((amount + i.getAmount()) < reqAmount) {
                                // Remove all of this item stack - clone
                                // otherwise it will keep a reference to
                                // the
                                // original
                                toBeRemoved.add(i.clone());
                                amount += i.getAmount();
                                if (DEBUG)
                                    plugin.getLogger().info("DEBUG: amount is <= req Remove " + i.toString()
                                            + ":" + i.getDurability() + " x " + i.getAmount());
                            } else if ((amount + i.getAmount()) == reqAmount) {
                                toBeRemoved.add(i.clone());
                                amount += i.getAmount();
                                break;
                            } else {
                                // Remove a portion of this item
                                if (DEBUG)
                                    plugin.getLogger().info("DEBUG: amount is > req Remove " + i.toString()
                                            + ":" + i.getDurability() + " x " + i.getAmount());

                                item.setAmount(reqAmount - amount);
                                item.setDurability(i.getDurability());
                                toBeRemoved.add(item);
                                amount += i.getAmount();
                                break;
                            }
                        }
                    }
                    if (DEBUG) {
                        plugin.getLogger().info("DEBUG: amount is " + amount);
                        plugin.getLogger().info("DEBUG: req amount is " + reqAmount);
                    }
                    if (amount < reqAmount) {
                        if (DEBUG)
                            plugin.getLogger().info("DEBUG: Failure! Insufficient amount of " + item.toString()
                                    + " required = " + reqAmount + " actual = " + amount);
                        return false;
                    }
                    if (DEBUG)
                        plugin.getLogger().info("DEBUG: before set amount " + item.toString() + ":"
                                + item.getDurability() + " x " + item.getAmount());

                } else if (part.length == 6 && part[0].contains("POTION")) {
                    // Run through player's inventory for the item
                    ItemStack[] playerInv = player.getInventory().getContents();
                    try {
                        reqAmount = Integer.parseInt(part[5]);
                        if (DEBUG)
                            plugin.getLogger().info("DEBUG: required amount is " + reqAmount);
                    } catch (Exception e) {
                        plugin.getLogger().severe("Could not parse the quantity of the potion item " + s);
                        return false;
                    }
                    int count = reqAmount;
                    for (ItemStack i : playerInv) {
                        // Catches all POTION, LINGERING_POTION and SPLASH_POTION
                        if (i != null && i.getType().toString().contains("POTION")) {
                            //plugin.getLogger().info("DEBUG:6 part potion check!");
                            // POTION:NAME:<LEVEL>:<EXTENDED>:<SPLASH/LINGER>:QTY
                            if (plugin.getServer().getVersion().contains("(MC: 1.8")
                                    || plugin.getServer().getVersion().contains("(MC: 1.7")) {
                                // Test potion
                                Potion potion = Potion.fromItemStack(i);
                                PotionType potionType = potion.getType();
                                boolean match = true;
                                if (DEBUG)
                                    plugin.getLogger().info("DEBUG: name check " + part[1]);
                                // Name check
                                if (potion != null && potionType != null && !part[1].isEmpty()) {
                                    // There is a name
                                    // Custom potions may not have names
                                    if (potionType.name() != null) {
                                        if (!part[1].equalsIgnoreCase(potionType.name())) {
                                            match = false;
                                            if (DEBUG)
                                                plugin.getLogger().info("DEBUG: name does not match");
                                        } else {
                                            if (DEBUG)
                                                plugin.getLogger().info("DEBUG: name matches");
                                        }
                                    } else {
                                        plugin.getLogger().severe(
                                                "Potion type is unknown. Please pick from the following:");
                                        for (PotionType pt : PotionType.values()) {
                                            plugin.getLogger().severe(pt.name());
                                        }
                                        match = false;
                                    }
                                }
                                // Level check (upgraded)
                                if (DEBUG)
                                    plugin.getLogger().info("DEBUG: level check " + part[2]);
                                if (!part[2].isEmpty()) {
                                    // There is a level declared - check it
                                    if (StringUtils.isNumeric(part[2])) {
                                        int level = Integer.valueOf(part[2]);
                                        if (level != potion.getLevel()) {
                                            if (DEBUG)
                                                plugin.getLogger().info("DEBUG: level does not match");
                                            match = false;
                                        }
                                    }
                                }
                                // Extended check
                                if (DEBUG)
                                    plugin.getLogger().info("DEBUG: extended check " + part[3]);
                                if (!part[3].isEmpty()) {
                                    if (part[3].equalsIgnoreCase("EXTENDED") && !potion.hasExtendedDuration()) {
                                        match = false;
                                        if (DEBUG)
                                            plugin.getLogger().info("DEBUG: extended does not match");
                                    }
                                    if (part[3].equalsIgnoreCase("NOTEXTENDED")
                                            && potion.hasExtendedDuration()) {
                                        match = false;
                                        if (DEBUG)
                                            plugin.getLogger().info("DEBUG: extended does not match");
                                    }
                                }
                                // Splash check
                                if (DEBUG)
                                    plugin.getLogger().info("DEBUG: splash/linger check " + part[4]);
                                if (!part[4].isEmpty()) {
                                    if (part[4].equalsIgnoreCase("SPLASH") && !potion.isSplash()) {
                                        match = false;
                                        if (DEBUG)
                                            plugin.getLogger().info("DEBUG: not splash");
                                    }
                                    if (part[4].equalsIgnoreCase("NOSPLASH") && potion.isSplash()) {
                                        match = false;
                                        if (DEBUG)
                                            plugin.getLogger().info("DEBUG: not no splash");
                                    }
                                }
                                // Quantity check
                                if (match) {
                                    if (DEBUG)
                                        plugin.getLogger().info("DEBUG: potion matches!");
                                    ItemStack removeItem = i.clone();
                                    if (removeItem.getAmount() > reqAmount) {
                                        if (DEBUG)
                                            plugin.getLogger().info(
                                                    "DEBUG: found " + removeItem.getAmount() + " qty in inv");
                                        removeItem.setAmount(reqAmount);
                                    }
                                    count = count - removeItem.getAmount();
                                    if (DEBUG)
                                        plugin.getLogger().info("DEBUG: " + count + " left");
                                    toBeRemoved.add(removeItem);
                                }
                            } else {
                                // V1.9 and above
                                PotionMeta potionMeta = (PotionMeta) i.getItemMeta();
                                // If any of the settings above are missing, then any is okay
                                boolean match = true;
                                if (DEBUG)
                                    plugin.getLogger().info("DEBUG: name check " + part[1]);
                                // Name check
                                if (!part[1].isEmpty()) {
                                    // There is a name
                                    if (PotionType.valueOf(part[1]) != null) {
                                        if (!potionMeta.getBasePotionData().getType().name()
                                                .equalsIgnoreCase(part[1])) {
                                            match = false;
                                            if (DEBUG)
                                                plugin.getLogger().info("DEBUG: name does not match");
                                        } else {
                                            if (DEBUG)
                                                plugin.getLogger().info("DEBUG: name matches");
                                        }
                                    } else {
                                        plugin.getLogger().severe(
                                                "Potion type is unknown. Please pick from the following:");
                                        for (PotionType pt : PotionType.values()) {
                                            plugin.getLogger().severe(pt.name());
                                        }
                                        match = false;
                                    }
                                }
                                // Level check (upgraded)
                                // plugin.getLogger().info("DEBUG: level check " + part[2]);
                                if (!part[2].isEmpty()) {
                                    // There is a level declared - check it
                                    if (StringUtils.isNumeric(part[2])) {
                                        int level = Integer.valueOf(part[2]);
                                        if (level == 1 && potionMeta.getBasePotionData().isUpgraded()) {
                                            if (DEBUG)
                                                plugin.getLogger().info("DEBUG: level does not match");
                                            match = false;
                                        }
                                        if (level != 1 && !potionMeta.getBasePotionData().isUpgraded()) {
                                            match = false;
                                            if (DEBUG)
                                                plugin.getLogger().info("DEBUG: level does not match");
                                        }
                                    }
                                }
                                // Extended check
                                if (DEBUG)
                                    plugin.getLogger().info("DEBUG: extended check " + part[3]);
                                if (!part[3].isEmpty()) {
                                    if (part[3].equalsIgnoreCase("EXTENDED")
                                            && !potionMeta.getBasePotionData().isExtended()) {
                                        match = false;
                                        if (DEBUG)
                                            plugin.getLogger().info("DEBUG: extended does not match");
                                    }
                                    if (part[3].equalsIgnoreCase("NOTEXTENDED")
                                            && potionMeta.getBasePotionData().isExtended()) {
                                        match = false;
                                        if (DEBUG)
                                            plugin.getLogger().info("DEBUG: extended does not match");
                                    }
                                }
                                // Splash or Linger check
                                if (DEBUG)
                                    plugin.getLogger().info("DEBUG: splash/linger check " + part[4]);
                                if (!part[4].isEmpty()) {
                                    if (part[4].equalsIgnoreCase("SPLASH")
                                            && !i.getType().equals(Material.SPLASH_POTION)) {
                                        match = false;
                                        if (DEBUG)
                                            plugin.getLogger().info("DEBUG: not splash");
                                    }
                                    if (part[4].equalsIgnoreCase("NOSPLASH")
                                            && i.getType().equals(Material.SPLASH_POTION)) {
                                        match = false;
                                        if (DEBUG)
                                            plugin.getLogger().info("DEBUG: not no splash");
                                    }
                                    if (part[4].equalsIgnoreCase("LINGER")
                                            && !i.getType().equals(Material.LINGERING_POTION)) {
                                        match = false;
                                        if (DEBUG)
                                            plugin.getLogger().info("DEBUG: not linger");
                                    }
                                    if (part[4].equalsIgnoreCase("NOLINGER")
                                            && i.getType().equals(Material.LINGERING_POTION)) {
                                        match = false;
                                        if (DEBUG)
                                            plugin.getLogger().info("DEBUG: not no linger");
                                    }
                                }
                                // Quantity check
                                if (match) {
                                    if (DEBUG)
                                        plugin.getLogger().info("DEBUG: potion matches!");
                                    ItemStack removeItem = i.clone();
                                    if (removeItem.getAmount() > reqAmount) {
                                        if (DEBUG)
                                            plugin.getLogger().info(
                                                    "DEBUG: found " + removeItem.getAmount() + " qty in inv");
                                        removeItem.setAmount(reqAmount);
                                    }
                                    count = count - removeItem.getAmount();
                                    if (DEBUG)
                                        plugin.getLogger().info("DEBUG: " + count + " left");
                                    toBeRemoved.add(removeItem);
                                }
                            }
                        }
                        if (count <= 0) {
                            if (DEBUG)
                                plugin.getLogger().info("DEBUG: Player has enough");
                            break;
                        }
                        if (DEBUG)
                            plugin.getLogger().info("DEBUG: still need " + count + " to complete");
                    }
                    if (count > 0) {
                        if (DEBUG)
                            plugin.getLogger().info("DEBUG: Player does not have enough");
                        return false;
                    }

                } else {
                    plugin.getLogger().severe("Problem with " + s + " in challenges.yml!");
                    return false;
                }
            }
        }
        // Build up the items in the inventory and remove them if they are
        // all there.

        if (getChallengeConfig().getBoolean("challenges.challengeList." + challenge + ".takeItems")) {
            // checkChallengeItems(player, challenge);
            // int qty = 0;
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Removing items");
            for (ItemStack i : toBeRemoved) {
                // qty += i.getAmount();
                if (DEBUG)
                    plugin.getLogger().info(
                            "DEBUG: Remove " + i.toString() + "::" + i.getDurability() + " x " + i.getAmount());
                HashMap<Integer, ItemStack> leftOver = player.getInventory().removeItem(i);
                if (!leftOver.isEmpty()) {
                    plugin.getLogger().warning("Exploit? Could not remove the following in challenge "
                            + challenge + " for player " + player.getName() + ":");
                    for (ItemStack left : leftOver.values()) {
                        plugin.getLogger().info(left.toString());
                    }
                    return false;
                }
            }
            // Remove money
            if (moneyReq > 0D) {
                EconomyResponse er = VaultHelper.econ.withdrawPlayer(player, moneyReq);
                if (!er.transactionSuccess()) {
                    plugin.getLogger().warning("Exploit? Could not remove " + VaultHelper.econ.format(moneyReq)
                            + " from " + player.getName() + " in challenge " + challenge);
                    plugin.getLogger().warning("Player's balance is "
                            + VaultHelper.econ.format(VaultHelper.econ.getBalance(player)));
                }
            }
            // plugin.getLogger().info("DEBUG: total = " + qty);
        }
        return true;
    }
    if (type.equalsIgnoreCase("island")) {
        final HashMap<Material, Integer> neededItem = new HashMap<Material, Integer>();
        final HashMap<EntityType, Integer> neededEntities = new HashMap<EntityType, Integer>();
        if (!reqList.isEmpty()) {
            for (int i = 0; i < reqList.split(" ").length; i++) {
                final String[] sPart = reqList.split(" ")[i].split(":");
                // Parse the qty required first
                try {
                    final int qty = Integer.parseInt(sPart[1]);
                    // Find out if the needed item is a Material or an Entity
                    boolean isEntity = false;
                    for (EntityType entityType : EntityType.values()) {
                        if (entityType.toString().equalsIgnoreCase(sPart[0])) {
                            isEntity = true;
                            break;
                        }
                    }
                    if (isEntity) {
                        // plugin.getLogger().info("DEBUG: Item " +
                        // sPart[0].toUpperCase() + " is an entity");
                        EntityType entityType = EntityType.valueOf(sPart[0].toUpperCase());
                        if (entityType != null) {
                            neededEntities.put(entityType, qty);
                            // plugin.getLogger().info("DEBUG: Needed entity is "
                            // + Integer.parseInt(sPart[1]) + " x " +
                            // EntityType.valueOf(sPart[0].toUpperCase()).toString());
                        }
                    } else {
                        Material item;
                        if (StringUtils.isNumeric(sPart[0])) {
                            item = Material.getMaterial(Integer.parseInt(sPart[0]));
                        } else {
                            item = Material.getMaterial(sPart[0].toUpperCase());
                        }
                        if (item != null) {
                            neededItem.put(item, qty);
                            // plugin.getLogger().info("DEBUG: Needed item is "
                            // + Integer.parseInt(sPart[1]) + " x " +
                            // Material.getMaterial(sPart[0]).toString());

                        } else {
                            plugin.getLogger().warning("Problem parsing required item for challenge "
                                    + challenge + " in challenges.yml!");
                            return false;
                        }
                    }
                } catch (Exception intEx) {
                    plugin.getLogger().warning("Problem parsing required items for challenge " + challenge
                            + " in challenges.yml - skipping");
                    return false;
                }
            }
        }
        // We now have two sets of required items or entities
        // Check the items first
        final Location l = player.getLocation();
        // if (!neededItem.isEmpty()) {
        final int px = l.getBlockX();
        final int py = l.getBlockY();
        final int pz = l.getBlockZ();
        // Get search radius - min is 10, max is 50
        int searchRadius = getChallengeConfig()
                .getInt("challenges.challengeList." + challenge + ".searchRadius", 10);
        if (searchRadius < 10) {
            searchRadius = 10;
        } else if (searchRadius > 50) {
            searchRadius = 50;
        }
        for (int x = -searchRadius; x <= searchRadius; x++) {
            for (int y = -searchRadius; y <= searchRadius; y++) {
                for (int z = -searchRadius; z <= searchRadius; z++) {
                    final Material b = new Location(l.getWorld(), px + x, py + y, pz + z).getBlock().getType();
                    if (neededItem.containsKey(b)) {
                        if (neededItem.get(b) == 1) {
                            neededItem.remove(b);
                        } else {
                            // Reduce the require amount by 1
                            neededItem.put(b, neededItem.get(b) - 1);
                        }
                    }
                }
            }
        }
        // }
        // Check if all the needed items have been amassed
        if (!neededItem.isEmpty()) {
            // plugin.getLogger().info("DEBUG: Insufficient items around");
            for (Material missing : neededItem.keySet()) {
                player.sendMessage(
                        ChatColor.RED + plugin.myLocale(player.getUniqueId()).challengeserrorYouAreMissing + " "
                                + neededItem.get(missing) + " x " + Util.prettifyText(missing.toString()));
            }
            return false;
        } else {
            // plugin.getLogger().info("DEBUG: Items are there");
            // Check for needed entities
            for (Entity entity : player.getNearbyEntities(searchRadius, searchRadius, searchRadius)) {
                // plugin.getLogger().info("DEBUG: Entity found:" +
                // entity.getType().toString());
                if (neededEntities.containsKey(entity.getType())) {
                    // plugin.getLogger().info("DEBUG: Entity in list");
                    if (neededEntities.get(entity.getType()) == 1) {
                        neededEntities.remove(entity.getType());
                        // plugin.getLogger().info("DEBUG: Entity qty satisfied");
                    } else {
                        neededEntities.put(entity.getType(), neededEntities.get(entity.getType()) - 1);
                        // plugin.getLogger().info("DEBUG: Entity qty reduced by 1");
                    }
                } else {
                    // plugin.getLogger().info("DEBUG: Entity not in list");
                }
            }
            if (neededEntities.isEmpty()) {
                return true;
            } else {
                for (EntityType missing : neededEntities.keySet()) {
                    player.sendMessage(ChatColor.RED
                            + plugin.myLocale(player.getUniqueId()).challengeserrorYouAreMissing + " "
                            + neededEntities.get(missing) + " x " + Util.prettifyText(missing.toString()));
                }
                return false;
            }
        }
    }

    return true;
}

From source file:org.apache.axis2.description.AxisService.java

/**
 * Add any control operations defined by a Module to this service.
 * /*w w  w .j  a va2 s  . c  o  m*/
 * @param module
 *            the AxisModule which has just been engaged
 * @throws AxisFault
 *             if a problem occurs
 */
void addModuleOperations(AxisModule module) throws AxisFault {
    HashMap<QName, AxisOperation> map = module.getOperations();
    Collection<AxisOperation> col = map.values();
    PhaseResolver phaseResolver = new PhaseResolver(getAxisConfiguration());
    for (Iterator<AxisOperation> iterator = col.iterator(); iterator.hasNext();) {
        AxisOperation axisOperation = copyOperation((AxisOperation) iterator.next());
        if (this.getOperation(axisOperation.getName()) == null) {
            ArrayList<String> wsamappings = axisOperation.getWSAMappingList();
            if (wsamappings != null) {
                for (int j = 0, size = wsamappings.size(); j < size; j++) {
                    String mapping = (String) wsamappings.get(j);
                    //If there is already an operation with this action
                    //mapping (e.g. if the service has a matching operation)
                    //then we're going to check to see if the module's
                    //operation says that it's OK to be overridden and
                    //if so, we'll simply ignore the mapping, otherwise
                    //we continue as before
                    AxisOperation mappedOperation = getOperationByAction(mapping);
                    if ((mappedOperation != null)
                            && (axisOperation.isParameterTrue(DeploymentConstants.TAG_ALLOWOVERRIDE))) {
                        if (log.isDebugEnabled()) {
                            log.debug("addModuleOperations: Mapping already exists for action: " + mapping
                                    + " to operation: " + axisOperation + " named: " + axisOperation.getName()
                                    + " and an override is allowed, so the module mapping for module: "
                                    + module.getName() + " is being ignored.");
                            log.debug(JavaUtils.callStackToString());
                        }
                    } else {
                        mapActionToOperation(mapping, axisOperation);
                    }
                }
            }
            // If we've set the "expose" parameter for this operation, it's
            // normal (non-
            // control) and therefore it will appear in generated WSDL. If
            // we haven't,
            // it's a control operation and will be ignored at WSDL-gen
            // time.
            if (axisOperation.isParameterTrue(DeploymentConstants.TAG_EXPOSE)) {
                axisOperation.setControlOperation(false);
            } else {
                axisOperation.setControlOperation(true);
            }

            phaseResolver.engageModuleToOperation(axisOperation, module);

            this.addOperation(axisOperation);
        }
    }
}

From source file:org.apache.axis2.description.AxisService.java

/**
 * Remove any operations which were added by a given module.
 * //from w w  w. j  a  v  a 2s. co m
 * @param module
 *            the module in question
 */
private void removeModuleOperations(AxisModule module) {
    HashMap<QName, AxisOperation> moduleOperations = module.getOperations();
    if (moduleOperations != null) {
        for (Iterator<AxisOperation> modOpsIter = moduleOperations.values().iterator(); modOpsIter.hasNext();) {
            AxisOperation operation = (AxisOperation) modOpsIter.next();
            removeOperation(operation.getName());
        }
    }
}

From source file:org.apache.hadoop.hbase.regionserver.TestColumnSeeking.java

@SuppressWarnings("unchecked")
@Test//from   ww  w.j a va 2  s . com
public void testDuplicateVersions() throws IOException {
    String family = "Family";
    byte[] familyBytes = Bytes.toBytes("Family");
    TableName table = TableName.valueOf(name.getMethodName());

    HColumnDescriptor hcd = new HColumnDescriptor(familyBytes).setMaxVersions(1000);
    hcd.setMaxVersions(3);
    HTableDescriptor htd = new HTableDescriptor(table);
    htd.addFamily(hcd);
    HRegionInfo info = new HRegionInfo(table, null, null, false);
    // Set this so that the archiver writes to the temp dir as well.
    HRegion region = TEST_UTIL.createLocalHRegion(info, htd);
    try {
        List<String> rows = generateRandomWords(10, "row");
        List<String> allColumns = generateRandomWords(10, "column");
        List<String> values = generateRandomWords(100, "value");

        long maxTimestamp = 2;
        double selectPercent = 0.5;
        int numberOfTests = 5;
        double flushPercentage = 0.2;
        double minorPercentage = 0.2;
        double majorPercentage = 0.2;
        double putPercentage = 0.2;

        HashMap<String, KeyValue> allKVMap = new HashMap<String, KeyValue>();

        HashMap<String, KeyValue>[] kvMaps = new HashMap[numberOfTests];
        ArrayList<String>[] columnLists = new ArrayList[numberOfTests];

        for (int i = 0; i < numberOfTests; i++) {
            kvMaps[i] = new HashMap<String, KeyValue>();
            columnLists[i] = new ArrayList<String>();
            for (String column : allColumns) {
                if (Math.random() < selectPercent) {
                    columnLists[i].add(column);
                }
            }
        }

        for (String value : values) {
            for (String row : rows) {
                Put p = new Put(Bytes.toBytes(row));
                p.setDurability(Durability.SKIP_WAL);
                for (String column : allColumns) {
                    for (long timestamp = 1; timestamp <= maxTimestamp; timestamp++) {
                        KeyValue kv = KeyValueTestUtil.create(row, family, column, timestamp, value);
                        if (Math.random() < putPercentage) {
                            p.add(kv);
                            allKVMap.put(kv.getKeyString(), kv);
                            for (int i = 0; i < numberOfTests; i++) {
                                if (columnLists[i].contains(column)) {
                                    kvMaps[i].put(kv.getKeyString(), kv);
                                }
                            }
                        }
                    }
                }
                region.put(p);
                if (Math.random() < flushPercentage) {
                    LOG.info("Flushing... ");
                    region.flushcache();
                }

                if (Math.random() < minorPercentage) {
                    LOG.info("Minor compacting... ");
                    region.compactStores(false);
                }

                if (Math.random() < majorPercentage) {
                    LOG.info("Major compacting... ");
                    region.compactStores(true);
                }
            }
        }

        for (int i = 0; i < numberOfTests + 1; i++) {
            Collection<KeyValue> kvSet;
            Scan scan = new Scan();
            scan.setMaxVersions();
            if (i < numberOfTests) {
                if (columnLists[i].size() == 0)
                    continue; // HBASE-7700
                kvSet = kvMaps[i].values();
                for (String column : columnLists[i]) {
                    scan.addColumn(familyBytes, Bytes.toBytes(column));
                }
                LOG.info("ExplicitColumns scanner");
                LOG.info("Columns: " + columnLists[i].size() + "  Keys: " + kvSet.size());
            } else {
                kvSet = allKVMap.values();
                LOG.info("Wildcard scanner");
                LOG.info("Columns: " + allColumns.size() + "  Keys: " + kvSet.size());

            }
            InternalScanner scanner = region.getScanner(scan);
            List<Cell> results = new ArrayList<Cell>();
            while (scanner.next(results))
                ;
            assertEquals(kvSet.size(), results.size());
            assertTrue(KeyValueTestUtil.containsIgnoreMvccVersion(results, kvSet));
        }
    } finally {
        HRegion.closeHRegion(region);
    }

    HRegion.closeHRegion(region);
}

From source file:edu.ucla.cs.scai.canali.core.index.BuildIndex.java

public void start() throws Exception {
    long t = System.currentTimeMillis();
    loadBasicTypesMapping();/* w ww.j  a  va2s  .  c  o  m*/
    System.out.println(System.currentTimeMillis() - t);
    t = System.currentTimeMillis();
    loadTriples();
    System.out.println(System.currentTimeMillis() - t);
    t = System.currentTimeMillis();
    loadPropertyLabels();
    System.out.println(System.currentTimeMillis() - t);
    t = System.currentTimeMillis();
    loadClassLabels();
    System.out.println(System.currentTimeMillis() - t);
    t = System.currentTimeMillis();
    loadClassHierarchy();
    System.out.println(System.currentTimeMillis() - t);
    t = System.currentTimeMillis();
    loadEntityLabels();
    System.out.println(System.currentTimeMillis() - t);
    t = System.currentTimeMillis();
    loadEntityClasses();
    System.out.println(System.currentTimeMillis() - t);
    t = System.currentTimeMillis();
    entityIdFromUriWithPrefix = null;//entityIdFromUri = null;
    classIdFromUri = null;
    propertyIdFromUri = null;
    System.gc();
    processTriples();
    System.out.println(System.currentTimeMillis() - t);
    t = System.currentTimeMillis();
    HashMap<String, Analyzer> analyzerMap = new HashMap<>();
    analyzerMap.put("label", new EnglishAnalyzer(CharArraySet.EMPTY_SET));
    analyzerMap.put("id", new WhitespaceAnalyzer());
    analyzerMap.put("type", new WhitespaceAnalyzer());
    analyzerMap.put("domainOfProperty", new WhitespaceAnalyzer());
    analyzerMap.put("rangeOfProperty", new WhitespaceAnalyzer());
    analyzerMap.put("propertyDomain", new WhitespaceAnalyzer());
    Analyzer analyzer = new PerFieldAnalyzerWrapper(new WhitespaceAnalyzer(), analyzerMap);
    HashMap<Integer, IndexedToken> elements = new HashMap<>();
    try (FSDirectory directory = FSDirectory.open(Paths.get(basePathOutput + "lucene"))) {
        IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
        iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
        try (IndexWriter writer = new IndexWriter(directory, iwc)) {
            System.out.println("Indexing entities");
            indexEntities(writer, elements);
            System.out.println(System.currentTimeMillis() - t);
            t = System.currentTimeMillis();
            System.out.println("Indexing classes");
            indexClasses(writer, elements);
            System.out.println(System.currentTimeMillis() - t);
            t = System.currentTimeMillis();
            System.out.println("Indexing propertys");
            indexProperties(writer, elements);
            System.out.println(System.currentTimeMillis() - t);
            t = System.currentTimeMillis();
            /*
             System.out.println("Indexing constraint uriToPrefix");
             indexConstraintPrefixes(writer, elements);
             System.out.println(System.currentTimeMillis() - t);
             t = System.currentTimeMillis();
             */
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    //save elements to file
    System.out.println("Creating the trie");
    Trie trie = new Trie();
    int c = 0;
    for (IndexedToken it : elements.values()) {
        trie.add(it.getText());
        c++;
        if (c % 100000 == 0) {
            System.out.println(c + " elements added to the trie");
        }
    }
    System.out.println(c + " elements added to the trie");
    c = 0;
    for (IndexedToken it : elements.values()) {
        String suffix = trie.getOneSuffix(it.getText());
        if (suffix != null) {
            it.setPrefix(true);
            c++;
        }
    }
    System.out.println(c + " are prefix of another element");
    System.out.println("Serializing the tokens");
    try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(basePathOutput + "elements"))) {
        oos.writeObject(elements);
        oos.writeInt(IndexedToken.counter);
    }
}

From source file:com.siemens.sw360.portal.portlets.admin.ComponentUploadPortlet.java

@UsedAsLiferayAction
public void updateLicenses(ActionRequest request, ActionResponse response)
        throws PortletException, IOException, TException {
    final HashMap<String, InputStream> inputMap = new HashMap<>();
    try {/* w w  w. j av a  2s. c  om*/
        fillFilenameInputStreamMap(request, inputMap);
        if (ZipTools.isValidLicenseArchive(inputMap)) {

            final LicenseService.Iface licenseClient = thriftClients.makeLicenseClient();

            log.debug("Parsing risk Categories ...");
            Map<Integer, RiskCategory> riskCategoryMap = getIdentifierToTypeMapAndWriteMissingToDatabase(
                    licenseClient, inputMap.get(RISK_CATEGORY_FILE), RiskCategory.class, Integer.class);

            log.debug("Parsing risks ...");
            Map<Integer, Risk> riskMap = getIntegerRiskMap(licenseClient, riskCategoryMap,
                    inputMap.get(RISK_FILE));

            log.debug("Parsing obligations ...");
            Map<Integer, Obligation> obligationMap = getIdentifierToTypeMapAndWriteMissingToDatabase(
                    licenseClient, inputMap.get(OBLIGATION_FILE), Obligation.class, Integer.class);

            log.debug("Parsing obligation todos ...");
            List<CSVRecord> obligationTodoRecords = readAsCSVRecords(inputMap.get(OBLIGATION_TODO_FILE));
            Map<Integer, Set<Integer>> obligationTodoMapping = convertObligationTodo(obligationTodoRecords);

            log.debug("Parsing todos ...");
            Map<Integer, Todo> todoMap = getTodoMap(licenseClient, obligationMap, obligationTodoMapping,
                    inputMap.get(TODO_FILE));

            log.debug("Parsing license types ...");
            Map<Integer, LicenseType> licenseTypeMap = getIdentifierToTypeMapAndWriteMissingToDatabase(
                    licenseClient, inputMap.get(LICENSETYPE_FILE), LicenseType.class, Integer.class);

            log.debug("Parsing license todos ...");
            List<CSVRecord> licenseTodoRecord = readAsCSVRecords(inputMap.get(LICENSE_TODO_FILE));
            Map<String, Set<Integer>> licenseTodoMap = convertRelationalTable(licenseTodoRecord);

            log.debug("Parsing license risks ...");
            List<CSVRecord> licenseRiskRecord = readAsCSVRecords(inputMap.get(LICENSE_RISK_FILE));
            Map<String, Set<Integer>> licenseRiskMap = convertRelationalTable(licenseRiskRecord);

            log.debug("Parsing licenses ...");
            List<CSVRecord> licenseRecord = readAsCSVRecords(inputMap.get(LICENSE_FILE));

            final List<License> licensesToAdd = ConvertRecord.fillLicenses(licenseRecord, licenseTypeMap,
                    todoMap, riskMap, licenseTodoMap, licenseRiskMap);
            addLicenses(licenseClient, licensesToAdd, log);

        } else {
            throw new SW360Exception("Invalid file format");
        }
    } finally {
        for (InputStream inputStream : inputMap.values()) {
            inputStream.close();
        }
    }
}