List of usage examples for java.util Map isEmpty
boolean isEmpty();
From source file:com.google.gsa.valve.saml.SAMLArtifactProcessor.java
/** * Logs the artifact map/*from w w w. j a v a 2 s . c om*/ * */ public static void logArtifactMap() { logger.debug("Logging Artifact Map"); Map<String, SAMLUserAuthentication> cacheArtifactMap; try { //Set<String> userIDs = userSessions.keySet(); synchronized (artifactMap) { cacheArtifactMap = new HashMap(artifactMap); } if (!cacheArtifactMap.isEmpty()) { Iterator it; synchronized (cacheArtifactMap) { it = cacheArtifactMap.keySet().iterator(); } while (it.hasNext()) { String userKey; synchronized (it) { userKey = (String) it.next(); } SAMLUserAuthentication userAuthentication; synchronized (cacheArtifactMap) { userAuthentication = cacheArtifactMap.get(userKey); } if (userAuthentication != null) { String userName = userAuthentication.getUserName(); long artifactTime = userAuthentication.getTime(); logger.debug( "Artifact Entry: " + userKey + " for user=" + userName + "; time=" + artifactTime); } } } else { logger.debug("Artifact Map is empty"); } } catch (Exception e) { logger.error("Error when logging out artifacts: " + e); } }
From source file:expansionBlocks.ProcessCommunities.java
private static Set<Map<Entity, Double>> getCommunitiesFromCommunitiesBasedOnSimilarity( Set<Map<Entity, Double>> communities, Double fusionThreshold) { //Set<Set<Article>> megaCommunities = new HashSet<Set<Article>>(valueSet(communities)); Set<Map<Entity, Double>> megaCommunities = new HashSet<>(); for (Map<Entity, Double> community : communities) { Set<Entity> communityIds = new HashSet<>(community.keySet()); Map<Entity, Double> megaCommunity = new HashMap<>(community); //if (!megaCommunity.isEmpty()) {//from w ww .j ava 2s. com for (Map<Entity, Double> community2 : communities) { Set<Entity> communityIds2 = new HashSet<>(community2.keySet()); if (!community2.isEmpty() && (compareCommunities(communityIds, communityIds2) >= fusionThreshold)) { //println("Fusionant: "+e.getValue()+" i "+e2.getValue()+" similarity:"+compareCommunities(community, community2)+" ("+threshold+")"); megaCommunity = fusion(community, community2); } } } if (!megaCommunity.isEmpty()) { megaCommunities.add(megaCommunity); } } return megaCommunities; }
From source file:net.paissad.minus.api.MinusUtils.java
/** * Verify that the specified map is not <code>null</code> and not empty. * /*from w w w. j av a 2s.co m*/ * @param jsonResult * @throws IllegalStateException */ static void validateJsonResult(Map<String, Object> jsonResult) throws IllegalStateException { if (jsonResult == null || jsonResult.isEmpty()) { throw new IllegalStateException("The JSON result cannot be null or empty."); } }
From source file:com.google.gsa.valve.saml.SAMLArtifactProcessor.java
/** * Deletes no longer valid artifact in the map * //from w ww. j a v a 2s . c om */ public static void deleteNoLongerValidArtifact() { Map<String, SAMLUserAuthentication> cacheArtifactMap; try { //Set<String> userIDs = userSessions.keySet(); synchronized (artifactMap) { cacheArtifactMap = new HashMap(artifactMap); } if (!cacheArtifactMap.isEmpty()) { Iterator it; synchronized (cacheArtifactMap) { it = cacheArtifactMap.keySet().iterator(); } while (it.hasNext()) { String userKey; synchronized (it) { userKey = (String) it.next(); } SAMLUserAuthentication userAuthentication; synchronized (cacheArtifactMap) { userAuthentication = cacheArtifactMap.get(userKey); } if (userAuthentication != null) { long artifactTime = userAuthentication.getTime(); long time = new Date().getTime() / MSECS_IN_SEC; long delayTime = time - maxArtifactAge; if (artifactTime < delayTime) { logger.debug("Artifact [" + userKey + "] is out of date as artifactTime[" + artifactTime + "] is lower than the delayTime [" + delayTime + "]"); removeArtifactMap(userKey); } } } } } catch (Exception e) { logger.error("Error when deleting no longer valid artifacts: " + e); } }
From source file:com.erudika.para.persistence.AWSDynamoUtils.java
/** * Updates the table settings (read and write capacities) * @param appid name of the {@link com.erudika.para.core.App} * @param readCapacity read capacity//from www. j a v a 2s .c o m * @param writeCapacity write capacity * @return true if updated */ public static boolean updateTable(String appid, long readCapacity, long writeCapacity) { if (StringUtils.isBlank(appid) || StringUtils.containsWhitespace(appid)) { return false; } try { Map<String, Object> dbStats = getTableStatus(appid); long currentReadCapacity = (Long) dbStats.get("readCapacityUnits"); long currentWriteCapacity = (Long) dbStats.get("writeCapacityUnits"); // AWS throws an exception if the new read/write capacity values are the same as the current ones if (!dbStats.isEmpty() && readCapacity != currentReadCapacity && writeCapacity != currentWriteCapacity) { getClient().updateTable(new UpdateTableRequest().withTableName(getTableNameForAppid(appid)) .withProvisionedThroughput(new ProvisionedThroughput(readCapacity, writeCapacity))); } } catch (Exception e) { logger.error(null, e); return false; } return true; }
From source file:com.activecq.api.helpers.WCMHelper.java
/** * Returns the HTML for creating DropTarget Edit Icon(s) for a specific * (named) DropTargets defined by a Component. * * Allows the developer to specific the EditType Icon to be used for the * Drop Target via editType parameter. If editType equals left null, the edit * type will be derived based on the DropTarget's Groups and Accepts * properties.//w w w . j a v a2 s. co m * * @param request * @param getName * @param editType * @param isConfigured will display edit block if evaluates to false * @return */ public static String getDDEditBlock(SlingHttpServletRequest request, String name, WCMEditType.Type editType, boolean... isConfigured) { if (!isAuthoringMode(request) || conditionAndCheck(isConfigured)) { return null; } final Resource resource = request.getResource(); final com.day.cq.wcm.api.components.Component component = WCMUtils.getComponent(resource); final String title = StringUtils.capitalize(component.getTitle()); String html = ""; ComponentEditConfig editConfig = component.getEditConfig(); Map<String, DropTarget> dropTargets = (editConfig != null) ? editConfig.getDropTargets() : null; if (dropTargets != null && !dropTargets.isEmpty()) { DropTarget dropTarget = null; // Find the named Drop Target for (String key : dropTargets.keySet()) { dropTarget = dropTargets.get(key); if (StringUtils.equals(name, dropTarget.getName())) { break; } else { dropTarget = null; } } if (dropTarget != null) { // If editType has not been specified then intelligently determine the best match editType = (editType == null) ? getWCMEditType(dropTarget) : editType; // Create the HTML img tag used for the edit icon html += "<img src=\"/libs/cq/ui/resources/0.gif\"" + " " + "class=\"" + dropTarget.getId() + " " + editType.getCssClass() + "\"" + " " + "alt=\"Drop Target: " + dropTarget.getName() + "\"" + " " + "title=\"Drop Target: " + dropTarget.getName() + "\"" + "/>"; } } return html; }
From source file:com.hangum.tadpole.engine.sql.util.resultset.ResultSetUtils.java
public static Map<Integer, String> getColumnLabelName(UserDBDAO userDB, Map<Integer, String> columnTableName, boolean isShowRowNum, ResultSet rs) throws Exception { Map<Integer, String> mapColumnName = getColumnLabelName(isShowRowNum, rs); DBAccessControlDAO dbAccessCtlDao = userDB.getDbAccessCtl(); Map<String, AccessCtlObjectDAO> mapDetailCtl = dbAccessCtlDao.getMapSelectAccessCtl(); if (!mapDetailCtl.isEmpty()) { Map<Integer, String> mapReturnColumnName = new HashMap<Integer, String>(); int intColumnCnt = 0; // ? db access ?? ?. for (int i = 0; i < mapColumnName.size(); i++) { String strTableName = columnTableName.get(i); // Is filter column? if (mapDetailCtl.containsKey(strTableName)) { // is filter table? AccessCtlObjectDAO acDao = mapDetailCtl.get(strTableName); String strTableOfAccessColumns = acDao.getDetail_obj(); String strResultColumn = mapColumnName.get(i); if (StringUtils.containsIgnoreCase(strTableOfAccessColumns, strResultColumn) | acDao.getDontuse_object().equals("YES")) { // if(logger.isDebugEnabled()) logger.debug("This colum is remove stauts " + strResultColumn); } else { // if(logger.isDebugEnabled()) logger.debug("This colum is normal stauts " + strResultColumn); mapReturnColumnName.put(intColumnCnt, mapColumnName.get(i)); intColumnCnt++;/*ww w . j a v a 2s . c o m*/ } } else { mapReturnColumnName.put(intColumnCnt, mapColumnName.get(i)); intColumnCnt++; } } return mapReturnColumnName; } else { return mapColumnName; } }
From source file:com.hangum.tadpole.engine.sql.util.resultset.ResultSetUtils.java
/** * column name of table./* w w w . j a v a 2 s . c om*/ * but this method is db access control. * * @param userDB * @param columnTableName * @param isShowRownum * @param rs * @return */ public static Map<Integer, String> getColumnName(UserDBDAO userDB, Map<Integer, String> columnTableName, boolean isShowRowNum, ResultSet rs) throws Exception { Map<Integer, String> mapColumnName = getColumnName(isShowRowNum, rs); DBAccessControlDAO dbAccessCtlDao = userDB.getDbAccessCtl(); Map<String, AccessCtlObjectDAO> mapDetailCtl = dbAccessCtlDao.getMapSelectAccessCtl(); if (!mapDetailCtl.isEmpty()) { Map<Integer, String> mapReturnColumnName = new HashMap<Integer, String>(); int intColumnCnt = 0; // ? db access ?? ?. for (int i = 0; i < mapColumnName.size(); i++) { String strTableName = columnTableName.get(i); // Is filter column? if (mapDetailCtl.containsKey(strTableName)) { // is filter table? AccessCtlObjectDAO acDao = mapDetailCtl.get(strTableName); String strTableOfAccessColumns = acDao.getDetail_obj(); String strResultColumn = mapColumnName.get(i); if (StringUtils.containsIgnoreCase(strTableOfAccessColumns, strResultColumn) | acDao.getDontuse_object().equals("YES")) { // if(logger.isDebugEnabled()) logger.debug("This colum is remove stauts " + strResultColumn); } else { // if(logger.isDebugEnabled()) logger.debug("This colum is normal stauts " + strResultColumn); mapReturnColumnName.put(intColumnCnt, mapColumnName.get(i)); intColumnCnt++; } } else { mapReturnColumnName.put(intColumnCnt, mapColumnName.get(i)); intColumnCnt++; } } return mapReturnColumnName; } else { return mapColumnName; } }
From source file:de.fosd.jdime.Main.java
/** * Perform a merge operation on the input files or directories. * * @param args/*from w w w. ja v a 2 s. co m*/ * command line arguments */ public static void run(String[] args) { MergeContext context = new MergeContext(); if (!parseCommandLineArgs(context, args)) { return; } List<FileArtifact> inputFiles = context.getInputFiles(); if (context.isInspect()) { inspectElement(inputFiles.get(0), context.getInspectArtifact(), context.getInspectionScope()); return; } if (context.getDumpMode() != DumpMode.NONE) { inputFiles.forEach(artifact -> dump(artifact, context.getDumpMode())); return; } try { merge(context); output(context); } finally { outputStatistics(context); } if (LOG.isLoggable(Level.FINE)) { Map<MergeScenario<?>, Throwable> crashes = context.getCrashes(); if (crashes.isEmpty()) { LOG.fine("No crashes occurred while merging."); } else { String ls = System.lineSeparator(); StringBuilder sb = new StringBuilder(); sb.append(String.format("%d crashes occurred while merging:%n", crashes.size())); for (Map.Entry<MergeScenario<?>, Throwable> entry : crashes.entrySet()) { sb.append("* ").append(entry.getValue().toString()).append(ls); sb.append(" ").append(entry.getKey().toString().replace(" ", ls + " ")).append(ls); } LOG.fine(sb.toString()); } } }
From source file:com.delicious.deliciousfeeds4J.DeliciousUtil.java
public static Set<Tag> deserializeTagsFromJson(String json) throws Exception { logger.debug("Trying to deserialize JSON to Tags..."); logger.trace("Deserializing JSON: " + json); //Check if empty or null if (json == null || json.isEmpty()) { logger.debug("Nothing to deserialize. JSON-string was empty!"); return null; }/*from www . j a va2 s. c o m*/ //Actually deserialize final Map<String, Integer> tagMap = ((Map<String, Integer>) objectMapper.readValue(json, new TypeReference<Map<String, Integer>>() { })); if (tagMap == null || tagMap.isEmpty()) { logger.debug("No tags found. Collection was empty."); return null; } logger.info("Successfully deserialized {} tagMap!", tagMap.size()); //Build the set final Set<Tag> tags = new TreeSet<Tag>(); for (Map.Entry<String, Integer> entry : tagMap.entrySet()) { final Tag tag = new Tag(); tag.setName(entry.getKey()); tag.setCount(entry.getValue()); tags.add(tag); } return tags; }