List of usage examples for java.util HashMap remove
public V remove(Object key)
From source file:com.altcanvas.asocial.Twitter.java
private String generateAuthorizationHeader(String method, String url, Map<String, String> postParams) { HashMap<String, String> oauthHeaderParams = new HashMap<String, String>(); // Insert hardcoded oauth entries long timestamp = System.currentTimeMillis() / 1000; long nonce = timestamp + 5; oauthHeaderParams.put("oauth_consumer_key", OAUTH_CONSUMER_KEY); oauthHeaderParams.put("oauth_signature_method", OAUTH_SIGNATURE_METHOD); oauthHeaderParams.put("oauth_timestamp", "" + timestamp); oauthHeaderParams.put("oauth_nonce", "" + nonce); oauthHeaderParams.put("oauth_version", "1.0"); if (this.token != null) { oauthHeaderParams.put("oauth_token", this.token); }/* w w w.j av a 2 s.c o m*/ // Insert entries from post parameters for (Map.Entry<String, String> e : postParams.entrySet()) { oauthHeaderParams.put(e.getKey(), e.getValue()); } // Parse and insert GET parameters parseGetParams(url, oauthHeaderParams); StringBuffer base = new StringBuffer(method).append("&").append(Http.encode(extractBaseUrl(url))) .append("&").append(Http.encode(Http.encodeParams(new TreeMap(oauthHeaderParams), "&", false))); String signature = new String(generateSignature(base.toString())); oauthHeaderParams.put("oauth_signature", signature); for (Map.Entry<String, String> e : postParams.entrySet()) { oauthHeaderParams.remove(e.getKey()); } return Http.encodeParams(oauthHeaderParams, ",", true); }
From source file:org.quartz.simpl.RAMJobStore.java
private boolean removeTrigger(SchedulingContext ctxt, String triggerName, String groupName, boolean removeOrphanedJob) { String key = TriggerWrapper.getTriggerNameKey(triggerName, groupName); boolean found = false; synchronized (triggerLock) { // remove from triggers by FQN map found = (triggersByFQN.remove(key) == null) ? false : true; if (found) { TriggerWrapper tw = null;/*from ww w . j av a 2s. c o m*/ // remove from triggers by group HashMap grpMap = (HashMap) triggersByGroup.get(groupName); if (grpMap != null) { grpMap.remove(triggerName); if (grpMap.size() == 0) { triggersByGroup.remove(groupName); } } // remove from triggers array Iterator tgs = triggers.iterator(); while (tgs.hasNext()) { tw = (TriggerWrapper) tgs.next(); if (key.equals(tw.key)) { tgs.remove(); break; } } timeTriggers.remove(tw); if (removeOrphanedJob) { JobWrapper jw = (JobWrapper) jobsByFQN .get(JobWrapper.getJobNameKey(tw.trigger.getJobName(), tw.trigger.getJobGroup())); Trigger[] trigs = getTriggersForJob(ctxt, tw.trigger.getJobName(), tw.trigger.getJobGroup()); if ((trigs == null || trigs.length == 0) && !jw.jobDetail.isDurable()) { removeJob(ctxt, tw.trigger.getJobName(), tw.trigger.getJobGroup()); } } } } return found; }
From source file:org.hyperic.hq.ui.action.resource.group.control.EditFormPrepareAction.java
/** * Find the control action and populate the GroupControlForm. *//* w w w . j a v a 2 s . co m*/ public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { log.trace("preparing edit group control action"); int sessionId = RequestUtils.getSessionId(request).intValue(); GroupControlForm gForm = (GroupControlForm) form; AppdefEntityID appdefId = RequestUtils.getEntityId(request); List<String> actions = controlBoss.getActions(sessionId, appdefId); List<OptionItem> options = OptionItem.createOptionsList(actions); gForm.setControlActions(options); gForm.setNumControlActions(new Integer(options.size())); Integer trigger = RequestUtils.getIntParameter(request, Constants.CONTROL_BATCH_ID_PARAM); ControlSchedule job = controlBoss.getControlJob(sessionId, trigger); // populate control actions gForm.populateFromSchedule(job.getScheduleValue(), request.getLocale()); gForm.setControlAction(job.getAction()); gForm.setDescription(job.getScheduleValue().getDescription()); // get the resource ids associated with this group, // create an options list, and associate it with the form AppdefGroupValue group = appdefBoss.findGroup(sessionId, appdefId.getId()); List<AppdefResourceValue> groupMembers = BizappUtils.buildGroupResources(appdefBoss, sessionId, group, PageControl.PAGE_ALL); ArrayList<LabelValueBean> groupOptions = new ArrayList<LabelValueBean>(); HashMap<String, String> mapOfGroupMembers = new HashMap<String, String>(); for (AppdefResourceValue arv : groupMembers) { LabelValueBean lvb = new LabelValueBean(arv.getName(), arv.getId().toString()); groupOptions.add(lvb); // create a set for ordering, later. mapOfGroupMembers.put(arv.getId().toString(), arv.getName()); } gForm.setResourceOrderingOptions(groupOptions); // if this is an ordered control action String resourceOrdering = job.getJobOrderData(); if (resourceOrdering != null && !"".equals(resourceOrdering.trim())) { gForm.setInParallel(GroupControlForm.IN_ORDER); groupOptions = new ArrayList<LabelValueBean>(); // comes back in the form of a string list // of group members for ordering 10001,10002,10004. barf. StringTokenizer tok = new StringTokenizer(resourceOrdering, ","); String gmemberId; while (tok.hasMoreTokens()) { gmemberId = tok.nextToken(); if (!mapOfGroupMembers.containsKey(gmemberId)) { // weird, in ordering, but not in group log.warn("Group control ordering contains id" + " of non group member."); } else { LabelValueBean lvb = new LabelValueBean((String) mapOfGroupMembers.get(gmemberId), gmemberId); groupOptions.add(lvb); mapOfGroupMembers.remove(gmemberId); } } // there are members of the group, that were not contained // in the ordering for some reason if (mapOfGroupMembers.size() != 0) { Set<String> memberIds = mapOfGroupMembers.keySet(); Iterator<String> idIterator = memberIds.iterator(); while (idIterator.hasNext()) { gmemberId = idIterator.next(); LabelValueBean lvb = new LabelValueBean((String) mapOfGroupMembers.get(gmemberId), gmemberId); groupOptions.add(lvb); } } gForm.setResourceOrderingOptions(groupOptions); } return null; }
From source file:org.quartz.simpl.RAMJobStore.java
/** * @see org.quartz.spi.JobStore#replaceTrigger(org.quartz.core.SchedulingContext, java.lang.String, java.lang.String, org.quartz.Trigger) *///from ww w . jav a 2 s . c om public boolean replaceTrigger(SchedulingContext ctxt, String triggerName, String groupName, Trigger newTrigger) throws JobPersistenceException { String key = TriggerWrapper.getTriggerNameKey(triggerName, groupName); boolean found = false; synchronized (triggerLock) { // remove from triggers by FQN map TriggerWrapper tw = (TriggerWrapper) triggersByFQN.remove(key); found = (tw == null) ? false : true; if (found) { if (!tw.getTrigger().getJobName().equals(newTrigger.getJobName()) || !tw.getTrigger().getJobGroup().equals(newTrigger.getJobGroup())) { throw new JobPersistenceException( "New trigger is not related to the same job as the old trigger."); } tw = null; // remove from triggers by group HashMap grpMap = (HashMap) triggersByGroup.get(groupName); if (grpMap != null) { grpMap.remove(triggerName); if (grpMap.size() == 0) { triggersByGroup.remove(groupName); } } // remove from triggers array Iterator tgs = triggers.iterator(); while (tgs.hasNext()) { tw = (TriggerWrapper) tgs.next(); if (key.equals(tw.key)) { tgs.remove(); break; } } timeTriggers.remove(tw); try { storeTrigger(ctxt, newTrigger, false); } catch (JobPersistenceException jpe) { storeTrigger(ctxt, tw.getTrigger(), false); // put previous trigger back... throw jpe; } } } return found; }
From source file:org.sakaiproject.signup.tool.jsf.attachment.AttachmentHandler.java
private void processItemAttachment() { ToolSession session = SessionManager.getCurrentToolSession(); if (session.getAttribute(FilePickerHelper.FILE_PICKER_ATTACHMENTS) != null) { HashMap map = getResourceIdHash(this.attachments); ArrayList newAttachmentList = new ArrayList(); String protocol = getSakaiFacade().getServerConfigurationService().getServerUrl(); List refs = (List) session.getAttribute(FilePickerHelper.FILE_PICKER_ATTACHMENTS); if (refs != null && refs.size() > 0) { Reference ref;/*from w w w. j a v a2 s . c o m*/ for (int i = 0; i < refs.size(); i++) { ref = (Reference) refs.get(i); String resourceId = ref.getId(); if (map.get(resourceId) == null) { // new attachment, add SignupAttachment newAttach = createSignupAttachment(ref.getId(), ref.getProperties().getProperty(ref.getProperties().getNamePropDisplayName()), protocol); newAttachmentList.add(newAttach); } else { // attachment already exist, let's add it to new list // and // check it off from map newAttachmentList.add((SignupAttachment) map.get(resourceId)); map.remove(resourceId); } } } session.removeAttribute(FilePickerHelper.FILE_PICKER_ATTACHMENTS); session.removeAttribute(FilePickerHelper.FILE_PICKER_CANCEL); this.attachments.clear(); this.attachments.addAll(newAttachmentList); } }
From source file:org.akaza.openclinica.controller.SystemController.java
public HashMap<String, String> getDbRoleProperties(Connection conn, HashMap<String, String> mapRole, String username, Boolean withoutRoleName) throws SQLException { mapRole = getDbRoleProperties(conn, mapRole, username); if (withoutRoleName) mapRole.remove("RoleName"); return mapRole; }
From source file:org.apache.hadoop.fs.azure.AzureNativeFileSystemStore.java
private static void storeVersionAttribute(CloudBlobContainerWrapper container) { HashMap<String, String> metadata = container.getMetadata(); if (null == metadata) { metadata = new HashMap<String, String>(); }/* ww w . java 2 s. c o m*/ metadata.put(VERSION_METADATA_KEY, CURRENT_WASB_VERSION); if (metadata.containsKey(OLD_VERSION_METADATA_KEY)) { metadata.remove(OLD_VERSION_METADATA_KEY); } container.setMetadata(metadata); }
From source file:com.jci.po.repo.PoRepoImpl.java
@Override public ResultSet getPoItemDetail(ScrollingParam param, DataHelper request) throws InvalidKeyException, URISyntaxException, StorageException { ResultContinuation continuationToken = DataUtil.getContinuationToken(param); PaginationParam pagination = new PaginationParam(); if (continuationToken != null) { pagination.setLastPartition(param.getPartition()); pagination.setLastRow(param.getRow()); }/*from w w w . j ava 2 s. c o m*/ // Create the query String whereCondition = QueryBuilder.poItemDetailQuery(request); LOG.debug("whereCondition--->" + whereCondition); if (StringUtils.isBlank(whereCondition)) { return null; } TableQuery<DynamicTableEntity> query = TableQuery.from(DynamicTableEntity.class).where(whereCondition) .take(param.getSize()); CloudTable table = azureStorage.getTable(request.getTableName()); LOG.debug("getTableName--->" + request.getTableName()); // segmented query ResultSegment<DynamicTableEntity> response = table.executeSegmented(query, continuationToken); // next continuation token continuationToken = response.getContinuationToken(); if (continuationToken != null) { pagination.setNextPartition(continuationToken.getNextPartitionKey()); pagination.setNextRow(continuationToken.getNextRowKey()); } HashMap<String, Object> hashmap; List<HashMap<String, Object>> series = new ArrayList<>(); DynamicTableEntity row; EntityProperty ep; ObjectMapper mapper = new ObjectMapper(); TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() { }; Iterator<DynamicTableEntity> rows = response.getResults().iterator(); while (rows.hasNext()) { row = rows.next(); HashMap<String, EntityProperty> map = row.getProperties(); hashmap = new HashMap<>(); for (String key : map.keySet()) { ep = map.get(key); if ("POItemJsonString".equals(key) || "POJsonString".equals(key)) { try { hashmap = mapper.readValue(ep.getValueAsString(), typeRef); if ("POJsonString".equals(key) && hashmap.containsKey("itemList")) { hashmap.remove("itemList"); } hashmap.put("id", row.getRowKey()); } catch (IOException e) { LOG.error("### Exception in ####", e); } } } series.add(hashmap); } LOG.error("series--->" + series); return new ResultSet(series, pagination); }
From source file:org.kalypso.wizard.KalypsoNAProjectWizard.java
public void mapRiver(final List sourceFeatureList, final HashMap mapping) { final Feature rootFeature = m_modelWS.getRootFeature(); final Feature channelCollectionFE = (Feature) rootFeature .getProperty(NaModelConstants.CHANNEL_COLLECTION_MEMBER_PROP); final FeatureList channelList = (FeatureList) channelCollectionFE .getProperty(NaModelConstants.CHANNEL_MEMBER_PROP); final IRelationType targetRelation = channelList.getParentFeatureTypeProperty(); // find column for id final String idColKey; if (mapping.containsKey("name")) //$NON-NLS-1$ {/*w w w . j a v a2s .co m*/ idColKey = (String) mapping.get("name"); //$NON-NLS-1$ } else idColKey = null; // StrangArt is defined in dummyFeatureType (member variable) final String typeKey = (String) mapping.get("StrangArt"); //$NON-NLS-1$ // remove the channel type mapping (just needed once) mapping.remove(typeKey); for (int i = 0; i < sourceFeatureList.size(); i++) { final Feature sourceFeature = (Feature) sourceFeatureList.get(i); final Object o = sourceFeature.getProperty(typeKey); int channelType = 0; try { channelType = ((Integer) SpecialPropertyMapper.map(o.getClass(), Integer.class, o)).intValue(); } catch (final Exception e) { e.printStackTrace(); throw new NumberFormatException(Messages.get("KalypsoNAProjectWizard.ExceptionStrangArt")); //$NON-NLS-1$ } Feature targetFeature = null; final String fid = getId(idColKey, sourceFeature, "S"); switch (channelType) { case 0: { final IFeatureType vFT = getFeatureType("VirtualChannel"); //$NON-NLS-1$ targetFeature = FeatureFactory.createFeature(channelCollectionFE, targetRelation, fid, vFT, true); break; } case 1: { final IFeatureType kmFT = getFeatureType("KMChannel"); //$NON-NLS-1$ targetFeature = FeatureFactory.createFeature(channelCollectionFE, targetRelation, fid, kmFT, true); final IRelationType parameterMemberRT = (IRelationType) kmFT .getProperty(NaModelConstants.KM_CHANNEL_PARAMETER_MEMBER); final List list = FeatureFactory.createFeatureList(targetFeature, parameterMemberRT); targetFeature.setProperty(parameterMemberRT, list); final int channelNo = Integer.parseInt(m_createPreferencePage.getKMChannelNo()); for (int j = 0; j < channelNo; j++) { final IFeatureType kmParameterFT = parameterMemberRT.getTargetFeatureType(); final Feature newFeature = m_modelWS.createFeature(targetFeature, targetRelation, kmParameterFT); try { m_modelWS.addFeatureAsComposition(targetFeature, parameterMemberRT, j, newFeature); } catch (final Exception e) { e.printStackTrace(); } } break; } case 2: { final IFeatureType storageFT = getFeatureType("StorageChannel"); //$NON-NLS-1$ targetFeature = FeatureFactory.createFeature(channelCollectionFE, targetRelation, fid, storageFT, true); break; } case 3: { throw new NotImplementedException( Messages.get("KalypsoNAProjectWizard.ExceptionNotImplementedRHT")); //$NON-NLS-1$ } default: { break; } }// switch final Iterator it = mapping.keySet().iterator(); while (it.hasNext()) { final String targetkey = (String) it.next(); final String sourcekey = (String) mapping.get(targetkey); if ("StrangArt".equals(targetkey)) continue; if (!sourcekey.equalsIgnoreCase(NULL_KEY)) { final Object so = sourceFeature.getProperty(sourcekey); final IPropertyType pt = targetFeature.getFeatureType().getProperty(targetkey); if (so instanceof GM_MultiCurve) { final GM_Curve[] curves = new GM_Curve[] { ((GM_MultiCurve) so).getCurveAt(0) }; targetFeature.setProperty(targetkey, curves[0]); } // if( so instanceof GMLMultiLineString ) // targetFeature.setProperty( targetkey, so ); else if (pt instanceof IValuePropertyType) { final IValuePropertyType vpt = (IValuePropertyType) pt; if (so.getClass().equals(vpt.getTypeHandler().getValueClass())) { targetFeature.setProperty(targetkey, so); } else { try { targetFeature.setProperty(targetkey, SpecialPropertyMapper.map(so.getClass(), vpt.getTypeHandler().getValueClass(), so)); } catch (final Exception e) { e.printStackTrace(); } } } } } channelList.add(targetFeature); } // for i }
From source file:org.wso2.carbon.event.simulator.core.internal.CarbonEventSimulator.java
@Override public void deleteDBConfigFile(String fileName, AxisConfiguration axisConfiguration) throws AxisFault { int tenantID = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); HashMap<String, DataSourceTableAndStreamInfo> dataSourceTableAndStreamInfoMap = tenantSpecificDataSourceInfoMap .get(tenantID);/*from ww w .j a v a 2 s .c o m*/ fileName = fileName.replace(EventSimulatorConstant.DATA_SOURCE_CONFIGURATION_XML_SUFFIX, ""); DataSourceTableAndStreamInfo dataSourceTableAndStreamInfo = dataSourceTableAndStreamInfoMap.get(fileName); String repo = axisConfiguration.getRepository().getPath(); String path = repo + EventSimulatorConstant.DEPLOY_DIRECTORY_PATH; String xmlFilePath = path + File.separator + dataSourceTableAndStreamInfo.getFileName(); File xmlFile = new File(xmlFilePath); if (xmlFile.exists()) { dataSourceTableAndStreamInfoMap.remove(fileName); xmlFile.delete(); Map<String, EventCreatorForDB> tenantSpecificEventSimulatorMap = dbEventSimulatorMap.get(tenantID); if (tenantSpecificEventSimulatorMap != null) { tenantSpecificEventSimulatorMap.remove(fileName); } } }