List of usage examples for java.util LinkedHashMap get
public V get(Object key)
From source file:com.primeleaf.krystal.web.view.cpanel.SummaryReportView.java
@SuppressWarnings("unchecked") private void printSummaryReport() throws Exception { printBreadCrumbs();/*from ww w . ja v a 2 s. co m*/ if (request.getAttribute(HTTPConstants.REQUEST_ERROR) != null) { printErrorDismissable((String) request.getAttribute(HTTPConstants.REQUEST_ERROR)); } if (request.getAttribute(HTTPConstants.REQUEST_MESSAGE) != null) { printSuccessDismissable((String) request.getAttribute(HTTPConstants.REQUEST_MESSAGE)); } try { out.println("<div class=\"panel panel-default\">"); out.println( "<div class=\"panel-heading\"><h4><i class=\"fa fa-lg fa-bar-chart-o\"></i> Repository Content Summary</h4></div>"); out.println("<div class=\"panel-body\">"); out.println("<div class=\"row\">"); out.println("<div class=\"col-lg-4\">"); out.println("<div class=\"panel panel-default\">"); out.println("<div class=\"panel-heading\">"); out.println("<div class=\"row\">"); out.println("<div class=\"col-xs-4\">"); out.println("<i class=\"fa fa-folder-open fa-3x\"></i>"); out.println("</div>"); out.println("<div class=\"col-xs-8 text-right\">"); out.println("<h3>" + request.getAttribute("DOCUMENT_CLASSES") + "</h3>"); out.println("<p >Document Classes</p>"); out.println("</div>"); out.println("</div>");//row out.println("</div>");//panel-heading out.println("</div>");//panel out.println("</div>");//col-lg-4 out.println("<div class=\"col-lg-4\">"); out.println("<div class=\"panel panel-default\">"); out.println("<div class=\"panel-heading\">"); out.println("<div class=\"row\">"); out.println("<div class=\"col-xs-6\">"); out.println("<i class=\"fa fa-file fa-3x\"></i>"); out.println("</div>"); out.println("<div class=\"col-xs-6 text-right\">"); out.println("<h3>" + request.getAttribute("DOCUMENTS") + "</h3>"); out.println("<p >Documents</p>"); out.println("</div>"); out.println("</div>");//row out.println("</div>");//panel-heading out.println("</div>");//panel out.println("</div>");//col-lg-4 out.println("<div class=\"col-lg-4\">"); out.println("<div class=\"panel panel-default\">"); out.println("<div class=\"panel-heading\">"); out.println("<div class=\"row\">"); out.println("<div class=\"col-xs-6\">"); out.println("<i class=\"fa fa-user fa-3x\"></i>"); out.println("</div>"); out.println("<div class=\"col-xs-6 text-right\">"); out.println("<h3>" + request.getAttribute("USERS") + "</h3>"); out.println("<p >Users</p>"); out.println("</div>"); out.println("</div>");//row out.println("</div>");//panel-heading out.println("</div>");//panel out.println("</div>");//col-lg-4 out.println("</div>");//row ArrayList<DocumentClass> documentClasses = (ArrayList<DocumentClass>) request .getAttribute("DOCUMENTCLASSLIST"); if (documentClasses.size() > 0) { //charts rendering starts here out.println("<div class=\"panel panel-default\">"); out.println("<div class=\"panel-heading\">"); out.println("<i class=\"fa fa-pie-chart fa-lg\"></i> Charts"); out.println("</div>"); out.println("<div class=\"panel-body\">"); out.println("<div class=\"row\">"); out.println("<div class=\"col-sm-6 text-center\">"); out.println("<h3>Documents : " + request.getAttribute("DOCUMENTS") + "</h3>"); out.println("<div id=\"classchart\" style=\"height:280px;\">"); out.println("<script>"); out.println("new Morris.Donut({"); out.println(" element: 'classchart',"); out.println(" data: ["); for (DocumentClass documentClass : documentClasses) { int documentCount = documentClass.getActiveDocuments(); out.println(" { label: \"" + StringEscapeUtils.escapeHtml4(documentClass.getClassName()) + "\", value: " + documentCount + " },"); } out.println(" ],"); out.println("});"); out.println("</script>"); out.println("</div>"); out.println("</div>");//col-sm-6 double totalSize = (Double) request.getAttribute("TOTALSIZE"); out.println("<div class=\"col-sm-6 text-center\">"); out.println("<h3>Total Size : " + StringHelper.formatSizeText(totalSize) + "</h3>"); out.println("<div id=\"sizechart\" style=\"height:280px;\">"); out.println("<script>"); out.println("new Morris.Donut({"); out.println(" element: 'sizechart',"); out.println(" data: ["); for (DocumentClass documentClass : documentClasses) { double documentSize = (Double) request.getAttribute(documentClass.getClassName() + "_SIZE"); out.println("{ label: \"" + StringEscapeUtils.escapeHtml4(documentClass.getClassName()) + "\", value: " + documentSize + " },"); } out.println(" ], " + " formatter : function (y, data) { " + " var result = '';" + " if(y > 1024) { result = parseFloat(y/1024).toFixed(1)+ ' KB'} " + " if(y > 1048576) { result = parseFloat(y/1048576).toFixed(1)+' MB'} " + " if(y > 1073741824) { result = parseFloat(y/1073741824).toFixed(1)+' GB'} " + "return result } "); out.println("});"); out.println("</script>"); out.println("</div>"); out.println("</div>");//col-sm-6 out.println("</div>");//row if (documentClasses.size() > 0) { out.println("<div class=\"text-center\">"); out.println("<div id=\"linechart\" style=\"height:280px;\">"); out.println("<script>"); out.println("new Morris.Line({"); out.println(" element: 'linechart',"); out.println(" data: ["); LinkedHashMap<String, Integer> chartValues = (LinkedHashMap<String, Integer>) request .getAttribute(documentClasses.get(0).getClassName() + "_CHARTVALUES"); for (String month : chartValues.keySet()) { out.print("{y : '" + month + "'"); for (DocumentClass documentClass : documentClasses) { chartValues = (LinkedHashMap<String, Integer>) request .getAttribute(documentClass.getClassName() + "_CHARTVALUES"); out.print(", c" + documentClass.getClassId() + " : " + chartValues.get(month)); } out.println("},"); } out.println(" ],"); out.println(" xkey: 'y',"); out.print(" ykeys: ["); for (DocumentClass documentClass : documentClasses) { out.print("'c" + documentClass.getClassId() + "',"); } out.println("],"); out.println(" labels: ["); for (DocumentClass documentClass : documentClasses) { out.print("'" + StringEscapeUtils.escapeHtml4(documentClass.getClassName()) + "',"); } out.println("]"); out.println("});"); out.println("</script>"); out.println("</div>");//line-chart out.println("</div>");// } out.println("</div>");//panel-body out.println("</div>");//panel } //charts rendering ends here out.println("<div class=\"panel panel-default\">"); out.println("<div class=\"panel-heading\">"); out.println("<i class=\"fa fa-folder-open fa-lg\"></i> Document Classes"); out.println("</div>"); ArrayList<DocumentClass> documentClassList = (ArrayList<DocumentClass>) request .getAttribute("DOCUMENTCLASSLIST"); if (documentClassList.size() > 0) { out.println("<div class=\"table-responsive\">"); out.println("<table class=\"table table-condensed table-stripped\">"); out.println("<thead><tr>"); out.println("<th>Document Class</th>"); out.println("<th class=\"text-center\">Documents</th>"); out.println("<th class=\"text-right\">Total Size</th></tr></thead>"); out.println("<tbody>"); for (DocumentClass documentClass : documentClassList) { int documentCount = documentClass.getActiveDocuments(); double documentSize = (Double) request.getAttribute(documentClass.getClassName() + "_SIZE"); String ownerName = (String) request.getAttribute(documentClass.getClassName() + "_OWNER"); out.println("<tr>"); out.println("<td style=\"width:80%;\">"); out.println("<h4 class=\"text-danger\">" + StringEscapeUtils.escapeHtml4(documentClass.getClassName()) + "</h4>"); out.println( "<h5>" + StringEscapeUtils.escapeHtml4(documentClass.getClassDescription()) + "</h5>"); out.println("<p>"); out.println("<i>Created By " + ownerName); out.println(" , " + StringHelper.getFriendlyDateTime(documentClass.getCreated()) + "</i>"); out.println("</p>"); out.println("</td>"); out.println("<td style=\"width:10%;\" class=\"text-center\">"); out.println("<h4>" + documentCount + "</h4>"); out.println("</td>"); out.println("<td class=\"text-right\">"); out.println("<h4>" + StringHelper.formatSizeText(documentSize) + "</h4>"); out.println("</td>"); out.println("</tr>");//row } // for out.println("</tbody>"); out.println("</table>"); out.println("</div>"); } else { out.println("<div class=\"panel-body\">"); //panel out.println("No document class found"); out.println("</div>"); //panel-body } out.println("</div>"); //panel out.println("</div>"); out.println("</div>"); out.println("</div>"); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.kerio.dashboard.LicenseTileUpdater.java
private boolean sendRequests() { JSONObject emptyArguments = new JSONObject(); LinkedHashMap<String, JSONObject> requests = new LinkedHashMap<String, JSONObject>(); LinkedHashMap<String, JSONObject> response; JSONObject productInfo = this.client.exec("ProductInfo.get", emptyArguments); requests.put("ProductRegistration.getFullStatus", emptyArguments); requests.put("ProductInfo.getUsedDevicesCount", emptyArguments); requests.put("Antivirus.get", emptyArguments); if (newVersion(productInfo)) { requests.put("ContentFilter.getUrlFilterConfig", emptyArguments); } else {//from ww w .j a v a 2 s . c o m requests.put("HttpPolicy.getUrlFilterConfig", emptyArguments); } requests.put("Antivirus.getUpdateStatus", new JSONObject()); requests.put("IntrusionPrevention.get", new JSONObject()); requests.put("IntrusionPrevention.getUpdateStatus", new JSONObject()); requests.put("ProductInfo.get", new JSONObject()); response = this.client.execBatch(requests); infoResult = response.get("ProductRegistration.getFullStatus"); devices = response.get("ProductInfo.getUsedDevicesCount"); av = response.get("Antivirus.get"); if (newVersion(productInfo)) { webFilter = response.get("ContentFilter.getUrlFilterConfig"); } else { webFilter = response.get("HttpPolicy.getUrlFilterConfig"); } if ((devices == null) || infoResult == null || av == null || webFilter == null) { this.notify("Unable to update"); return false; } else { return true; } }
From source file:org.appcelerator.titanium.analytics.TiAnalyticsService.java
@Override public void onStart(Intent intent, final int startId) { super.onStart(intent, startId); if (!sending.compareAndSet(false, true)) { Log.i(TAG, "Send already in progress, skipping intent"); }/*from w ww.j ava2 s . c o m*/ final TiAnalyticsService self = this; Thread t = new Thread(new Runnable() { public void run() { Log.i(TAG, "Analytics Service Started"); try { if (connectivityManager == null) { Log.w(TAG, "Connectivity manager not available."); stopSelf(startId); return; } TiAnalyticsModel model = new TiAnalyticsModel(self); if (!model.hasEvents()) { Log.d(TAG, "No events to send.", Log.DEBUG_MODE); stopSelf(startId); return; } while (model.hasEvents()) { if (canSend()) { LinkedHashMap<Integer, JSONObject> events = model .getEventsAsJSON(BUCKET_SIZE_FAST_NETWORK); int len = events.size(); int[] eventIds = new int[len]; Iterator<Integer> keys = events.keySet().iterator(); JSONArray records = new JSONArray(); // build up data to send and records to delete on success for (int i = 0; i < len; i++) { int id = keys.next(); // ids are kept even on error JSON to prevent unrestrained growth // and a queue blocked by bad records. eventIds[i] = id; records.put(events.get(id)); if (Log.isDebugModeEnabled()) { JSONObject obj = events.get(id); Log.d(TAG, "Sending event: type = " + obj.getString("type") + ", timestamp = " + obj.getString("ts")); } } boolean deleteEvents = true; if (records.length() > 0) { if (Log.isDebugModeEnabled()) { Log.d(TAG, "Sending " + records.length() + " analytics events."); } try { String jsonData = records.toString() + "\n"; String postUrl = TiApplication.getInstance() == null ? ANALYTICS_URL : ANALYTICS_URL + TiApplication.getInstance().getAppGUID(); HttpPost httpPost = new HttpPost(postUrl); StringEntity entity = new StringEntity(jsonData); entity.setContentType("text/json"); httpPost.setEntity(entity); HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, 5000); //TODO use property //HttpConnectionParams.setSoTimeout(httpParams, 15000); //TODO use property HttpClient client = new DefaultHttpClient(httpParams); ResponseHandler<String> responseHandler = new BasicResponseHandler(); client.getParams().setBooleanParameter("http.protocol.expect-continue", false); @SuppressWarnings("unused") String response = client.execute(httpPost, responseHandler); } catch (Throwable t) { Log.e(TAG, "Error posting events: " + t.getMessage(), t); deleteEvents = false; records = null; break; } } records = null; if (deleteEvents) { model.deleteEvents(eventIds); } events.clear(); } else { Log.w(TAG, "Network unavailable, can't send analytics"); //TODO reset alarm? break; } } Log.i(TAG, "Stopping Analytics Service"); stopSelf(startId); } catch (Throwable t) { Log.e(TAG, "Unhandled exception in analytics thread: ", t); stopSelf(startId); } finally { if (!sending.compareAndSet(true, false)) { Log.w(TAG, "Expected to be in a sending state. Sending was already false.", Log.DEBUG_MODE); } } } }); t.setPriority(Thread.MIN_PRIORITY); t.start(); }
From source file:com.sapito.db.dao.AbstractDao.java
public List<T> findBySpecificField(String field, Object fieldContent, String predicates, LinkedHashMap<String, String> ordering, LinkedList<String> grouping) { CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery cq = cb.createQuery(); Root<T> root = cq.from(entityClass); Predicate predicate = null;/*from www . j av a 2s .c om*/ if (predicates.equals("equal")) { predicate = cb.equal(root.get(field), fieldContent); } else if (predicates.equals("likelower")) { predicate = cb.like(cb.lower(root.<String>get(field)), fieldContent.toString()); } else if (predicates.equals("like")) { predicate = cb.like(root.<String>get(field), "%" + fieldContent.toString() + "%"); } cq.select(root); cq.where(predicate); if (ordering != null) { Set<String> set = ordering.keySet(); List<Order> orders = new ArrayList<>(); for (String orderingField : set) { Order order; if (ordering.get(orderingField).equals("ASC")) { order = cb.asc(root.get(orderingField)); } else { order = cb.desc(root.get(orderingField)); } orders.add(order); } cq.orderBy(orders); } if (grouping != null) { Iterator iterator = grouping.iterator(); List<Expression> groups = new LinkedList<>(); while (iterator.hasNext()) { groups.add(root.get(iterator.next().toString())); } cq.groupBy(groups); } Query query = entityManager.createQuery(cq); query.setMaxResults(MAX_RECORDS_RETURNED); return query.getResultList(); }
From source file:eionet.cr.staging.exp.ExportRunner.java
/** * Adds the predicate value./* w ww . ja va 2 s . com*/ * * @param valuesByPredicate * the values by predicate * @param predicateURI * the predicate uri * @param value * the value */ private void addPredicateValue(LinkedHashMap<URI, ArrayList<Value>> valuesByPredicate, URI predicateURI, Value value) { ArrayList<Value> values = valuesByPredicate.get(predicateURI); if (values == null) { values = new ArrayList<Value>(); valuesByPredicate.put(predicateURI, values); } values.add(value); }
From source file:com.amalto.workbench.dialogs.MenuEntryDialog.java
@Override protected Control createDialogArea(Composite parent) { // Should not really be here but well,.... parent.getShell().setText(this.title); Composite composite = (Composite) super.createDialogArea(parent); GridLayout layout = (GridLayout) composite.getLayout(); layout.numColumns = 3;/*w w w . j a v a 2 s . c o m*/ // layout.verticalSpacing = 10; Label idLabel = new Label(composite, SWT.NONE); idLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); idLabel.setText(Messages.MenuEntryDialog_Id); if (this.isChanged) { idText = new Text(composite, SWT.NONE); } else { idText = new Text(composite, SWT.NONE | SWT.READ_ONLY); } idText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); ((GridData) idText.getLayoutData()).widthHint = 300; idText.setDoubleClickEnabled(false); Label contextLabel = new Label(composite, SWT.NONE); contextLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); contextLabel.setText(Messages.MenuEntryDialog_Context); contextText = new Text(composite, SWT.NONE); contextText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); contextText.setDoubleClickEnabled(false); Label applicationNameLabel = new Label(composite, SWT.NONE); applicationNameLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); applicationNameLabel.setText(Messages.MenuEntryDialog_Application); applicationNameText = new Text(composite, SWT.NONE); applicationNameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); Label iconPathLabel = new Label(composite, SWT.NONE); iconPathLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); iconPathLabel.setText(Messages.MenuEntryDialog_IconPath); iconPathText = new FileSelectWidget(composite, "", new String[] { "*.png", "*.gif", "*.jpg" }, "", true);//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ //$NON-NLS-5$ // Labels descriptionsComposite = new Composite(composite, SWT.BORDER); descriptionsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); descriptionsComposite.setLayout(new GridLayout(3, false)); Label descriptionsLabel = new Label(descriptionsComposite, SWT.NULL); descriptionsLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); descriptionsLabel.setText(Messages.MenuEntryDialog_MenuEntryLabels); languagesCombo = new Combo(descriptionsComposite, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE); languagesCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.NONE, false, false, 1, 1)); Set<String> languages = Util.lang2iso.keySet(); for (Object element : languages) { String language = (String) element; languagesCombo.add(language); } languagesCombo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { } }); languagesCombo.select(0); labelText = new Text(descriptionsComposite, SWT.BORDER | SWT.SINGLE); labelText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); labelText.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { if ((e.stateMask == 0) && (e.character == SWT.CR)) { String isoCode = Util.lang2iso.get(languagesCombo.getText()); descriptionsMap.put(isoCode, labelText.getText()); descriptionsViewer.refresh(); } } }); Button addLabelButton = new Button(descriptionsComposite, SWT.PUSH); addLabelButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1)); addLabelButton.setImage(ImageCache.getCreatedImage(EImage.ADD_OBJ.getPath())); addLabelButton.setToolTipText(Messages.MenuEntryDialog_Add); addLabelButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) { }; public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { String isoCode = Util.lang2iso.get(languagesCombo.getText()); descriptionsMap.put(isoCode, labelText.getText()); descriptionsViewer.refresh(); }; }); final String LANGUAGE = Messages.MenuEntryDialog_Language; final String LABEL = Messages.MenuEntryDialog_Label; descriptionsViewer = new TableViewer(descriptionsComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION); descriptionsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); ((GridData) descriptionsViewer.getControl().getLayoutData()).heightHint = 100; // Set up the underlying table Table table = descriptionsViewer.getTable(); // table.setLayoutData(new GridData(GridData.FILL_BOTH)); new TableColumn(table, SWT.LEFT).setText(LANGUAGE); new TableColumn(table, SWT.CENTER).setText(LABEL); table.getColumn(0).setWidth(150); table.getColumn(1).setWidth(150); for (int i = 2, n = table.getColumnCount(); i < n; i++) { table.getColumn(i).pack(); } table.setHeaderVisible(true); table.setLinesVisible(true); // Create the cell editors --> We actually discard those later: not natural for an user CellEditor[] editors = new CellEditor[2]; editors[0] = new TextCellEditor(table); editors[1] = new TextCellEditor(table); descriptionsViewer.setCellEditors(editors); // set the content provider descriptionsViewer.setContentProvider(new IStructuredContentProvider() { public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public Object[] getElements(Object inputElement) { // System.out.println("getElements() "); LinkedHashMap<String, String> descs = (LinkedHashMap<String, String>) inputElement; Set<String> languages = descs.keySet(); ArrayList<DescriptionLine> lines = new ArrayList<DescriptionLine>(); for (Object element : languages) { String language = (String) element; DescriptionLine line = new DescriptionLine(Util.iso2lang.get(language), descs.get(language)); lines.add(line); } // we return an instance line made of a Sring and a boolean return lines.toArray(new DescriptionLine[lines.size()]); } }); // set the label provider descriptionsViewer.setLabelProvider(new ITableLabelProvider() { public boolean isLabelProperty(Object element, String property) { return false; } public void dispose() { } public void addListener(ILabelProviderListener listener) { } public void removeListener(ILabelProviderListener listener) { } public String getColumnText(Object element, int columnIndex) { // System.out.println("getColumnText() "+columnIndex); DescriptionLine line = (DescriptionLine) element; switch (columnIndex) { case 0: return line.getLanguage(); case 1: return line.getLabel(); } return "";//$NON-NLS-1$ } public Image getColumnImage(Object element, int columnIndex) { return null; } }); // Set the column properties descriptionsViewer.setColumnProperties(new String[] { LANGUAGE, LABEL }); // set the Cell Modifier descriptionsViewer.setCellModifier(new ICellModifier() { public boolean canModify(Object element, String property) { // if (INSTANCE_ACCESS.equals(property)) return true; Deactivated return false; } public void modify(Object element, String property, Object value) { // System.out.println("modify() "+element.getClass().getName()+": "+property+": "+value); // DescriptionLine line = // (DescriptionLine)((IStructuredSelection)instancesViewer.getSelection()).getFirstElement(); // deactivated: editing in places is not natural for users } public Object getValue(Object element, String property) { // System.out.println("getValue() "+property); DescriptionLine line = (DescriptionLine) element; if (LANGUAGE.equals(property)) { return line.getLanguage(); } if (LABEL.equals(property)) { return line.getLabel(); } return null; } }); // Listen for changes in the selection of the viewer to display additional parameters descriptionsViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { } }); // display for Delete Key events to delete an instance descriptionsViewer.getTable().addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { // System.out.println("Table keyReleased() "); if ((e.stateMask == 0) && (e.character == SWT.DEL) && (descriptionsViewer.getSelection() != null)) { DescriptionLine line = (DescriptionLine) ((IStructuredSelection) descriptionsViewer .getSelection()).getFirstElement(); String isoCode = Util.lang2iso.get(line.getLanguage()); LinkedHashMap<String, String> descs = (LinkedHashMap<String, String>) descriptionsViewer .getInput(); descs.remove(isoCode); descriptionsViewer.refresh(); } } }); descriptionsViewer.refresh(); if (wsMenuEntry != null) { idText.setText(wsMenuEntry.getId() == null ? "" : wsMenuEntry.getId());//$NON-NLS-1$ contextText.setText(wsMenuEntry.getContext() == null ? "" : wsMenuEntry.getContext());//$NON-NLS-1$ applicationNameText.setText(wsMenuEntry.getApplication() == null ? "" : wsMenuEntry.getApplication());//$NON-NLS-1$ iconPathText.setFilename(wsMenuEntry.getIcon() == null ? "" : wsMenuEntry.getIcon());//$NON-NLS-1$ descriptionsViewer.setInput(descriptionsMap); } idText.setFocus(); return composite; }
From source file:com.atinternet.tracker.Builder.java
/** * Build the hit// w w w.j a va 2s . c om */ Object[] build() { ArrayList<String> prepareHitsList = new ArrayList<String>(); ArrayList<String> hitsList = new ArrayList<String>(); Integer countSplitHits = 1; int indexError = -1; String queryString = ""; String idClient = ""; String configuration = buildConfiguration(); // Calcul pour connaitre la longueur maximum du hit String oltParameter = Tool.getTimeStamp().execute(); int MAX_LENGTH_AVAILABLE = HIT_MAX_LENGTH - (configuration.length() + oltParameter.length() + MH_PARAMETER_MAX_LENGTH); LinkedHashMap<String, Object[]> dictionary = new LinkedHashMap<String, Object[]>(); if (!TextUtils.isEmpty(configuration)) { dictionary = prepareQuery(); Set<String> keySet = dictionary.keySet(); // Outerloop est un label de rfrence si jamais une boucle doit tre interrompue outerloop: for (String parameterKey : keySet) { Param p = (Param) dictionary.get(parameterKey)[0]; String value = String.valueOf(dictionary.get(parameterKey)[1]); // Rcupration de l'idclient pour viter les redirections if (parameterKey.equals(Hit.HitParam.UserId.stringValue())) { idClient = value; MAX_LENGTH_AVAILABLE -= idClient.length(); } // Si la valeur du paramtre est trop grande if (value.length() > MAX_LENGTH_AVAILABLE) { // Si le paramtre est dcoupable if (Lists.getSliceReadyParams().contains(parameterKey)) { // Rcupration du sparateur, de la cl et la valeur du paramtre courant String separator = p.getOptions() != null ? p.getOptions().getSeparator() : ","; String[] currentParameterString = value.split("="); String currentKey = currentParameterString[0] + "="; String currentValue = currentParameterString[1]; // On dcoupe la valeur du paramtre sur son sparateur String[] valuesList = currentValue.split(separator); for (int i = 0; i < valuesList.length; i++) { String currentSplitValue = valuesList[i]; // Si la valeur courante est trop grande if (currentSplitValue.length() > MAX_LENGTH_AVAILABLE) { // Erreur : Valeur trop longue non dcoupable indexError = countSplitHits; queryString += currentKey; int currentMaxLength = MAX_LENGTH_AVAILABLE - (MHERR_PARAMETER_LENGTH + queryString.length()); // On cherche la position du dernier % afin d'viter les exceptions au moment de la dcoupe brutale String splitError = currentSplitValue.substring(0, currentMaxLength); int lastIndexOfPercent = splitError.lastIndexOf(PERCENT_VALUE); if ((lastIndexOfPercent > currentMaxLength - 5) && (lastIndexOfPercent < currentMaxLength)) { queryString += splitError.substring(0, lastIndexOfPercent); } else { queryString += splitError; } Tool.executeCallback(tracker.getListener(), CallbackType.warning, "Multihits: Param " + parameterKey + " value still too long after slicing"); // On retourne l'endroit du code o se trouve outerloop break outerloop; } // Sinon si le hit dj construit + la valeur courante est trop grand else if (queryString.length() + currentSplitValue.length() > MAX_LENGTH_AVAILABLE) { // On cr un nouveau tronon countSplitHits++; prepareHitsList.add(queryString); queryString = idClient + currentKey + (i == 0 ? currentSplitValue : separator + currentSplitValue); } // Sinon, on continue la construction normalement else { queryString += i == 0 ? currentKey + currentSplitValue : separator + currentSplitValue; } } } else { // Erreur : le paramtre n'est pas dcoupable indexError = countSplitHits; Tool.executeCallback(tracker.getListener(), CallbackType.warning, "Multihits: parameter " + parameterKey + " value not allowed to be sliced"); break; } } // Sinon, si le hit est trop grand, on le dcoupe entre deux paramtres else if (queryString.length() + value.length() > MAX_LENGTH_AVAILABLE) { countSplitHits++; prepareHitsList.add(queryString); queryString = idClient + value; } //Sinon, on ne dcoupe pas else { queryString += value; } } // Si un seul hit est construit if (countSplitHits == 1) { if (indexError == countSplitHits) { hitsList.add(configuration + makeSubQuery("mherr", "1") + queryString); } else { hitsList.add(configuration + queryString); } } // Sinon, si le nombre de tronons > 999, erreur else if (countSplitHits > HIT_MAX_COUNT) { hitsList.add(configuration + makeSubQuery("mherr", "1") + queryString); Tool.executeCallback(tracker.getListener(), CallbackType.warning, "Multihits: too much hit parts"); } // Sinon, on ajoute les hits construits la liste de hits envoyer else { prepareHitsList.add(queryString); String mhID = mhIdSuffixGenerator(); for (int i = 0; i < countSplitHits; i++) { String countSplitHitsString = countSplitHits.toString(); String mhParameter = makeSubQuery("mh", String.format(MH_PARAMETER_FORMAT, Tool.formatNumberLength(Integer.toString(i + 1), countSplitHitsString.length()), countSplitHitsString, mhID)); if (indexError == (i + 1)) { hitsList.add( configuration + mhParameter + makeSubQuery("mherr", "1") + prepareHitsList.get(i)); } else { hitsList.add(configuration + mhParameter + prepareHitsList.get(i)); } } } if (tracker.getListener() != null) { String message = ""; for (String hit : hitsList) { message += hit + "\n"; } Tool.executeCallback(tracker.getListener(), CallbackType.build, message, TrackerListener.HitStatus.Success); } } return new Object[] { hitsList, oltParameter }; }
From source file:com.indeed.imhotep.web.ImhotepMetadataCache.java
private boolean loadMetadataFromFiles(LinkedHashMap<String, DatasetMetadata> newDatasetToAliases) { File ramsesDir = new File(ramsesMetadataPath); if (!ramsesDir.exists() || !ramsesDir.isDirectory()) { log.error("Directory not found at " + ramsesMetadataPath); return false; }//from w w w . ja v a 2s . co m File[] files = ramsesDir.listFiles(); if (files == null) { log.error("Failed to stat directory at " + ramsesMetadataPath); return false; } for (File indexDir : files) { if (!indexDir.isDirectory()) { continue; } final String indexName = indexDir.getName(); final DatasetMetadata datasetMetadata = newDatasetToAliases.get(indexName); if (datasetMetadata == null) { log.trace("Found dimensions data for unknown dataset: " + indexName); continue; } loadDimensions(indexDir, datasetMetadata); loadSuggestions(indexDir, datasetMetadata); } return true; }
From source file:org.openmeetings.app.remote.MainService.java
/** * This Method is jsut for testing you can find the corresponding CLietn * Function in xmlcrm/auth/checkLoginData.lzx * // ww w. java2 s . c o m * @param myObject2 * @return */ public int testObject(Object myObject2) { try { @SuppressWarnings("rawtypes") LinkedHashMap myObject = (LinkedHashMap) myObject2; log.debug("testObject " + myObject.size()); log.debug("testObject " + myObject.get(1)); log.debug("testObject " + myObject.get("stringObj")); return myObject.size(); } catch (Exception e) { log.error("ex: ", e); } return -1; }
From source file:org.esigate.extension.surrogate.Surrogate.java
/** * <ul>//from w w w. j av a 2 s . c om * <li>Inject H_X_ENABLED_CAPABILITIES into response.</li> * <li>Consume capabilities. Does not support targeting yet.</li> * <li>Update caching directives.</li> * </ul> * * @param event * Incoming fetch event. */ private void onPostFetch(Event event) { // Update caching policies FetchEvent e = (FetchEvent) event; String ourSurrogateId = e.getHttpRequest().getFirstHeader(H_X_SURROGATE_ID).getValue(); SurrogateCapabilitiesHeader surrogateCapabilitiesHeader = SurrogateCapabilitiesHeader .fromHeaderValue(e.getHttpRequest().getFirstHeader(H_SURROGATE_CAPABILITIES).getValue()); if (!e.getHttpResponse().containsHeader(H_SURROGATE_CONTROL) && surrogateCapabilitiesHeader.getSurrogates().size() > 1) { // Ensure another proxy can process the request LinkedHashMap<String, List<String>> targetCapabilities = new LinkedHashMap<String, List<String>>(); initSurrogateMap(targetCapabilities, surrogateCapabilitiesHeader); for (String c : this.capabilities) { // Ignore Surrogate/1.0 if ("Surrogate/1.0".equals(c)) { continue; } String firstSurrogate = getFirstSurrogateFor(surrogateCapabilitiesHeader, c); // firstSurrogate cannot be null since we are the last surrogate. targetCapabilities.get(firstSurrogate).add(c); } fixSurrogateMap(targetCapabilities, ourSurrogateId); StringBuilder sb = new StringBuilder(); boolean firstDevice = true; for (String device : targetCapabilities.keySet()) { if (targetCapabilities.get(device).size() == 0) { continue; } if (!firstDevice) { sb.append(", "); } else { firstDevice = false; } sb.append("content=\""); boolean firstCap = true; for (String cap : targetCapabilities.get(device)) { if (!firstCap) { sb.append(" "); } else { firstCap = false; } sb.append(cap); } sb.append("\";"); sb.append(device); } e.getHttpResponse().addHeader(H_SURROGATE_CONTROL, sb.toString()); } if (!e.getHttpResponse().containsHeader(H_SURROGATE_CONTROL)) { return; } // If there is a Surrogate-Control header, add a Vary header to ensure content is not reuse when using a // different set of Surrogates e.getHttpResponse().addHeader("Vary", H_SURROGATE_CAPABILITIES); List<String> enabledCapabilities = new ArrayList<String>(); List<String> remainingCapabilities = new ArrayList<String>(); List<String> newSurrogateControlL = new ArrayList<String>(); List<String> newCacheContent = new ArrayList<String>(); String controlHeader = e.getHttpResponse().getFirstHeader(H_SURROGATE_CONTROL).getValue(); String[] control = split(controlHeader, ","); for (String directiveAndTarget : control) { String directive = strip(directiveAndTarget); // Is directive targeted int targetIndex = directive.lastIndexOf(';'); String target = null; if (targetIndex > 0) { target = directive.substring(targetIndex + 1); directive = directive.substring(0, targetIndex); } if (target != null && !target.equals(ourSurrogateId)) { // If directive is not targeted to current instance. newSurrogateControlL.add(strip(directiveAndTarget)); } else if (directive.startsWith("content=\"")) { // Handle content String[] content = split(directive.substring("content=\"".length(), directive.length() - 1), " "); for (String contentCap : content) { contentCap = strip(contentCap); if (contains(this.capabilities, contentCap)) { enabledCapabilities.add(contentCap); } else { remainingCapabilities.add(contentCap); } } if (remainingCapabilities.size() > 0) { newSurrogateControlL.add("content=\"" + join(remainingCapabilities, " ") + "\""); } } else if (directive.startsWith("max-age=")) { String[] maxAge = split(directive, "+"); newCacheContent.add(maxAge[0]); // Freshness extension if (maxAge.length > 1) { newCacheContent.add("stale-while-revalidate=" + maxAge[1]); newCacheContent.add("stale-if-error=" + maxAge[1]); } newSurrogateControlL.add(directive); } else if (directive.startsWith("no-store")) { newSurrogateControlL.add(directive); newCacheContent.add(directive); } else { newSurrogateControlL.add(directive); } } e.getHttpResponse().setHeader(H_X_ENABLED_CAPABILITIES, join(enabledCapabilities, " ")); e.getHttpResponse().setHeader(H_X_NEXT_SURROGATE_CONTROL, join(newSurrogateControlL, ", ")); // If cache control must be updated. if (newCacheContent.size() > 0) { MoveResponseHeader.moveHeader(e.getHttpResponse(), "Cache-Control", H_X_ORIGINAL_CACHE_CONTROL); e.getHttpResponse().setHeader("Cache-Control", join(newCacheContent, ", ")); } }