List of usage examples for java.util Collections EMPTY_MAP
Map EMPTY_MAP
To view the source code for java.util Collections EMPTY_MAP.
Click Source Link
From source file:org.grails.plugins.zkui.metaclass.RedirectDynamicMethod.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override/*from w w w.j av a 2s . c o m*/ public Object invoke(Object target, String methodName, Object[] arguments) { if (arguments.length == 0) { throw new MissingMethodException(METHOD_SIGNATURE, target.getClass(), arguments); } Map argMap = arguments[0] instanceof Map ? (Map) arguments[0] : Collections.EMPTY_MAP; if (argMap.isEmpty()) { throw new MissingMethodException(METHOD_SIGNATURE, target.getClass(), arguments); } GrailsWebRequest webRequest = (GrailsWebRequest) RequestContextHolder.currentRequestAttributes(); HttpServletRequest request = webRequest.getCurrentRequest(); if (request.getAttribute(GRAILS_REDIRECT_ISSUED) != null) { throw new CannotRedirectException( "Cannot issue a redirect(..) here. A previous call to redirect(..) has already redirected the response."); } HttpServletResponse response = webRequest.getCurrentResponse(); if (response.isCommitted()) { throw new CannotRedirectException( "Cannot issue a redirect(..) here. The response has already been committed either by another redirect or by directly writing to the response."); } Object uri = argMap.get(ARGUMENT_URI); String url = argMap.containsKey(ARGUMENT_URL) ? argMap.get(ARGUMENT_URL).toString() : null; String actualUri; if (uri != null) { GrailsApplicationAttributes attrs = webRequest.getAttributes(); actualUri = attrs.getApplicationUri(request) + uri.toString(); } else if (url != null) { actualUri = url; } else { if (argMap.get(ARGUMENT_ACTION) == null || argMap.get(ARGUMENT_CONTROLLER) == null) { throw new CannotRedirectException( "redirect required attribute [controller] or attribute [action] is missing"); } String actionName = argMap.get(ARGUMENT_ACTION).toString(); String controllerName = argMap.get(ARGUMENT_CONTROLLER).toString(); controllerName = controllerName != null ? controllerName : webRequest.getControllerName(); Map params = (Map) argMap.get(ARGUMENT_PARAMS); if (params == null) { params = new HashMap(); } if (LOG.isDebugEnabled()) { LOG.debug("Dynamic method [redirect] looking up URL mapping for controller [" + controllerName + "] and action [" + actionName + "] and params [" + params + "] with [" + urlMappingsHolder + "]"); } Object id = argMap.get(ARGUMENT_ID); try { if (id != null) { params.put(ARGUMENT_ID, id); } UrlCreator urlMapping = urlMappingsHolder.getReverseMapping(controllerName, actionName, params); if (urlMapping == null && LOG.isDebugEnabled()) { LOG.debug("Dynamic method [redirect] no URL mapping found for params [" + params + "]"); } String frag = argMap.get(ARGUMENT_FRAGMENT) != null ? argMap.get(ARGUMENT_FRAGMENT).toString() : null; actualUri = urlMapping.createURL(controllerName, actionName, params, request.getCharacterEncoding(), frag); if (LOG.isDebugEnabled()) { LOG.debug("Dynamic method [redirect] mapped to URL [" + actualUri + "]"); } } finally { if (id != null) { params.remove(ARGUMENT_ID); } } } return redirectResponse(actualUri, request, response); }
From source file:org.forgerock.openam.examples.SampleConditionType.java
@Override public ConditionDecision evaluate(String realm, Subject subject, String resource, Map<String, Set<String>> environment) throws EntitlementException { boolean authorized = true; for (Principal principal : subject.getPrincipals()) { String userDn = principal.getName(); int start = userDn.indexOf('='); int end = userDn.indexOf(','); if (end <= start) { throw new EntitlementException(EntitlementException.CONDITION_EVALUTATION_FAILED, "Name is not a valid DN: " + userDn); }/* w w w . j ava2s. com*/ String userName = userDn.substring(start + 1, end); if (userName.length() < getNameLength()) { authorized = false; } } return new ConditionDecision(authorized, Collections.EMPTY_MAP); }
From source file:diva.rest.model.DivaRoot.java
public DivaRoot(URI uri) { ResourceSet rs = new ResourceSetImpl(); Resource res = rs.createResource(uri); try {/*from w w w.jav a 2 s . c om*/ res.load(Collections.EMPTY_MAP); this.root = (VariabilityModel) res.getContents().get(0); } catch (Exception e) { e.printStackTrace(); } }
From source file:architecture.ee.web.servlet.ViewRendererServlet.java
protected Map resolveModel(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) { Map map = (Map) httpservletrequest.getAttribute(WebApplicatioinConstants.MODEL_ATTRIBUTE); if (map != null) return map; else/*from w ww.jav a 2 s. c o m*/ return Collections.EMPTY_MAP; }
From source file:de.betterform.agent.web.flux.FluxFacade.java
public List<XMLEvent> dispatchEventTypeWithContext(String id, String eventType, String sessionKey, String contextInfo) throws XFormsException { Map params;// w w w . jav a2 s . c om if (contextInfo != null) { params = new HashMap(1); params.put("context-info", contextInfo); } else { params = Collections.EMPTY_MAP; } return dispatchEventTypeWithContext(id, eventType, sessionKey, params); }
From source file:com.redhat.rhn.frontend.dto.SystemCompareDto.java
private List<Item> compare(List strings) { return compare(strings, Collections.EMPTY_MAP); }
From source file:se.uu.it.cs.recsys.constraint.builder.CreditDomainBuilder.java
/** * * @param idSet the set of course ids/*from w w w . j ava 2s . c o m*/ * @return mapping between course credit and course */ public Map<CourseCredit, Set<Integer>> getCreditAndIdSetMappingFor(Set<Integer> idSet) { if (idSet == null || idSet.isEmpty()) { LOGGER.warn("Does not make sense to put null or empty set, right?"); return Collections.EMPTY_MAP; } Map<CourseCredit, Set<Integer>> creditAndIds = new HashMap<>(); this.courseRepository.findByAutoGenIds(idSet).forEach(course -> { checkCourseCreditAndPutToMap(course, creditAndIds); }); return creditAndIds; }
From source file:org.codehaus.groovy.grails.web.metaclass.RedirectDynamicMethod.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override/*from ww w.ja v a 2s . c om*/ public Object invoke(Object target, String methodName, Object[] arguments) { if (arguments.length == 0) { throw new MissingMethodException(METHOD_SIGNATURE, target.getClass(), arguments); } Map argMap = arguments[0] instanceof Map ? (Map) arguments[0] : Collections.EMPTY_MAP; if (argMap.isEmpty()) { throw new MissingMethodException(METHOD_SIGNATURE, target.getClass(), arguments); } GrailsWebRequest webRequest = (GrailsWebRequest) RequestContextHolder.currentRequestAttributes(); LinkGenerator requestLinkGenerator = getLinkGenerator(webRequest); HttpServletRequest request = webRequest.getCurrentRequest(); if (request.getAttribute(GRAILS_REDIRECT_ISSUED) != null) { throw new CannotRedirectException( "Cannot issue a redirect(..) here. A previous call to redirect(..) has already redirected the response."); } HttpServletResponse response = webRequest.getCurrentResponse(); if (response.isCommitted()) { throw new CannotRedirectException( "Cannot issue a redirect(..) here. The response has already been committed either by another redirect or by directly writing to the response."); } if (target instanceof GroovyObject) { GroovyObject controller = (GroovyObject) target; // if there are errors add it to the list of errors Errors controllerErrors = (Errors) controller.getProperty(ControllerDynamicMethods.ERRORS_PROPERTY); Errors errors = (Errors) argMap.get(ARGUMENT_ERRORS); if (controllerErrors != null && errors != null) { controllerErrors.addAllErrors(errors); } else { controller.setProperty(ControllerDynamicMethods.ERRORS_PROPERTY, errors); } Object action = argMap.get(GrailsControllerClass.ACTION); if (action != null) { argMap.put(GrailsControllerClass.ACTION, establishActionName(action, controller)); } if (!argMap.containsKey(GrailsControllerClass.NAMESPACE_PROPERTY)) { // this could be made more efficient if we had a reference to the GrailsControllerClass object, which // has the namespace property accessible without needing reflection argMap.put(GrailsControllerClass.NAMESPACE_PROPERTY, GrailsClassUtils .getStaticFieldValue(controller.getClass(), GrailsControllerClass.NAMESPACE_PROPERTY)); } } boolean permanent = DefaultGroovyMethods.asBoolean(argMap.get(ARGUMENT_PERMANENT)); // we generate a relative link with no context path so that the absolute can be calculated by combining the serverBaseURL // which includes the contextPath argMap.put(LinkGenerator.ATTRIBUTE_CONTEXT_PATH, BLANK); return redirectResponse(requestLinkGenerator.getServerBaseURL(), requestLinkGenerator.link(argMap), request, response, permanent); }
From source file:com.ctrip.infosec.rule.resource.hystrix.DataProxyQueryCommand.java
@Override protected Map<String, Object> run() throws Exception { DataProxyRequest request = new DataProxyRequest(); request.setServiceName(serviceName); request.setOperationName(operationName); request.setParams(params);//from w ww .j ava2 s .c o m List<DataProxyRequest> requests = new ArrayList<>(); requests.add(request); DataProxyResponse response = null; if (VENUS.equals(apiMode)) { DataProxyVenusService dataProxyVenusService = SpringContextHolder.getBean(DataProxyVenusService.class); List<DataProxyResponse> responses = dataProxyVenusService.dataproxyQueries(requests); if (responses == null || responses.size() < 1) { return null; } response = responses.get(0); if (response.getRtnCode() != 0) { logger.warn(Contexts.getLogPrefix() + "invoke DataProxy.queryForMap fault. RtnCode=" + response.getRtnCode() + ", RtnMessage=" + response.getMessage()); return null; } } else { String responseTxt = Request.Post(urlPrefix + "/rest/dataproxy/query") .body(new StringEntity(JSON.toJSONString(request), ContentType.APPLICATION_JSON)).execute() .returnContent().asString(); response = JSON.parseObject(responseTxt, DataProxyResponse.class); } if (response != null) { if (response.getRtnCode() == 0) { return response.getResult(); } else { logger.warn(Contexts.getLogPrefix() + "DataProxy. RtnCode=" + response.getRtnCode() + ", RtnMessage=" + response.getMessage()); } } return Collections.EMPTY_MAP; }
From source file:com.haulmont.cuba.core.sys.serialization.KryoSerialization.java
protected Kryo newKryoInstance() { Kryo kryo = new Kryo(); kryo.setInstantiatorStrategy(new CubaInstantiatorStrategy()); if (onlySerializable) { kryo.setDefaultSerializer(CubaFieldSerializer.class); }/* ww w. j a v a2s. c o m*/ //To work properly must itself be loaded by the application classloader (i.e. by classloader capable of loading //all the other application classes). For web application it means placing this class inside webapp folder. kryo.setClassLoader(KryoSerialization.class.getClassLoader()); kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer()); kryo.register(Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer()); kryo.register(Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer()); kryo.register(Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer()); kryo.register(Collections.singletonList("").getClass(), new CollectionsSingletonListSerializer()); kryo.register(Collections.singleton("").getClass(), new CollectionsSingletonSetSerializer()); kryo.register(Collections.singletonMap("", "").getClass(), new CollectionsSingletonMapSerializer()); kryo.register(BitSet.class, new BitSetSerializer()); kryo.register(GregorianCalendar.class, new GregorianCalendarSerializer()); kryo.register(InvocationHandler.class, new JdkProxySerializer()); UnmodifiableCollectionsSerializer.registerSerializers(kryo); SynchronizedCollectionsSerializer.registerSerializers(kryo); kryo.register(CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer()); ImmutableListSerializer.registerSerializers(kryo); ImmutableSetSerializer.registerSerializers(kryo); ImmutableMapSerializer.registerSerializers(kryo); ImmutableMultimapSerializer.registerSerializers(kryo); kryo.register(IndirectList.class, new IndirectContainerSerializer()); kryo.register(IndirectMap.class, new IndirectContainerSerializer()); kryo.register(IndirectSet.class, new IndirectContainerSerializer()); kryo.register(org.eclipse.persistence.indirection.IndirectList.class, new IndirectContainerSerializer()); kryo.register(org.eclipse.persistence.indirection.IndirectMap.class, new IndirectContainerSerializer()); kryo.register(org.eclipse.persistence.indirection.IndirectSet.class, new IndirectContainerSerializer()); //classes with custom serialization methods kryo.register(HashMultimap.class, new CubaJavaSerializer()); kryo.register(ArrayListMultimap.class, new CubaJavaSerializer()); kryo.register(MetaClassImpl.class, new CubaJavaSerializer()); kryo.register(MetaPropertyImpl.class, new CubaJavaSerializer()); kryo.register(UnitOfWorkQueryValueHolder.class, new UnitOfWorkQueryValueHolderSerializer(kryo)); return kryo; }