List of usage examples for java.util HashMap putAll
public void putAll(Map<? extends K, ? extends V> m)
From source file:org.opencastproject.ingest.impl.IngestServiceImpl.java
private Map<String, String> mergeWorkflowConfiguration(Map<String, String> properties, Long workflowId) { if (workflowId == null || schedulerService == null) return properties; HashMap<String, String> mergedProperties = new HashMap<String, String>(); try {/*from w ww . ja v a2 s.co m*/ Properties recordingProperties = schedulerService.getEventCaptureAgentConfiguration(workflowId); logger.debug("Restoring workflow properties from scheduler event {}", workflowId); mergedProperties.putAll((Map) recordingProperties); } catch (SchedulerException e) { logger.warn("Unable to get workflow properties from scheduler event {}: {}", workflowId, e.getMessage()); } catch (NotFoundException e) { logger.info("No capture event found for id {}", workflowId); } if (properties != null) { // Merge the properties, this must be after adding the recording properties logger.debug("Merge workflow properties with the one from the scheduler event {}", workflowId); mergedProperties.putAll(properties); } return mergedProperties; }
From source file:org.zaproxy.zap.extension.soap.WSDLCustomParser.java
private HashMap<String, String> fillParameters(Element element, String parent) { HashMap<String, String> formParams = new HashMap<String, String>(); try {// w ww .j a v a 2 s . c o m /* Tries to parse it as a complex type first. */ String xpath = null; if (parent != null) xpath = parent + "/" + element.getName(); else xpath = element.getName(); ComplexType ct = (ComplexType) element.getEmbeddedType(); /* Handles when ComplexType is not embedded but referenced by 'type'. */ if (ct == null) { Schema currentSchema = element.getSchema(); ct = (ComplexType) currentSchema.getType(element.getType()); if (ct == null) throw new ClassCastException("Complex Type is null after cast."); // Hashmap is empty here. } for (Element e : ct.getSequence().getElements()) { /* Recursive parsing for nested complex types. */ formParams.putAll(fillParameters(e, xpath)); } } catch (ClassCastException cce) { /* Simple element treatment. */ if (element == null) return formParams; /* Handles simple types. */ SimpleType simpleType = null; try { simpleType = (SimpleType) element.getEmbeddedType(); if (simpleType == null) { Schema currentSchema = element.getSchema(); simpleType = (SimpleType) currentSchema.getType(element.getType()); if (simpleType == null) { /* It is not simple type, so it is treated as a plain element. */ String xpath = ""; if (parent != null) xpath = parent + "/" + element.getName(); else xpath = element.getName(); if (element.getType() != null) return addParameter(xpath, element.getType().getQualifiedName(), null); else return formParams; } } } catch (ClassCastException cce2) { /* It is not simple type, so it is treated as a plain element. */ String xpath = ""; if (parent != null) xpath = parent + "/" + element.getName(); else xpath = element.getName(); return addParameter(xpath, element.getType().getQualifiedName(), null); } /* Handles enumeration restriction. */ BaseRestriction br = simpleType.getRestriction(); if (br != null) { List<EnumerationFacet> enums = br.getEnumerationFacets(); if (enums != null && enums.size() > 0) { String defaultValue = enums.get(0).getValue(); formParams.putAll(addParameter(parent + "/" + element.getName(), "string", defaultValue)); } } return formParams; } catch (Exception e) { LOG.warn("There was an error when trying to parse element " + element.getName() + " from WSDL file.", e); } return formParams; }
From source file:org.opencastproject.capture.impl.CaptureAgentImpl.java
/** * {@inheritDoc}/*from www . j av a2 s . com*/ * * @see org.opencastproject.capture.api.StateService#getKnownRecordings() */ public Map<String, AgentRecording> getKnownRecordings() { HashMap<String, AgentRecording> complete = new HashMap<String, AgentRecording>(); complete.putAll(pendingRecordings); complete.putAll(completedRecordings); return complete; }
From source file:au.org.ala.delta.intkey.directives.invocation.UseDirectiveInvocation.java
/** * For the given character, build a map of all its controlling characters, * and the states of these controlling characters that will make the * supplied character inapplicable./*from w w w .j a v a 2s . c om*/ * * @param ch * @param ds * @return */ private Map<MultiStateCharacter, Set<Integer>> getAllControllingCharacterDependencies( au.org.ala.delta.model.Character ch, IntkeyDataset ds) { HashMap<MultiStateCharacter, Set<Integer>> retMap = new HashMap<MultiStateCharacter, Set<Integer>>(); List<CharacterDependency> controllingDependencies = ch.getControllingCharacters(); for (CharacterDependency cd : controllingDependencies) { // A controlling character must be a multistate character MultiStateCharacter cc = (MultiStateCharacter) ds.getCharacter(cd.getControllingCharacterId()); // states for the controlling character that will make dependent // characters inapplicable Set<Integer> inapplicableStates = cd.getStates(); if (retMap.containsKey(cc)) { retMap.get(cc).addAll(inapplicableStates); } else { retMap.put(cc, new HashSet<Integer>(inapplicableStates)); } retMap.putAll(getAllControllingCharacterDependencies(cc, ds)); } return retMap; }
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 ww. j a va2s .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:com.dtolabs.client.services.RundeckAPICentralDispatcher.java
/** * Submit a request to the server which expects a list of execution items in the response, and return a single * QueuedItemResult parsed from the response. * * @param tempxml xml temp file (or null) * @param otherparams parameters for the request * @param requestPath//from w ww . ja v a 2 s . c om * * @return a single QueuedItemResult * * @throws com.dtolabs.rundeck.core.dispatcher.CentralDispatcherException * if an error occurs */ private QueuedItemResult submitExecutionRequest(final File tempxml, final HashMap<String, String> otherparams, final String requestPath) throws CentralDispatcherException { final HashMap<String, String> params = new HashMap<String, String>(); if (null != otherparams) { params.putAll(otherparams); } final WebserviceResponse response; try { response = serverService.makeRundeckRequest(requestPath, params, tempxml, null, "xmlBatch"); } catch (MalformedURLException e) { throw new CentralDispatcherServerRequestException("Failed to make request", e); } validateResponse(response); final ArrayList<QueuedItem> list = parseExecutionListResult(response); if (null == list || list.size() < 1) { return QueuedItemResultImpl.failed("Server response contained no success information."); } else { final QueuedItem next = list.iterator().next(); return QueuedItemResultImpl.successful("Succeeded queueing " + next.getName(), next.getId(), next.getUrl(), next.getName()); } }
From source file:com.dtolabs.client.services.RundeckAPICentralDispatcher.java
/** * Submit a request to the server which expects an execution id in response, and return a single * QueuedItemResult parsed from the response. * * @param uploadFileParam name of file upload parameter * @param tempxml xml temp file (or null) * @param otherparams parameters for the request * @param requestPath/* www . ja v a2 s. c o m*/ * * @return a single QueuedItemResult * * @throws com.dtolabs.rundeck.core.dispatcher.CentralDispatcherException * if an error occurs */ private QueuedItemResult submitRunRequest(final File tempxml, final HashMap<String, String> otherparams, final String requestPath, final String uploadFileParam) throws CentralDispatcherException { final HashMap<String, String> params = new HashMap<String, String>(); if (null != otherparams) { params.putAll(otherparams); } final WebserviceResponse response; try { response = serverService.makeRundeckRequest(requestPath, params, tempxml, null, null, null, uploadFileParam); } catch (MalformedURLException e) { throw new CentralDispatcherServerRequestException("Failed to make request", e); } validateResponse(response); final Document resultDoc = response.getResultDoc(); if (null != resultDoc.selectSingleNode("/result/execution") && null != resultDoc.selectSingleNode("/result/execution/@id")) { final Node node = resultDoc.selectSingleNode("/result/execution/@id"); final String succeededId = node.getStringValue(); final String name = "adhoc"; String url = createExecutionURL(succeededId); url = makeAbsoluteURL(url); logger.info("\t[" + succeededId + "] <" + url + ">"); return QueuedItemResultImpl.successful("Succeeded queueing " + name, succeededId, url, name); } return QueuedItemResultImpl.failed("Server response contained no success information."); }
From source file:cz.cesnet.shongo.connector.device.CiscoMCUConnector.java
/** * Sends a command to the device. Blocks until response to the command is complete. * * @param command//from ww w . j a v a2 s .c om * @param params * @return output of the command * @throws XmlRpcException */ private synchronized Map<String, Object> execApi(String command, Map<String, Object> params) throws XmlRpcException { logger.debug(String.format("Issuing command '%s' on %s", command, deviceAddress)); HashMap<String, Object> content = new HashMap<String, Object>(); if (params != null) { content.putAll(params); } content.put("authenticationUser", authUsername); content.put("authenticationPassword", authPassword); @SuppressWarnings("unchecked") Map<String, Object> result = (Map<String, Object>) xmlRpcClient.execute(command, new Object[] { content }); return result; }
From source file:org.eclipse.birt.report.engine.api.ReportRunner.java
/** * read Config-Parameter-Render file//from w w w . ja v a 2 s . c om */ protected void readConfigurationFile(String fileName, HashMap params) { File file = new File(fileName); Properties ps = new Properties(); InputStream in = null; try { in = new FileInputStream(file); ps.load(in); } catch (FileNotFoundException e) { logger.log(Level.SEVERE, "file: " + file.getAbsolutePath() + " not exists!"); //$NON-NLS-1$ } catch (IOException e) { logger.log(Level.SEVERE, "Can not open file: " + file.getAbsolutePath()); //$NON-NLS-1 } finally { if (in != null) { try { in.close(); } catch (IOException e) { logger.log(Level.SEVERE, "Can not close file: " + file.getAbsolutePath()); //$NON-NLS-1 } } } params.putAll(ps); }
From source file:org.telegramsecureplus.android.NotificationsController.java
@SuppressLint("InlinedApi") public void showExtraNotifications(NotificationCompat.Builder notificationBuilder, boolean notifyAboutLast) { if (Build.VERSION.SDK_INT < 19) { return;//w w w . jav a 2s .c o m } ArrayList<Long> sortedDialogs = new ArrayList<>(); HashMap<Long, ArrayList<MessageObject>> messagesByDialogs = new HashMap<>(); for (int a = 0; a < pushMessages.size(); a++) { MessageObject messageObject = pushMessages.get(a); long dialog_id = messageObject.getDialogId(); if ((int) dialog_id == 0) { continue; } ArrayList<MessageObject> arrayList = messagesByDialogs.get(dialog_id); if (arrayList == null) { arrayList = new ArrayList<>(); messagesByDialogs.put(dialog_id, arrayList); sortedDialogs.add(0, dialog_id); } arrayList.add(messageObject); } HashMap<Long, Integer> oldIdsWear = new HashMap<>(); oldIdsWear.putAll(wearNotificationsIds); wearNotificationsIds.clear(); HashMap<Long, Integer> oldIdsAuto = new HashMap<>(); oldIdsAuto.putAll(autoNotificationsIds); autoNotificationsIds.clear(); for (int b = 0; b < sortedDialogs.size(); b++) { long dialog_id = sortedDialogs.get(b); ArrayList<MessageObject> messageObjects = messagesByDialogs.get(dialog_id); int max_id = messageObjects.get(0).getId(); int max_date = messageObjects.get(0).messageOwner.date; TLRPC.Chat chat = null; TLRPC.User user = null; String name; if (dialog_id > 0) { user = MessagesController.getInstance().getUser((int) dialog_id); if (user == null) { continue; } } else { chat = MessagesController.getInstance().getChat(-(int) dialog_id); if (chat == null) { continue; } } if (chat != null) { name = chat.title; } else { name = UserObject.getUserName(user); } Integer notificationIdWear = oldIdsWear.get(dialog_id); if (notificationIdWear == null) { notificationIdWear = wearNotificationId++; } else { oldIdsWear.remove(dialog_id); } Integer notificationIdAuto = oldIdsAuto.get(dialog_id); if (notificationIdAuto == null) { notificationIdAuto = autoNotificationId++; } else { oldIdsAuto.remove(dialog_id); } Intent msgHeardIntent = new Intent(); msgHeardIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); msgHeardIntent.setAction("org.telegramsecureplus.messenger.ACTION_MESSAGE_HEARD"); msgHeardIntent.putExtra("dialog_id", dialog_id); msgHeardIntent.putExtra("max_id", max_id); PendingIntent msgHeardPendingIntent = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, notificationIdAuto, msgHeardIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent msgReplyIntent = new Intent(); msgReplyIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); msgReplyIntent.setAction("org.telegramsecureplus.messenger.ACTION_MESSAGE_REPLY"); msgReplyIntent.putExtra("dialog_id", dialog_id); msgReplyIntent.putExtra("max_id", max_id); PendingIntent msgReplyPendingIntent = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, notificationIdAuto, msgReplyIntent, PendingIntent.FLAG_UPDATE_CURRENT); RemoteInput remoteInputAuto = new RemoteInput.Builder(NotificationsController.EXTRA_VOICE_REPLY) .setLabel(LocaleController.getString("Reply", R.string.Reply)).build(); NotificationCompat.CarExtender.UnreadConversation.Builder unreadConvBuilder = new NotificationCompat.CarExtender.UnreadConversation.Builder( name).setReadPendingIntent(msgHeardPendingIntent) .setReplyAction(msgReplyPendingIntent, remoteInputAuto) .setLatestTimestamp((long) max_date * 1000); Intent replyIntent = new Intent(ApplicationLoader.applicationContext, WearReplyReceiver.class); replyIntent.putExtra("dialog_id", dialog_id); replyIntent.putExtra("max_id", max_id); PendingIntent replyPendingIntent = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, notificationIdWear, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT); RemoteInput remoteInputWear = new RemoteInput.Builder(EXTRA_VOICE_REPLY) .setLabel(LocaleController.getString("Reply", R.string.Reply)).build(); String replyToString; if (chat != null) { replyToString = LocaleController.formatString("ReplyToGroup", R.string.ReplyToGroup, name); } else { replyToString = LocaleController.formatString("ReplyToUser", R.string.ReplyToUser, name); } NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon, replyToString, replyPendingIntent).addRemoteInput(remoteInputWear).build(); String text = ""; for (int a = messageObjects.size() - 1; a >= 0; a--) { MessageObject messageObject = messageObjects.get(a); String message = getStringForMessage(messageObject, false); if (message == null) { continue; } if (chat != null) { message = message.replace(" @ " + name, ""); } else { message = message.replace(name + ": ", "").replace(name + " ", ""); } if (text.length() > 0) { text += "\n\n"; } text += message; unreadConvBuilder.addMessage(message); } TLRPC.FileLocation photoPath = null; if (chat != null) { if (chat.photo != null && chat.photo.photo_small != null && chat.photo.photo_small.volume_id != 0 && chat.photo.photo_small.local_id != 0) { photoPath = chat.photo.photo_small; } } else { if (user.photo != null && user.photo.photo_small != null && user.photo.photo_small.volume_id != 0 && user.photo.photo_small.local_id != 0) { photoPath = user.photo.photo_small; } } Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class); intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE); intent.setFlags(32768); if (chat != null) { intent.putExtra("chatId", chat.id); } else if (user != null) { intent.putExtra("userId", user.id); } PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Builder builder = new NotificationCompat.Builder( ApplicationLoader.applicationContext).setContentTitle(name) .setSmallIcon(R.drawable.notification).setGroup("messages").setContentText(text) .setColor(0xff2ca5e0).setGroupSummary(false).setContentIntent(contentIntent) .extend(new NotificationCompat.WearableExtender().addAction(action)) .extend(new NotificationCompat.CarExtender() .setUnreadConversation(unreadConvBuilder.build())) .setCategory(NotificationCompat.CATEGORY_MESSAGE); if (photoPath != null) { BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photoPath, null, "50_50"); if (img != null) { builder.setLargeIcon(img.getBitmap()); } } if (chat == null && user != null && user.phone != null && user.phone.length() > 0) { builder.addPerson("tel:+" + user.phone); } notificationManager.notify(notificationIdWear, builder.build()); wearNotificationsIds.put(dialog_id, notificationIdWear); } for (HashMap.Entry<Long, Integer> entry : oldIdsWear.entrySet()) { notificationManager.cancel(entry.getValue()); } }