Refine search
public String determineContentType() { String ct = null; List<Object> ctList = CastUtils.cast(headers.get(Message.CONTENT_TYPE)); if (ctList != null && ctList.size() == 1 && ctList.get(0) != null) { ct = ctList.get(0).toString(); } else { ct = (String)message.get(Message.CONTENT_TYPE); } String enc = (String)message.get(Message.ENCODING); if (null != ct) { if (enc != null && ct.indexOf("charset=") == -1 && !ct.toLowerCase().contains("multipart/related")) { ct = ct + "; charset=" + enc; } } else if (enc != null) { ct = "text/xml; charset=" + enc; } else { ct = "text/xml"; } return ct; }
/** * While extracting the Message.PROTOCOL_HEADERS property from the Message, * this call ensures that the Message.PROTOCOL_HEADERS property is * set on the Message. If it is not set, an empty map is placed there, and * then returned. * * @param message The outbound message * @return The PROTOCOL_HEADERS map */ public static Map<String, List<String>> getSetProtocolHeaders(final Message message) { Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS)); if (null == headers) { headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); } else if (headers instanceof HashMap) { Map<String, List<String>> headers2 = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); headers2.putAll(headers); headers = headers2; } message.put(Message.PROTOCOL_HEADERS, headers); return headers; }
protected Map<String, Object> removeHandlerProperties(WrappedMessageContext ctx) { Map<String, Scope> scopes = CastUtils.cast((Map<?, ?>)ctx.get(WrappedMessageContext.SCOPES)); Map<String, Object> handlerScopedStuff = new HashMap<>(); if (scopes != null) { for (Map.Entry<String, Scope> scope : scopes.entrySet()) { if (scope.getValue() == Scope.HANDLER) { handlerScopedStuff.put(scope.getKey(), ctx.get(scope.getKey())); } } for (String key : handlerScopedStuff.keySet()) { ctx.remove(key); } } return handlerScopedStuff; }
private Object createAttachments(Map<String, Object> mc, String propertyName) { if (mc == null) { return null; } Collection<Attachment> attachments = CastUtils.cast((Collection<?>)mc.get(Message.ATTACHMENTS)); Map<String, DataHandler> dataHandlers; if (attachments instanceof WrappedAttachments) { dataHandlers = ((WrappedAttachments) attachments).getAttachments(); } else { if (attachments == null) { attachments = new ArrayList<>(); mc.put(Message.ATTACHMENTS, attachments); } dataHandlers = AttachmentUtil.getDHMap(attachments); mc.put(propertyName, dataHandlers); scopes.put(propertyName, Scope.APPLICATION); } return dataHandlers; }
String fname = e.nextElement(); String mappedName = HttpHeaderHelper.getHeaderKey(fname); List<String> values = headers.get(mappedName); if (values == null) { values = new ArrayList<>(); headers.put(mappedName, values); if ("Accept".equals(mappedName) && values.size() > 0) { String firstAccept = values.get(0); firstAccept = firstAccept + ", " + val; values.set(0, firstAccept); values.add(val); headers.put(Message.CONTENT_TYPE, Collections.singletonList(req.getContentType())); Map<String, List<Object>> theHeaders = CastUtils.cast(headers); LOG.log(Level.FINE, "Request Headers: " + toString(theHeaders, logSensitiveHeaders()));
public Object[] getHeaders(QName name, JAXBContext context, boolean allRoles) { SOAPMessage msg = getMessage(); SOAPHeader header; try { header = msg.getSOAPPart().getEnvelope().getHeader(); if (header == null || !header.hasChildNodes()) { return new Object[0]; } List<Object> ret = new ArrayList<>(); Iterator<SOAPHeaderElement> it = CastUtils.cast(header.examineAllHeaderElements()); while (it.hasNext()) { SOAPHeaderElement she = it.next(); if ((allRoles || roles.contains(she.getActor())) && name.equals(she.getElementQName())) { ret.add(JAXBUtils.unmarshall(context, she)); } } return ret.toArray(new Object[0]); } catch (SOAPException | JAXBException e) { throw new WebServiceException(e); } }
public Binding[] getCorbaBindings() { List<Binding> result = new ArrayList<>(); Map<QName, Binding> bindings = CastUtils.cast(definition.getBindings()); for (Binding binding : bindings.values()) { List<ExtensibilityElement> extElements = CastUtils.cast(binding.getExtensibilityElements()); for (int i = 0; i < extElements.size(); i++) { ExtensibilityElement el = extElements.get(i); if (el.getElementType().equals(CorbaConstants.NE_CORBA_BINDING)) { result.add(binding); break; } } } return result.toArray(new Binding[0]); }
private void parseImports(Definition def, List<Definition> defList) { List<Import> importList = new ArrayList<Import>(); Collection<List<Import>> ilist = CastUtils.cast(def.getImports().values()); for (List<Import> list : ilist) { importList.addAll(list); } for (Import impt : importList) { if (!defList.contains(impt.getDefinition())) { defList.add(impt.getDefinition()); parseImports(impt.getDefinition(), defList); } } }
public static Collection<Import> getImports(final Definition wsdlDef) { Collection<Import> importList = new ArrayList<Import>(); Map<?, ?> imports = wsdlDef.getImports(); for (Iterator<?> iter = imports.keySet().iterator(); iter.hasNext();) { String uri = (String)iter.next(); List<Import> lst = CastUtils.cast((List<?>)imports.get(uri)); importList.addAll(lst); } return importList; }
String newURL, Message message) throws IOException { Map<String, Integer> visitedURLs = CastUtils.cast((Map<?, ?>)message.get(KEY_VISITED_URLS)); if (visitedURLs == null) { visitedURLs = new HashMap<>(); message.put(KEY_VISITED_URLS, visitedURLs); Integer visitCount = visitedURLs.get(lastURL); if (visitCount == null) { visitCount = 1; visitCount++; visitedURLs.put(lastURL, visitCount); Integer newURLCount = visitedURLs.get(newURL); if (newURL != null && newURLCount != null) {
private Map<String, String> getHeaders(Message message) { Map<String, List<Object>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS)); Map<String, String> result = new HashMap<>(); if (headers == null) { return result; } for (Map.Entry<String, List<Object>> entry : headers.entrySet()) { if (entry.getValue().size() == 1) { Object value = entry.getValue().get(0); if (value != null) { result.put(entry.getKey(), value.toString()); } } else { result.put(entry.getKey(), Arrays.deepToString(entry.getValue().toArray())); } } return result; }
public void handleMessage(Message message) throws Fault { Map<String, List<String>> headers = CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS)); if (headers == null) { headers = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER); message.put(Message.PROTOCOL_HEADERS, headers); } String ct = (String)message.getExchange().get(Endpoint.class).get(HttpHeaderHelper.CONTENT_TYPE); if (ct != null) { List<String> contentType = new ArrayList<String>(); contentType.add(ct); headers.put(HttpHeaderHelper.getHeaderKey(HttpHeaderHelper.CONTENT_TYPE), contentType); message.put(HttpHeaderHelper.CONTENT_TYPE, ct); } }
public static void addMultipartOutFilter(MultipartOutputFilter filter) { Message m = JAXRSUtils.getCurrentMessage(); List<MultipartOutputFilter> outFilters = CastUtils.cast((List<?>)m.get(OUT_FILTERS)); if (outFilters == null) { outFilters = new ArrayList<>(); m.put(OUT_FILTERS, outFilters); } outFilters.add(filter); }
SoapVersion soapVersion = (SoapVersion)message.get(SoapVersion.class.getName()); if (soapVersion != null && soapVersion.getVersion() != 1.1) { if (f instanceof SoapFault) { for (Iterator<QName> it = CastUtils.cast(sf.getFault().getFaultSubcodes()); it.hasNext();) { ((SoapFault) f).addSubCode(it.next()); Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0), message.getExchange().getBus()); writer.setSchema(schema); FaultMode mode = message.get(FaultMode.class); if (mode == FaultMode.CHECKED_APPLICATION_FAULT) {
params = Collections.singletonList(null); res = CastUtils.cast((List<?>)super.invoke(exchange, serviceObject, m, params)); "jaxws.provider.interpretNullAsOneway", true) && (res != null && !res.isEmpty() && res.get(0) == null) && exchange.getInMessage().getInterceptorChain().getState() == InterceptorChain.State.EXECUTING) {
@Override public void handleMessage(Message message) throws Fault { final Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS)); final TraceScopeHolder<TraceScope> holder = super.startTraceSpan(headers, getUri(message), (String)message.get(Message.HTTP_REQUEST_METHOD)); if (holder != null) { message.getExchange().put(TRACE_SPAN, holder); } }