List of usage examples for java.lang String compareToIgnoreCase
public int compareToIgnoreCase(String str)
From source file:com.sqewd.open.dal.services.DataServices.java
@Path("/read/{type}") @GET/*w ww .jav a 2 s. c o m*/ @Produces(MediaType.APPLICATION_JSON) public JResponse<DALResponse> read(@Context HttpServletRequest req, @PathParam("type") String type, @DefaultValue("") @QueryParam("q") String query, @DefaultValue("1") @QueryParam("p") String page, @DefaultValue("20") @QueryParam("s") String size, @DefaultValue("off") @QueryParam("d") String debugs) throws Exception { try { Timer timer = new Timer(); log.debug("[ENTITY TYPE:" + type + "]"); int pagec = Integer.parseInt(page); int limit = Integer.parseInt(size); int count = pagec * limit; boolean debug = false; if (debugs.compareToIgnoreCase("on") == 0) debug = true; DataManager dm = DataManager.get(); StructEntityReflect enref = ReflectionUtils.get().getEntityMetadata(type); if (enref == null) throw new Exception("No entity found for type [" + type + "]"); Class<?> typec = Class.forName(enref.Class); List<AbstractEntity> data = dm.read(query, typec, count); DALResponse response = new DALResponse(); String path = "/read/" + typec.getCanonicalName() + "?q=" + query; response.setRequest(path); if (data == null || data.size() <= 0) { response.setState(EnumResponseState.NoData); } else { response.setState(EnumResponseState.Success); int stindex = limit * (pagec - 1); if (stindex > 0) { if (stindex > data.size()) { response.setState(EnumResponseState.NoData); } else { List<AbstractEntity> subdata = data.subList(stindex, data.size()); DALReadResponse rr = new DALReadResponse(); rr.setData(subdata); if (debug) { EntitySchema schema = EntitySchema.loadSchema(typec); rr.setSchema(schema); } response.setData(rr); } } else { DALReadResponse rr = new DALReadResponse(); rr.setData(data); if (debug) { EntitySchema schema = EntitySchema.loadSchema(typec); rr.setSchema(schema); } response.setData(rr); } } response.setTimetaken(timer.stop()); return JResponse.ok(response).build(); } catch (Exception e) { LogUtils.stacktrace(log, e); log.error(e.getLocalizedMessage()); DALResponse response = new DALResponse(); response.setState(EnumResponseState.Exception); response.setMessage(e.getLocalizedMessage()); return JResponse.ok(response).build(); } }
From source file:org.wso2.carbon.operation.mgt.OperationAdmin.java
/** * return all parameters for this operation (including inherited ones), * where each parameter is an XML fragment representing the "parameter" element * * @param serviceId//from w w w . j ava 2 s .c o m * @param operationId * @return operation params * @throws AxisFault */ public String[] getOperationParameters(String serviceId, String operationId) throws AxisFault { AxisService axisService = getAxisConfig().getServiceForActivation(serviceId); AxisOperation op = axisService.getOperation(new QName(operationId)); if (op == null) { throw new AxisFault("Invalid operation : " + operationId + " not available in service : " + serviceId); } ArrayList<String> allParameters = new ArrayList<String>(); ArrayList globalParameters = getAxisConfig().getParameters(); for (Object globalParameter : globalParameters) { Parameter parameter = (Parameter) globalParameter; allParameters.add(parameter.getParameterElement().toString()); } AxisService service = getAxisConfig().getServiceForActivation(serviceId); if (service == null) { throw new AxisFault("invalid service name"); } ArrayList serviceParams = service.getParameters(); for (Object serviceParam : serviceParams) { Parameter parameter = (Parameter) serviceParam; allParameters.add(parameter.getParameterElement().toString()); } AxisServiceGroup axisServiceGroup = (AxisServiceGroup) service.getParent(); ArrayList serviceGroupParams = axisServiceGroup.getParameters(); for (Object serviceGroupParam : serviceGroupParams) { Parameter parameter = (Parameter) serviceGroupParam; allParameters.add(parameter.getParameterElement().toString()); } ArrayList opParams = op.getParameters(); for (Object opParam : opParams) { Parameter parameter = (Parameter) opParam; allParameters.add(parameter.getParameterElement().toString()); } Collections.sort(allParameters, new Comparator<String>() { public int compare(String arg0, String arg1) { return arg0.compareToIgnoreCase(arg1); } }); return allParameters.toArray(new String[allParameters.size()]); }
From source file:com.adamkruger.myipaddressinfo.NetworkInfoFragment.java
private void refreshView() { Context context = getActivity(); mNetworkInfoTableLayout.removeAllViewsInLayout(); if (mNetworkInfo != null) { String state = mNetworkInfo.getState().toString(); String detailedState = mNetworkInfo.getDetailedState().toString(); String reason = mNetworkInfo.getReason(); if (detailedState.compareToIgnoreCase(state) == 0) { detailedState = ""; }//from w ww .j a va2 s. c o m if (reason == null || reason.compareToIgnoreCase(state) == 0 || reason.compareToIgnoreCase(detailedState) == 0) { reason = ""; } addTableRowTitle(context.getString(R.string.network_info_subtitle_active_network)); addTableRow(new Row().addLine(mNetworkInfo.getTypeName(), state) .addLine(mNetworkInfo.getSubtypeName(), mNetworkInfo.getExtraInfo()) .addLine(reason, detailedState)); } if (mWifiEnabled) { if (mWifiInfo != null) { String wifiSSID = mWifiInfo.getSSID(); if (wifiSSID != null && wifiSSID.length() > 0) { addTableRowSpacer(); addTableRowTitle(context.getString(R.string.network_info_subtitle_wifi_info)); addTableRow(new Row() .addLine(wifiSSID, mWifiInfo.getLinkSpeed() + WifiInfo.LINK_SPEED_UNITS + " (" + calculateSignalLevel(mWifiInfo.getRssi(), 100) + "%)") .addLine(mWifiInfo.getHiddenSSID() ? context.getString(R.string.network_info_hidden_network) : "", "")); } } if (mDhcpInfo != null) { String dhcpIPAddress = intToHostAddress(mDhcpInfo.ipAddress); if (dhcpIPAddress.length() > 0) { addTableRowSpacer(); addTableRowTitle(context.getString(R.string.network_info_subtitle_dhcp_info)); addTableRow(new Row() .addLineIfValue(context.getString(R.string.network_info_label_ip_address), dhcpIPAddress) .addLineIfValue(context.getString(R.string.network_info_label_gateway), intToHostAddress(mDhcpInfo.gateway)) // TODO: netmask conversion doesn't work .addLineIfValue(context.getString(R.string.network_info_label_netmask), intToHostAddress(mDhcpInfo.netmask)) .addLineIfValue(context.getString(R.string.network_info_label_dns), intToHostAddress(mDhcpInfo.dns1)) .addLineIfValue(context.getString(R.string.network_info_label_dns), intToHostAddress(mDhcpInfo.dns2)) .addLineIfValue(context.getString(R.string.network_info_label_dhcp_server), intToHostAddress(mDhcpInfo.serverAddress)) .addLineIfValue(context.getString(R.string.network_info_label_lease_duration), Integer.toString(mDhcpInfo.leaseDuration))); } } } if (mDNSes.size() > 0) { addTableRowSpacer(); addTableRowTitle(context.getString(R.string.network_info_subtitle_active_dns)); Row row = new Row(); for (String DNS : mDNSes) { row.addLine(context.getString(R.string.network_info_label_dns), DNS); } addTableRow(row); } if (mNetworkInterfaceInfos.size() > 0) { addTableRowSpacer(); addTableRowTitle(context.getString(R.string.network_info_subtitle_interfaces)); for (NetworkInterfaceInfo networkInterfaceInfo : mNetworkInterfaceInfos) { String valueColumn = ""; for (String ipAddress : networkInterfaceInfo.ipAddresses) { valueColumn += ipAddress + "\n"; } if (networkInterfaceInfo.MAC.length() > 0) { valueColumn += networkInterfaceInfo.MAC + "\n"; } if (networkInterfaceInfo.MTU != -1) { valueColumn += String.format("%s: %d", context.getString(R.string.network_info_label_mtu), networkInterfaceInfo.MTU); } addTableRow(new Row().addLine(networkInterfaceInfo.name, valueColumn)); } } addTableRowSpacer(); }
From source file:com.swordlord.gozer.databinding.DataBindingManager.java
/** * TODO need to merge with getResolvedRow(LinkedList<DataBindingElement> * elements, String strTableName, DataRowBase rowFather). Today there is too * many risk. We need a better Parser and a lot of JUnit Tests. * /*ww w .jav a 2 s .co m*/ * @param elements * @param strTableName * @param rowFather * @return */ public DataRowBase[] getResolvedRows(LinkedList<DataBindingElement> elements, String strTableName, DataRowBase rowFather) { if ((elements == null) || (elements.size() == 0)) { LOG.error("elements is empty"); } ArrayList<DataRowBase> dataRowBaseLst = new ArrayList<DataRowBase>(); boolean rowFound = false; for (DataBindingElement element : elements) { if (!element.isField()) { String strPathElement = element.getPathElement(); // ignore the same level if (strPathElement.compareToIgnoreCase(strTableName) != 0) { Object property = rowFather.getProperty(strPathElement); if (property == null) { return new DataRowBase[0]; } else { if (property instanceof DataRowBase) { rowFather = (DataRowBase) property; rowFound = true; } else if (property instanceof ToManyList) { ToManyList list = (ToManyList) property; if (list.size() > 0) { if (elements.get(elements.size() - 2).equals(element)) { // Last element without field name if (list.getValueDirectly() == null) { try { rowFather = (DataRowBase) list.get(element.getRowNumber()); rowFound = true; } catch (Exception e) { e.printStackTrace(); return new DataRowBase[0]; } dataRowBaseLst.add(rowFather); return dataRowBaseLst.toArray(new DataRowBase[dataRowBaseLst.size()]); } else { List<DataRowBase> lst = (List) list.getValueDirectly(); return lst.toArray(new DataRowBase[lst.size()]); } } else { rowFather = (DataRowBase) list.get(element.getRowNumber()); rowFound = true; } } } } // this is some nice side effect where we just loop as long // as we // are not at the right level } } } if (rowFound) { dataRowBaseLst.add(rowFather); return dataRowBaseLst.toArray(new DataRowBase[dataRowBaseLst.size()]); } else { return new DataRowBase[0]; } }
From source file:net.vivekiyer.GAL.ActiveSyncManager.java
/** * @param entity The entity to decode/*from w w w.j ava2 s . c o m*/ * @return The decoded WBXML or text/HTML entity * * Decodes the entity that is returned from the Exchange server * @throws Exception * @throws */ private String decodeContent(HttpEntity entity) throws Exception { String result = ""; if (entity != null) { java.io.ByteArrayOutputStream output = new java.io.ByteArrayOutputStream(); // Parse all the entities String contentType = entity.getContentType().getValue(); // WBXML entities if (contentType.compareToIgnoreCase("application/vnd.ms-sync.wbxml") == 0) { InputStream is = entity.getContent(); wbxml.convertWbxmlToXml(is, output); result = output.toString(); } // Text / HTML entities else if (contentType.compareToIgnoreCase("text/html") == 0) { result = EntityUtils.toString(entity); } } //Log.d(TAG, (result.toString())); return result; }
From source file:org.opendatakit.aggregate.servlet.SubmissionServlet.java
/** * Handler for HTTP post request that processes a form submission Currently * supports plain/xml and multipart/*from www.j a v a2 s.c o m*/ * * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ @Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { CallingContext cc = ContextFactory.getCallingContext(this, req); Double openRosaVersion = getOpenRosaVersion(req); boolean isIncomplete = false; try { SubmissionParser submissionParser = null; if (ServletFileUpload.isMultipartContent(req)) { MultiPartFormData uploadedSubmissionItems = new MultiPartFormData(req); String isIncompleteFlag = uploadedSubmissionItems .getSimpleFormField(ServletConsts.TRANSFER_IS_INCOMPLETE); isIncomplete = (isIncompleteFlag != null && isIncompleteFlag.compareToIgnoreCase("YES") == 0); submissionParser = new SubmissionParser(uploadedSubmissionItems, isIncomplete, cc); } else { // TODO: check that it is the proper types we can deal with // XML received, we hope... submissionParser = new SubmissionParser(req.getInputStream(), cc); } IForm form = submissionParser.getForm(); // Only trigger uploads if this submission was not already // marked as complete before this interaction and if it is // now complete. AND... // Issue a publish request only if we haven't issued one recently. // use BackendActionsTable to mediate that decision. // This test ONLY OCCURS during submissions, not during Watchdog // firings, so we don't have to worry about bugs here affecting Watchdog. if (!submissionParser.wasPreexistingComplete() && submissionParser.getSubmission().isComplete() && BackendActionsTable.triggerPublisher(form.getUri(), cc)) { // send information to remote servers that need to be notified List<ExternalService> tmp = FormServiceCursor.getExternalServicesForForm(form, cc); UploadSubmissions uploadTask = (UploadSubmissions) cc.getBean(BeanDefs.UPLOAD_TASK_BEAN); // publication failures should not fail the submission... try { CallingContext ccDaemon = ContextFactory.getCallingContext(this, req); ccDaemon.setAsDaemon(true); for (ExternalService rs : tmp) { // only create upload tasks for active publishers if (rs.getFormServiceCursor().getOperationalStatus() == OperationalStatus.ACTIVE) { uploadTask.createFormUploadTask(rs.getFormServiceCursor(), false, ccDaemon); } } } catch (ODKExternalServiceException e) { logger.info("Publishing enqueue failure (this is recoverable) - " + e.getMessage()); e.printStackTrace(); } } // form full url including scheme... String serverUrl = cc.getServerURL(); String url = serverUrl + BasicConsts.FORWARDSLASH + ADDR; resp.setHeader("Location", url); resp.setStatus(HttpServletResponse.SC_CREATED); if (openRosaVersion == null) { logger.info("Successful non-OpenRosa submission"); resp.setContentType(HtmlConsts.RESP_TYPE_HTML); resp.setCharacterEncoding(HtmlConsts.UTF8_ENCODE); PrintWriter out = resp.getWriter(); out.write(HtmlConsts.HTML_OPEN); out.write(HtmlConsts.BODY_OPEN); out.write("Successful submission upload. Click "); out.write(HtmlUtil.createHref(cc.getWebApplicationURL(ADDR), "here", false)); out.write(" to return to upload submissions page."); out.write(HtmlConsts.BODY_CLOSE); out.write(HtmlConsts.HTML_CLOSE); } else { logger.info("Successful OpenRosa submission"); addOpenRosaHeaders(resp); resp.setContentType(HtmlConsts.RESP_TYPE_XML); resp.setCharacterEncoding(HtmlConsts.UTF8_ENCODE); PrintWriter out = resp.getWriter(); out.write("<OpenRosaResponse xmlns=\"http://openrosa.org/http/response\">"); if (isIncomplete) { out.write("<message>partial submission upload was successful!</message>"); } else { out.write("<message>full submission upload was successful!</message>"); } // for Briefcase2, use the attributes on a <submissionMetadata> tag to // update the local copy of the data (if these attributes are // available). { XmlAttributeFormatter attributeFormatter = new XmlAttributeFormatter(); Submission sub = submissionParser.getSubmission(); Row attributeRow = new Row(sub.constructSubmissionKey(null)); // // add what could be considered the form's metadata... // attributeRow.addFormattedValue("id=\"" + StringEscapeUtils.escapeXml10(form.getFormId() .replace(ParserConsts.FORWARD_SLASH_SUBSTITUTION, ParserConsts.FORWARD_SLASH)) + "\""); if (form.isEncryptedForm()) { attributeRow.addFormattedValue("encrypted=\"yes\""); } sub.getFormattedNamespaceValuesForRow(attributeRow, Collections.singletonList(FormElementNamespace.METADATA), attributeFormatter, false, cc); out.write("<submissionMetadata xmlns=\"" + StringEscapeUtils.escapeXml10(ParserConsts.NAMESPACE_ODK) + "\""); Iterator<String> itrAttributes = attributeRow.getFormattedValues().iterator(); while (itrAttributes.hasNext()) { out.write(" "); out.write(itrAttributes.next()); } out.write("/>"); } out.write("</OpenRosaResponse>"); } } catch (ODKFormNotFoundException e) { e.printStackTrace(); logger.warn("Form not found - " + e.getMessage()); odkIdNotFoundError(resp); } catch (ODKParseException e) { logger.warn("Parsing failure - " + e.getMessage()); e.printStackTrace(); resp.sendError(HttpServletResponse.SC_BAD_REQUEST, ErrorConsts.PARSING_PROBLEM); } catch (ODKEntityPersistException e) { logger.error("Persist failure - " + e.getMessage()); e.printStackTrace(); resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ErrorConsts.PARSING_PROBLEM); } catch (ODKIncompleteSubmissionData e) { logger.warn("Incomplete submission failure - " + e.getMessage()); e.printStackTrace(); resp.sendError(HttpServletResponse.SC_BAD_REQUEST, ErrorConsts.PARSING_PROBLEM); } catch (ODKConversionException e) { logger.warn("Datatype casting failure - " + e.getMessage()); e.printStackTrace(); resp.sendError(HttpServletResponse.SC_BAD_REQUEST, ErrorConsts.PARSING_PROBLEM); } catch (ODKDatastoreException e) { logger.error("Datastore failure - " + e.getMessage()); e.printStackTrace(); resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ErrorConsts.PARSING_PROBLEM); } catch (FileUploadException e) { logger.warn("Attachments parsing failure - " + e.getMessage()); e.printStackTrace(); resp.sendError(HttpServletResponse.SC_BAD_REQUEST, ErrorConsts.PARSING_PROBLEM); } catch (ODKFormSubmissionsDisabledException e) { logger.warn("Form submission disabled - " + e.getMessage()); e.printStackTrace(); resp.sendError(HttpServletResponse.SC_BAD_REQUEST, ErrorConsts.FORM_DOES_NOT_ALLOW_SUBMISSIONS); } catch (Exception e) { logger.error("Unexpected exception: " + e.getMessage()); e.printStackTrace(); resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unexpected exception"); } }
From source file:org.h2gis.drivers.osm.OSMParser.java
@Override public void endElement(String uri, String localName, String qName) throws SAXException { if (localName.compareToIgnoreCase("node") == 0) { tagLocation = TAG_LOCATION.OTHER; try {// www . j ava 2 s .c om nodePreparedStmt.setObject(1, nodeOSMElement.getID()); nodePreparedStmt.setObject(2, nodeOSMElement.getPoint(gf)); nodePreparedStmt.setObject(3, nodeOSMElement.getElevation()); nodePreparedStmt.setObject(4, nodeOSMElement.getUser()); nodePreparedStmt.setObject(5, nodeOSMElement.getUID()); nodePreparedStmt.setObject(6, nodeOSMElement.getVisible()); nodePreparedStmt.setObject(7, nodeOSMElement.getVersion()); nodePreparedStmt.setObject(8, nodeOSMElement.getChangeSet()); nodePreparedStmt.setObject(9, nodeOSMElement.getTimeStamp(), Types.DATE); nodePreparedStmt.setString(10, nodeOSMElement.getName()); nodePreparedStmt.addBatch(); nodePreparedStmtBatchSize++; HashMap<String, String> tags = nodeOSMElement.getTags(); for (Map.Entry<String, String> entry : tags.entrySet()) { nodeTagPreparedStmt.setObject(1, nodeOSMElement.getID()); nodeTagPreparedStmt.setObject(2, entry.getKey()); nodeTagPreparedStmt.setObject(3, entry.getValue()); nodeTagPreparedStmt.addBatch(); nodeTagPreparedStmtBatchSize++; } } catch (SQLException ex) { throw new SAXException("Cannot insert the node : " + nodeOSMElement.getID(), ex); } } else if (localName.compareToIgnoreCase("way") == 0) { tagLocation = TAG_LOCATION.OTHER; try { wayPreparedStmt.setObject(1, wayOSMElement.getID()); wayPreparedStmt.setObject(2, wayOSMElement.getUser()); wayPreparedStmt.setObject(3, wayOSMElement.getUID()); wayPreparedStmt.setObject(4, wayOSMElement.getVisible()); wayPreparedStmt.setObject(5, wayOSMElement.getVersion()); wayPreparedStmt.setObject(6, wayOSMElement.getChangeSet()); wayPreparedStmt.setTimestamp(7, wayOSMElement.getTimeStamp()); wayPreparedStmt.setString(8, wayOSMElement.getName()); wayPreparedStmt.addBatch(); wayPreparedStmtBatchSize++; HashMap<String, String> tags = wayOSMElement.getTags(); for (Map.Entry<String, String> entry : tags.entrySet()) { wayTagPreparedStmt.setObject(1, wayOSMElement.getID()); wayTagPreparedStmt.setObject(2, entry.getKey()); wayTagPreparedStmt.setObject(3, entry.getValue()); wayTagPreparedStmt.addBatch(); wayTagPreparedStmtBatchSize++; } int order = 1; for (long ref : wayOSMElement.getNodesRef()) { wayNodePreparedStmt.setObject(1, wayOSMElement.getID()); wayNodePreparedStmt.setObject(2, ref); wayNodePreparedStmt.setObject(3, order++); wayNodePreparedStmt.addBatch(); wayNodePreparedStmtBatchSize++; } } catch (SQLException ex) { throw new SAXException("Cannot insert the way : " + wayOSMElement.getID(), ex); } } else if (localName.compareToIgnoreCase("relation") == 0) { tagLocation = TAG_LOCATION.OTHER; try { relationPreparedStmt.setObject(1, relationOSMElement.getID()); relationPreparedStmt.setObject(2, relationOSMElement.getUser()); relationPreparedStmt.setObject(3, relationOSMElement.getUID()); relationPreparedStmt.setObject(4, relationOSMElement.getVisible()); relationPreparedStmt.setObject(5, relationOSMElement.getVersion()); relationPreparedStmt.setObject(6, relationOSMElement.getChangeSet()); relationPreparedStmt.setTimestamp(7, relationOSMElement.getTimeStamp()); relationPreparedStmt.addBatch(); relationPreparedStmtBatchSize++; HashMap<String, String> tags = relationOSMElement.getTags(); for (Map.Entry<String, String> entry : tags.entrySet()) { relationTagPreparedStmt.setObject(1, relationOSMElement.getID()); relationTagPreparedStmt.setObject(2, entry.getKey()); relationTagPreparedStmt.setObject(3, entry.getValue()); relationTagPreparedStmt.addBatch(); relationTagPreparedStmtBatchSize++; } idMemberOrder = 0; } catch (SQLException ex) { throw new SAXException("Cannot insert the relation : " + relationOSMElement.getID(), ex); } } else if (localName.compareToIgnoreCase("member") == 0) { idMemberOrder++; } try { insertBatch(); } catch (SQLException ex) { throw new SAXException("Could not insert sql batch", ex); } if (nodeCountProgress++ % readFileSizeEachNode == 0) { // Update Progress try { progress.setStep((int) (((double) fc.position() / fileSize) * 100)); } catch (IOException ex) { // Ignore } } }
From source file:org.nuxeo.runtime.osgi.OSGiRuntimeService.java
@Override public void reloadProperties() throws IOException { File dir = Environment.getDefault().getConfig(); String[] names = dir.list();//from ww w. j a va 2 s. c o m if (names != null) { Arrays.sort(names, new Comparator<String>() { @Override public int compare(String o1, String o2) { return o1.compareToIgnoreCase(o2); } }); CryptoProperties props = new CryptoProperties(System.getProperties()); for (String name : names) { if (name.endsWith(".config") || name.endsWith(".ini") || name.endsWith(".properties")) { FileInputStream in = new FileInputStream(new File(dir, name)); try { props.load(in); } finally { in.close(); } } } // replace the current runtime properties properties = props; } }
From source file:org.apache.synapse.transport.nhttp.ServerWorker.java
/** * Create an Axis2 message context for the given http request. The request may be in the * process of being streamed//from www . j a v a2s . c om * @param request the http request to be used to create the corresponding Axis2 message context * @return the Axis2 message context created */ private MessageContext createMessageContext(HttpRequest request) { MessageContext msgContext = new MessageContext(); msgContext.setMessageID(UIDGenerator.generateURNString()); // There is a discrepency in what I thought, Axis2 spawns a new threads to // send a message if this is TRUE - and I want it to be the other way msgContext.setProperty(MessageContext.CLIENT_API_NON_BLOCKING, Boolean.FALSE); msgContext.setConfigurationContext(cfgCtx); if ("https".equalsIgnoreCase(schemeName)) { msgContext.setTransportOut(cfgCtx.getAxisConfiguration().getTransportOut(Constants.TRANSPORT_HTTPS)); msgContext.setTransportIn(cfgCtx.getAxisConfiguration().getTransportIn(Constants.TRANSPORT_HTTPS)); msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTPS); SSLIOSession session = (SSLIOSession) (conn.getContext()).getAttribute(SSLIOSession.SESSION_KEY); //set SSL certificates to message context if SSLVerifyClient parameter is set if (session != null && msgContext.getTransportIn() != null && msgContext.getTransportIn().getParameter(NhttpConstants.SSL_VERIFY_CLIENT) != null) { try { msgContext.setProperty(NhttpConstants.SSL_CLIENT_AUTH_CERT_X509, session.getSSLSession().getPeerCertificateChain()); } catch (SSLPeerUnverifiedException e) { //Peer Certificate Chain may not be available always.(in case of verify client is optional) if (log.isTraceEnabled()) { log.trace("Peer certificate chain is not available for MsgContext " + msgContext.getMessageID()); } } } } else { msgContext.setTransportOut(cfgCtx.getAxisConfiguration().getTransportOut(Constants.TRANSPORT_HTTP)); msgContext.setTransportIn(cfgCtx.getAxisConfiguration().getTransportIn(Constants.TRANSPORT_HTTP)); msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP); } msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, this); // the following statement causes the soap session services to be failing - ruwan // msgContext.setServiceGroupContextId(UUIDGenerator.getUUID()); msgContext.setServerSide(true); msgContext.setProperty(Constants.Configuration.TRANSPORT_IN_URL, request.getRequestLine().getUri()); // http transport header names are case insensitive Map<String, String> headers = new TreeMap<String, String>(new Comparator<String>() { public int compare(String o1, String o2) { return o1.compareToIgnoreCase(o2); } }); for (Header header : request.getAllHeaders()) { String headerName = header.getName(); // if this header is already added if (headers.containsKey(headerName)) { /* this is a multi-value header */ // generate the key String key = NhttpConstants.EXCESS_TRANSPORT_HEADERS; // get the old value String oldValue = headers.get(headerName); // adds additional values to a list in a property of message context Map map; if (msgContext.getProperty(key) != null) { map = (Map) msgContext.getProperty(key); map.put(headerName, oldValue); } else { map = new MultiValueMap(); map.put(headerName, oldValue); // set as a property in message context msgContext.setProperty(key, map); } } headers.put(header.getName(), header.getValue()); } msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, headers); // find the remote party IP address and set it to the message context if (conn instanceof HttpInetConnection) { HttpContext httpContext = conn.getContext(); HttpInetConnection inetConn = (HttpInetConnection) conn; InetAddress remoteAddr = inetConn.getRemoteAddress(); if (remoteAddr != null) { httpContext.setAttribute(NhttpConstants.CLIENT_REMOTE_ADDR, remoteAddr); httpContext.setAttribute(NhttpConstants.CLIENT_REMOTE_PORT, inetConn.getRemotePort()); msgContext.setProperty(MessageContext.REMOTE_ADDR, remoteAddr.getHostAddress()); msgContext.setProperty(NhttpConstants.REMOTE_HOST, NhttpUtil.getHostName(remoteAddr)); remoteAddress = remoteAddr.getHostAddress(); } } msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL, new HttpCoreRequestResponseTransport(msgContext)); msgContext.setProperty(ServerHandler.SERVER_CONNECTION_DEBUG, conn.getContext().getAttribute(ServerHandler.SERVER_CONNECTION_DEBUG)); msgContext.setProperty(NhttpConstants.NHTTP_INPUT_STREAM, is); msgContext.setProperty(NhttpConstants.NHTTP_OUTPUT_STREAM, os); return msgContext; }
From source file:org.sakaiproject.portal.charon.site.MoreSiteViewImpl.java
protected void processMySites() { List<Site> allSites = new ArrayList<Site>(); allSites.addAll(mySites);/*from ww w .j a va 2s . c om*/ allSites.addAll(moreSites); // get Sections Map<String, List> termsToSites = new HashMap<String, List>(); Map<String, List> tabsMoreTerms = new TreeMap<String, List>(); for (int i = 0; i < allSites.size(); i++) { Site site = allSites.get(i); ResourceProperties siteProperties = site.getProperties(); String type = site.getType(); String term = null; if (isCourseType(type)) { term = siteProperties.getProperty("term"); if (null == term) { term = rb.getString("moresite_unknown_term"); } } else if (isProjectType(type)) { term = rb.getString("moresite_projects"); } else if ("portfolio".equals(type)) { term = rb.getString("moresite_portfolios"); } else if ("admin".equals(type)) { term = rb.getString("moresite_administration"); } else { term = rb.getString("moresite_other"); } List<Site> currentList = new ArrayList(); if (termsToSites.containsKey(term)) { currentList = termsToSites.get(term); termsToSites.remove(term); } currentList.add(site); termsToSites.put(term, currentList); } class TitleSorter implements Comparator<Map> { public int compare(Map first, Map second) { if (first == null || second == null) return 0; String firstTitle = (String) first.get("siteTitle"); String secondTitle = (String) second.get("siteTitle"); if (firstTitle != null) return firstTitle.compareToIgnoreCase(secondTitle); return 0; } } Comparator<Map> titleSorter = new TitleSorter(); // now loop through each section and convert the Lists to maps for (Map.Entry<String, List> entry : termsToSites.entrySet()) { List<Site> currentList = entry.getValue(); List<Map> temp = siteHelper.convertSitesToMaps(request, currentList, prefix, currentSiteId, myWorkspaceSiteId, /* includeSummary */false, /* expandSite */false, /* resetTools */"true" .equalsIgnoreCase(serverConfigurationService.getString(Portal.CONFIG_AUTO_RESET)), /* doPages */true, /* toolContextPath */null, loggedIn); Collections.sort(temp, titleSorter); tabsMoreTerms.put(entry.getKey(), temp); } String[] termOrder = serverConfigurationService.getStrings("portal.term.order"); List<String> tabsMoreSortedTermList = new ArrayList<String>(); // Order term column headers according to order specified in // portal.term.order // Filter out terms for which user is not a member of any sites // SAK-19464 - Set tab order // Property portal.term.order // Course sites (sorted in order by getAcademicSessions START_DATE ASC) // Rest of terms in alphabetic order if (termOrder != null) { for (int i = 0; i < termOrder.length; i++) { if (tabsMoreTerms.containsKey(termOrder[i])) { tabsMoreSortedTermList.add(termOrder[i]); } } } if (courseManagementService != null) { Collection<AcademicSession> sessions = courseManagementService.getAcademicSessions(); for (AcademicSession s : sessions) { String title = s.getTitle(); if (tabsMoreTerms.containsKey(title)) { if (!tabsMoreSortedTermList.contains(title)) { tabsMoreSortedTermList.add(title); } } } } Iterator i = tabsMoreTerms.keySet().iterator(); while (i.hasNext()) { String term = (String) i.next(); if (!tabsMoreSortedTermList.contains(term)) { tabsMoreSortedTermList.add(term); } } renderContextMap.put("tabsMoreTerms", tabsMoreTerms); renderContextMap.put("tabsMoreSortedTermList", tabsMoreSortedTermList); }