List of usage examples for java.util Map remove
V remove(Object key);
From source file:bluej.collect.DataCollectorImpl.java
public static void renamedClass(Package pkg, final File oldSourceFile, final File newSourceFile) { final ProjectDetails projDetails = new ProjectDetails(pkg.getProject()); MultipartEntity mpe = new MultipartEntity(); mpe.addPart("source_histories[][source_history_type]", CollectUtility.toBody("rename")); mpe.addPart("source_histories[][content]", CollectUtility.toBodyLocal(projDetails, oldSourceFile)); mpe.addPart("source_histories[][name]", CollectUtility.toBodyLocal(projDetails, newSourceFile)); submitEvent(pkg.getProject(), pkg, EventName.RENAME, new PlainEvent(mpe) { @Override// w ww . j av a 2 s. c om public MultipartEntity makeData(int sequenceNum, Map<FileKey, List<String>> fileVersions) { // We need to change the fileVersions hash to move the content across from the old file // to the new file: FileKey oldKey = new FileKey(projDetails, CollectUtility.toPath(projDetails, oldSourceFile)); FileKey newKey = new FileKey(projDetails, CollectUtility.toPath(projDetails, newSourceFile)); fileVersions.put(newKey, fileVersions.get(oldKey)); fileVersions.remove(oldKey); return super.makeData(sequenceNum, fileVersions); } }); }
From source file:grails.plugin.searchable.internal.compass.index.DefaultIndexMethod.java
public Object invoke(Object[] args) { Map options = SearchableMethodUtils.getOptionsArgument(args, getDefaultOptions()); final Class clazz = (Class) (options.containsKey("match") ? options.remove("match") : options.remove("class")); final List ids = getIds(args); final List objects = getObjects(args); validateArguments(args, clazz, ids, objects, options); if (args.length == 0 || (args.length == 1 && args[0] instanceof Map && clazz != null)) { CompassGpsUtils.index(compassGps, clazz); return null; }/* w ww.j a v a 2s . c o m*/ return doInCompass(new CompassCallback() { public Object doInCompass(CompassSession session) throws CompassException { List objectsToSave = objects; if (clazz != null && !ids.isEmpty()) { Assert.isTrue(objects.isEmpty(), "Either provide ids or objects, not both"); objectsToSave = (List) InvokerHelper.invokeStaticMethod(clazz, "getAll", ids); } Assert.notEmpty(objectsToSave); for (Iterator iter = objectsToSave.iterator(); iter.hasNext();) { Object o = iter.next(); if (o != null) { session.save(o); } } return ids.isEmpty() ? (objectsToSave.size() == 1 ? objectsToSave.get(0) : objectsToSave) : (ids.size() == 1 ? objectsToSave.get(0) : objectsToSave); } }); }
From source file:org.craftercms.core.controller.rest.ContentStoreRestController.java
@RequestMapping(value = URL_DESCRIPTOR, method = RequestMethod.GET) public Map<String, Object> getDescriptor(WebRequest request, HttpServletResponse response, @RequestParam(REQUEST_PARAM_CONTEXT_ID) String contextId, @RequestParam(REQUEST_PARAM_URL) String url) throws InvalidContextException, StoreException, PathNotFoundException, ItemProcessingException, XmlMergeException, XmlFileParseException { Map<String, Object> model = getItem(request, response, contextId, url); if (MapUtils.isNotEmpty(model)) { Item item = (Item) model.remove(MODEL_ATTR_ITEM); model.put(MODEL_ATTR_DESCRIPTOR, item.getDescriptorDom()); }/*from w ww .java2 s . c om*/ return model; }
From source file:com.imaginary.home.cloud.device.PoweredDevice.java
@Override public void update(@Nonnull JSONObject json) throws PersistenceException { try {//www .jav a2s. co m Memento<PoweredDevice> memento = new Memento<PoweredDevice>(this); Map<String, Object> state = new HashMap<String, Object>(); mapPoweredDevice(getRelay(), json, state); state.remove("vendorDeviceId"); state.remove("deviceId"); memento.save(state); state = memento.getState(); Transaction xaction = Transaction.getInstance(); try { getCache().update(xaction, this, state); xaction.commit(); } finally { xaction.rollback(); } memento.load(state); } catch (JSONException e) { throw new PersistenceException(e); } }
From source file:controllers.ImageBrowser.java
public static void pasteAttributes(Project project, Path path, String jsonAttributes, boolean overwrite, boolean dataMode) { if (!permitMetadataEdit(project, dataMode)) forbidden();/*w w w . j av a 2s. c o m*/ Stopwatch sw = new Stopwatch(); sw.start("loading image"); DatabaseImage image = DatabaseImage.forPath(path); sw.stop("loading image"); sw.start("parsing json"); Type listType = new TypeToken<List<KeyValueStore>>() { }.getType(); List<KeyValueStore> attributes = new GsonBuilder().create().fromJson(jsonAttributes, listType); sw.stop("parsing json"); sw.start("get map"); Map<String, List<ImageAttribute>> existingMap = DatabaseImageService.attributeMapForImageAndMode(project, image, dataMode); sw.start("get map"); sw.start("loop"); for (KeyValueStore attr : attributes) { if (attr.value == null) continue; sw.start("loopinner"); if (existingMap.containsKey(attr.attribute)) { if (!overwrite) continue; sw.start("delete all"); for (ImageAttribute iattr : existingMap.get(attr.attribute)) { iattr.delete(); } sw.stop("delete all"); existingMap.remove(attr.attribute); } if (attr.value.trim().isEmpty()) continue; sw.start("add attr"); image.addAttribute(project, attr.attribute, attr.value, dataMode); sw.stop("add attr"); sw.stop("loopinner"); } sw.stop("loop"); sw.start("export data"); ImportExportService.tryExportData(image); sw.stop("export data"); System.out.println(sw.toString()); jsonOk(); }
From source file:com.fatwire.dta.sscrawler.reporting.reporters.PageCriteriaReporter.java
public void addToReport(final ResultPage page) { if (page.getResponseCode() != 200) { return; // bail out }//from w ww .j a v a 2s . c om // check if this pagelet should be cached (is cacheable) if (page.getBody().endsWith(HelperStrings.STATUS_NOTCACHED)) { return; } else { if (!CacheHelper.shouldCache(page.getResponseHeaders())) { return; // page should not be cached based on SiteCatalog info } } final Header[] headers = page.getResponseHeaders(); for (final Header header : headers) { if (HelperStrings.PAGE_CRITERIA_HEADER.equals(header.getName())) { final List<String> pageCriteria = Arrays .asList(header.getValue() == null ? new String[0] : header.getValue().split(",")); final Map<String, String> params = new TreeMap<String, String>(page.getUri().getParameters()); // remove params that should not be part of PageCriteria params.remove(HelperStrings.PAGENAME); params.remove(HelperStrings.RENDERMODE); params.remove(HelperStrings.SS_CLIENT_INDICATOR); params.remove(HelperStrings.SS_PAGEDATA_REQUEST); for (final String param : params.keySet()) { if (!pageCriteria.contains(param)) { count.incrementAndGet(); report.addRow(page.getPageName(), page.getUri().toString(), param, header.getValue()); } } break; } } }
From source file:com.googlecode.starflow.engine.core.data.ThreadLocalRelaDataManager.java
private Object doUnbindResource(Object actualKey) { Map<Object, Object> map = resources.get(); if (map == null) { return null; }//from w ww . j a v a2s . c om Object value = map.remove(actualKey); // Remove entire ThreadLocal if empty... if (map.isEmpty()) { resources.set(null); } if (value != null && logger.isTraceEnabled()) { logger.trace("Removed value [" + value + "] for key [" + actualKey + "] from thread [" + Thread.currentThread().getName() + "]"); } return value; }
From source file:fr.mby.saml2.sp.impl.web.Saml20RequestWrapper.java
@SuppressWarnings("unchecked") protected Saml20RequestWrapper(final HttpServletRequest request, final Map<String, String[]> initialParams) throws SamlProcessingException, UnsupportedSamlOperation { super(request); Saml20RequestWrapper.LOGGER.debug("Wrapping SAML 2.0 request..."); // Unlock the map final Map<String, String[]> parameters = new HashMap<String, String[]>(super.getParameterMap()); final String idpIdParamKey = SamlHelper.getWayfConfig().getIdpIdParamKey(); parameters.remove(idpIdParamKey); parameters.remove(SamlHelper.SAML_RESPONSE_PARAM_KEY); if (!CollectionUtils.isEmpty(initialParams)) { parameters.putAll(initialParams); }// w w w. j av a 2 s . c om // Lock the map. this.parameters = MapUtils.unmodifiableMap(parameters); }
From source file:io.github.restdocsext.jersey.JerseyRestDocumentationFilter.java
/** * Create a new {@link JerseyRestDocumentationFilter} that will produce documentation * with the provided snippets.// ww w .ja v a 2 s .co m * * @param snippets the snippets to add * @return a new Jersey documentation filter. */ public JerseyRestDocumentationFilter document(Snippet... snippets) { return new JerseyRestDocumentationFilter(this.delegate.withSnippets(snippets)) { @SuppressWarnings("unchecked") @Override public void filter(ClientRequestContext request, ClientResponseContext response) throws IOException { final Map<String, Object> configuration = new HashMap<>( getContextProperty(request, CONTEXT_CONFIGURATION_KEY, Map.class)); configuration.remove(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS); super.filter(request, response); } }; }
From source file:com.alibaba.cobar.manager.web.screen.MClusterListScreen.java
@SuppressWarnings("unchecked") @Override/*from ww w .j a va 2 s . c o m*/ protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { UserDO user = (UserDO) request.getSession().getAttribute("user"); List<ClusterDO> list = xmlAccesser.getClusterDAO().listAllCluster(); List<Map<String, Object>> clusterList = new ArrayList<Map<String, Object>>(); ListSortUtil.sortClusterBySortId(list); PropertyUtilsBean util = new PropertyUtilsBean(); for (ClusterDO e : list) { int count = xmlAccesser.getCobarDAO().getCobarList(e.getId(), ConstantDefine.ACTIVE).size(); count += xmlAccesser.getCobarDAO().getCobarList(e.getId(), ConstantDefine.IN_ACTIVE).size(); Map<String, Object> map; try { map = util.describe(e); } catch (Exception ex) { throw new RuntimeException(ex); } map.remove("class"); map.remove("name"); map.remove("deployDesc"); map.put("name", CobarStringUtil.htmlEscapedString(e.getName())); map.put("deployContact", CobarStringUtil.htmlEscapedString(e.getDeployContact())); map.put("cobarNum", count); clusterList.add(map); } return new ModelAndView("m_clusterList", new FluenceHashMap<String, Object>() .putKeyValue("clusterList", clusterList).putKeyValue("user", user)); }