List of usage examples for java.util Hashtable get
@SuppressWarnings("unchecked") public synchronized V get(Object key)
From source file:edu.ku.brc.specify.utilapps.RegisterApp.java
/** * @return//from w ww .j a va 2 s . c o m */ private JPanel getStatsPane(final String chartPrefixTitle, final Collection<RegProcEntry> entries, final String tableName) { CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "f:p:g")); final Hashtable<String, String> keyDescPairsHash = rp.getAllDescPairsHash(); final Hashtable<String, String> desc2KeyPairsHash = new Hashtable<String, String>(); for (String key : keyDescPairsHash.keySet()) { desc2KeyPairsHash.put(keyDescPairsHash.get(key), key); } Vector<String> keywords = new Vector<String>(); for (String keyword : getKeyWordsList(entries)) { if (keyword.endsWith("_name") || keyword.endsWith("_type") || keyword.endsWith("ISA_Number") || keyword.endsWith("reg_isa")) { //keywords.add(keyword); } else { String desc = keyDescPairsHash.get(keyword); //System.out.println("["+keyword+"]->["+desc+"]"); if (desc != null) { keywords.add(desc); } else { System.out.println("Desc for keyword[" + keyword + "] is null."); } } } Vector<Object[]> rvList = BasicSQLUtils .query("SELECT DISTINCT(Name) FROM registeritem WHERE SUBSTRING(Name, 1, 4) = 'num_'"); for (Object[] array : rvList) { keywords.add((String) array[0]); } Collections.sort(keywords); final JList list = new JList(keywords); pb.add(UIHelper.createScrollPane(list), cc.xy(1, 1)); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { String statName = (String) list.getSelectedValue(); if (desc2KeyPairsHash.get(statName) != null) { statName = desc2KeyPairsHash.get(statName); } DateType dateType = convertDateType(statName); if (dateType == DateType.None) { Vector<Pair<String, Integer>> values; if (statName.startsWith("num_")) { values = getCollNumValuesFromList(statName); Hashtable<String, Boolean> hash = new Hashtable<String, Boolean>(); for (Pair<String, Integer> p : values) { if (hash.get(p.first) == null) { hash.put(p.first, true); } else { int i = 0; String name = p.first; while (hash.get(p.first) != null) { p.first = name + " _" + i; i++; } hash.put(p.first, true); } //p.first += "(" + p.second.toString() + ")"; } } else { values = getCollValuesFromList(statName); } Collections.sort(values, countComparator); Vector<Pair<String, Integer>> top10Values = new Vector<Pair<String, Integer>>(); for (int i = 1; i < Math.min(11, values.size()); i++) { top10Values.insertElementAt(values.get(values.size() - i), 0); } createBarChart(chartPrefixTitle + " " + statName, statName, top10Values); } else { String desc = getByDateDesc(dateType); Vector<Pair<String, Integer>> values = tableName.equals("track") ? getDateValuesFromListByTable(dateType, tableName) : getDateValuesFromList(dateType); Collections.sort(values, titleComparator); createBarChart(chartPrefixTitle + " " + desc, desc, values); } } } }); return pb.getPanel(); }
From source file:org.mybatisorm.annotation.handler.JoinHandler.java
private String getImplicitJoin(List<Field> fields) { Hashtable<Set<Class<?>>, LinkedList<Field[]>> refMap = getRefMap(fields); if (refMap.isEmpty()) throw new InvalidAnnotationException("References for join not found"); Field field = fields.get(0);//ww w.j a v a2s . c o m Class<?> clazz = field.getType(), clazz2; LinkedList<Field[]> refs = null; StringBuilder sb = new StringBuilder(); TableHandler handler = HandlerFactory.getHandler(clazz); String table = handler.getName(), alias = field.getName() + "_"; Map<String, String> aliases = new HashMap<String, String>(); aliases.put(table, alias); sb.append(table).append(" ").append(alias); List<String> cnames = new LinkedList<String>(); for (int i = 1; i < fields.size(); i++) { field = fields.get(i); clazz = field.getType(); table = HandlerFactory.getHandler(clazz).getName(); alias = field.getName() + "_"; aliases.put(table, alias); int j; for (j = i - 1; j >= 0; j--) { clazz2 = fields.get(j).getType(); cnames.add(0, clazz2.getSimpleName()); refs = refMap.get(pair(clazz, clazz2)); if (refs == null) continue; sb.append(" INNER JOIN ").append(table).append(" ").append(alias).append(" ON ("); Iterator<Field[]> it = refs.iterator(); while (it.hasNext()) { Field[] fs = it.next(); table = HandlerFactory.getHandler(fs[0].getDeclaringClass()).getName(); alias = aliases.get(table); sb.append(alias).append(".").append(ColumnAnnotation.getName(fs[0])).append(" = "); table = HandlerFactory.getHandler(fs[1].getDeclaringClass()).getName(); alias = aliases.get(table); sb.append(alias).append(".").append(ColumnAnnotation.getName(fs[1])); if (it.hasNext()) sb.append(" AND "); } sb.append(")"); break; } if (j < 0) throw new InvalidJoinException("The class " + clazz.getSimpleName() + " doesn't refer to the former classes. (" + StringUtil.join(cnames, ",") + ")"); cnames.clear(); } return sb.toString(); }
From source file:org.gvsig.framework.web.service.impl.OGCInfoServiceImpl.java
public ServiceMetadata getMetadataInfoFromWMS(String urlServer) { ServiceMetadata servMetadata = new ServiceMetadata(); try {/*from www . j a v a2 s . c om*/ WMSClient wms = new WMSClient(urlServer); wms.connect(null); // set server information WMSServiceInformation serviceInfo = wms.getServiceInformation(); servMetadata.setAbstractStr(serviceInfo.abstr); servMetadata.setFees(serviceInfo.fees); servMetadata.setKeywords(serviceInfo.keywords); servMetadata.setName(serviceInfo.name); servMetadata.setTitle(serviceInfo.title); servMetadata.setUrl(urlServer); servMetadata.setVersion(serviceInfo.version); // I can't get from service the accessConstraints value //servMetadata.setAccessConstraints(accessConstraints); // get layers TreeMap layers = wms.getLayers(); if (layers != null) { List<Layer> lstLayers = new ArrayList<Layer>(); Set<String> keys = layers.keySet(); for (String key : keys) { WMSLayer wmsLayer = (WMSLayer) layers.get(key); Layer layer = new Layer(); layer.setName(wmsLayer.getName()); layer.setTitle(wmsLayer.getTitle()); lstLayers.add(layer); } servMetadata.setLayers(lstLayers); } // get operations Hashtable supportedOperations = serviceInfo.getSupportedOperationsByName(); if (supportedOperations != null) { List<OperationsMetadata> lstOperations = new ArrayList<OperationsMetadata>(); Set<String> keys = supportedOperations.keySet(); for (String key : keys) { OperationsMetadata opMetadata = new OperationsMetadata(); opMetadata.setName(key); opMetadata.setUrl((String) supportedOperations.get(key)); lstOperations.add(opMetadata); } servMetadata.setOperations(lstOperations); } // get contact address ContactAddressMetadata contactAddress = null; if (StringUtils.isNotEmpty(serviceInfo.address) || StringUtils.isNotEmpty(serviceInfo.addresstype) || StringUtils.isNotEmpty(serviceInfo.place) || StringUtils.isNotEmpty(serviceInfo.country) || StringUtils.isNotEmpty(serviceInfo.postcode) || StringUtils.isNotEmpty(serviceInfo.province)) { contactAddress = new ContactAddressMetadata(); contactAddress.setAddress(serviceInfo.address); contactAddress.setAddressType(serviceInfo.addresstype); contactAddress.setCity(serviceInfo.place); contactAddress.setCountry(serviceInfo.country); contactAddress.setPostCode(serviceInfo.postcode); contactAddress.setStateProvince(serviceInfo.province); } // get contact info ContactMetadata contactMetadata = null; if (contactAddress != null || StringUtils.isNotEmpty(serviceInfo.email) || StringUtils.isNotEmpty(serviceInfo.fax) || StringUtils.isNotEmpty(serviceInfo.organization) || StringUtils.isNotEmpty(serviceInfo.personname) || StringUtils.isNotEmpty(serviceInfo.function) || StringUtils.isNotEmpty(serviceInfo.phone)) { contactMetadata = new ContactMetadata(); contactMetadata.setContactAddress(contactAddress); contactMetadata.setEmail(serviceInfo.email); contactMetadata.setFax(serviceInfo.fax); contactMetadata.setOrganization(serviceInfo.organization); contactMetadata.setPerson(serviceInfo.personname); contactMetadata.setPosition(serviceInfo.function); contactMetadata.setTelephone(serviceInfo.phone); } servMetadata.setContact(contactMetadata); } catch (Exception exc) { // Show exception in log logger.error("Exception on getMetadataInfoFromWMS", exc); throw new ServerGeoException(); } return servMetadata; }
From source file:com.circles.model.ApplicationJSON.java
public Object PopulateFromJSONObjectHash(Hashtable<String, Object> jobj) { Hashtable<String, Object> childhash = new Hashtable<String, Object>(); System.out.println("hash" + jobj.getClass().toString()); Enumeration<?> keys = jobj.keys(); while (keys.hasMoreElements()) { String childkey = (String) keys.nextElement(); try {/* www . ja va 2s . c o m*/ Object objchild = processObject(jobj.get(childkey)); processParent(childkey, childhash, objchild); } catch (Exception jex) { jex.printStackTrace(); } } return childhash; }
From source file:com.smartmarmot.orabbix.Orabbixmon.java
@Override public void run() { try {// www . jav a2 s.c o m Configurator cfg = null; try { cfg = new Configurator(configFile); } catch (Exception e) { SmartLogger.logThis(Level.ERROR, "Error while creating configurator with " + configFile + " " + e); } RuntimeMXBean rmxb = ManagementFactory.getRuntimeMXBean(); String pid = rmxb.getName(); SmartLogger.logThis(Level.INFO, Constants.PROJECT_NAME + " started with pid:" + pid.split("@")[0].toString()); // System.out.print("pid: "+pid.split("@")[0].toString()); String pidfile = cfg.getPidFile(); try { Utility.writePid(pid.split("@")[0].toString(), pidfile); } catch (Exception e) { SmartLogger.logThis(Level.ERROR, "Error while trying to write pidfile " + e); } Locale.setDefault(Locale.US); DBConn[] myDBConn = cfg.getConnections(); if (myDBConn == null) { SmartLogger.logThis(Level.ERROR, "ERROR on main - Connections is null"); throw new Exception("ERROR on main - Connections is null"); } else if (myDBConn.length == 0) { SmartLogger.logThis(Level.ERROR, "ERROR on main - Connections is empty"); throw new Exception("ERROR on main - Connections is empty"); } /** * retrieve maxThread */ Integer maxThread = 0; try { maxThread = cfg.getMaxThread(); } catch (Exception e) { SmartLogger.logThis(Level.WARN, "MaxThread not defined calculated maxThread = " + myDBConn.length * 3); } if (maxThread == null) maxThread = 0; if (maxThread == 0) { maxThread = myDBConn.length * 3; } ExecutorService executor = Executors.newFixedThreadPool(maxThread.intValue()); /** * populate qbox */ Hashtable<String, Querybox> qbox = new Hashtable<String, Querybox>(); for (int i = 0; i < myDBConn.length; i++) { Querybox qboxtmp = Configurator.buildQueryBoxbyDBName(myDBConn[i].getName()); qbox.put(myDBConn[i].getName(), qboxtmp); } // for (int i = 0; i < myDBConn.length; i++) { cfg = null; /** * daemon begin here */ while (running) { /** * istantiate a new configurator */ Configurator c = new Configurator(configFile); /* * here i rebuild DB's List */ if (!c.isEqualsDBList(myDBConn)) { // rebuild connections DBConn[] myDBConn = c.rebuildDBList(myDBConn); for (int i = 1; i < myDBConn.length; i++) { if (!qbox.containsKey(myDBConn[i].getName())) { Querybox qboxtmp = Configurator.buildQueryBoxbyDBName(myDBConn[i].getName()); qbox.put(myDBConn[i].getName(), qboxtmp); } } } // if (!c.isEqualsDBList(myDBConn)) { /* * ready to run query */ for (int i = 0; i < myDBConn.length; i++) { Querybox actqb = qbox.get(myDBConn[i].getName()); actqb.refresh(); Query[] q = actqb.getQueries(); SharedPoolDataSource spds = myDBConn[i].getSPDS(); Hashtable<String, Integer> zabbixServers = c.getZabbixServers(); SmartLogger.logThis(Level.DEBUG, "Ready to run DBJob for dbname ->" + myDBConn[i].getName()); Runnable runner = new DBJob(spds, q, Constants.QUERY_LIST, zabbixServers, myDBConn[i].getName()); executor.execute(runner); } // for (int i = 0; i < myDBConn.length; i++) { Thread.sleep(60 * 1000); SmartLogger.logThis(Level.DEBUG, "Waking up Goood Morning"); } } catch (Exception e1) { // TODO Auto-generated catch block System.out.println("Stopping"); e1.printStackTrace(); stopped = true; } }
From source file:edu.ku.brc.specify.extras.ViewToSchemaReview.java
/** * /*from w ww . j a va2 s. c o m*/ */ public void checkSchemaAndViews() { Hashtable<String, HashSet<String>> viewFieldHash = new Hashtable<String, HashSet<String>>(); SpecifyAppContextMgr sacm = (SpecifyAppContextMgr) AppContextMgr.getInstance(); for (ViewIFace view : sacm.getEntirelyAllViews()) { //System.err.println(view.getName() + " ----------------------"); for (AltViewIFace av : view.getAltViews()) { ViewDefIFace vd = av.getViewDef(); if (vd.getType() == ViewType.form) { DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(vd.getClassName()); if (ti != null) { HashSet<String> tiHash = viewFieldHash.get(ti.getName()); if (tiHash == null) { tiHash = new HashSet<String>(); viewFieldHash.put(ti.getName(), tiHash); } FormViewDef fvd = (FormViewDef) vd; for (FormRowIFace row : fvd.getRows()) { for (FormCellIFace cell : row.getCells()) { if (cell.getType() == FormCellIFace.CellType.panel) { FormCellPanelIFace panelCell = (FormCellPanelIFace) cell; for (String fieldName : panelCell.getFieldNames()) { tiHash.add(fieldName); } } else if (cell.getType() == FormCellIFace.CellType.field || cell.getType() == FormCellIFace.CellType.subview) { String fieldName = cell.getName(); if (!cell.isIgnoreSetGet() && !fieldName.equals("this")) { DBFieldInfo fi = ti.getFieldByName(fieldName); if (fi != null) { //System.err.println("Form Field["+fieldName+"] is in schema."); tiHash.add(fieldName); } else { DBRelationshipInfo ri = ti.getRelationshipByName(fieldName); if (ri == null) { //System.err.println("Form Field["+fieldName+"] not in table."); } else { tiHash.add(fieldName); } } } else if (cell instanceof FormCellFieldIFace) { FormCellFieldIFace fcf = (FormCellFieldIFace) cell; if (fcf.getUiType() == FormCellFieldIFace.FieldType.plugin) { String pluginName = fcf.getProperty("name"); if (StringUtils.isNotEmpty(pluginName)) { checkPluginForNames(fcf, pluginName, tiHash); } } } } } } } } } } for (DBTableInfo ti : DBTableIdMgr.getInstance().getTables()) { int cnt = 0; HashSet<String> tiHash = viewFieldHash.get(ti.getName()); if (tiHash != null) { tblTitle2Name.put(ti.getTitle(), ti.getName()); //System.err.println(ti.getName() + " ----------------------"); for (DBFieldInfo fi : ti.getFields()) { Boolean isInForm = tiHash.contains(fi.getName()); modelList.add( createRow(ti.getTitle(), fi.getName(), fi.getTitle(), isInForm, fi.isHidden(), cnt++)); } for (DBRelationshipInfo ri : ti.getRelationships()) { Boolean isInForm = tiHash.contains(ri.getName()); modelList.add( createRow(ti.getTitle(), ri.getName(), ri.getTitle(), isInForm, ri.isHidden(), cnt++)); } } } viewModel = new ViewModel(); JTable table = new JTable(viewModel); sorter = new TableRowSorter<TableModel>(viewModel); searchTF = new JAutoCompTextField(20); table.setRowSorter(sorter); CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,f:p:g,2px,p:g")); SearchBox searchBox = new SearchBox(searchTF, null); filterCBX = UIHelper.createComboBox(new String[] { "None", "Not On Form, Not Hidden", "On Form, Hidden" }); PanelBuilder searchPB = new PanelBuilder(new FormLayout("p,2px,p, f:p:g, p,2px,p", "p")); searchPB.add(UIHelper.createI18NFormLabel("SEARCH"), cc.xy(1, 1)); searchPB.add(searchBox, cc.xy(3, 1)); searchPB.add(UIHelper.createI18NFormLabel("Filter"), cc.xy(5, 1)); searchPB.add(filterCBX, cc.xy(7, 1)); JLabel legend = UIHelper.createLabel( "<HTML><li><font color=\"red\">Red</font> - Not on form and not hidden</li><li><font color=\"magenta\">Magenta</font> - On the form , but is hidden</li><li>Black - Correct</li>"); legend.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); PanelBuilder legPB = new PanelBuilder(new FormLayout("p,f:p:g", "p")); legPB.add(legend, cc.xy(1, 1)); pb.add(searchPB.getPanel(), cc.xy(1, 1)); pb.add(UIHelper.createScrollPane(table), cc.xy(1, 3)); pb.add(legPB.getPanel(), cc.xy(1, 5)); pb.setDefaultDialogBorder(); sorter.setRowFilter(null); searchTF.getDocument().addDocumentListener(new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { SwingUtilities.invokeLater(new Runnable() { /* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { if (filterCBX.getSelectedIndex() > 0) { blockCBXUpdate = true; filterCBX.setSelectedIndex(-1); blockCBXUpdate = false; } String text = searchTF.getText(); sorter.setRowFilter(text.isEmpty() ? null : RowFilter.regexFilter("^(?i)" + text, 0, 1)); } }); } }); filterCBX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (!blockCBXUpdate) { RowFilter<TableModel, Integer> filter = null; int inx = filterCBX.getSelectedIndex(); if (inx > 0) { filter = filterCBX.getSelectedIndex() == 1 ? new NotOnFormNotHiddenRowFilter() : new OnFormIsHiddenRowFilter(); } sorter.setRowFilter(filter); } } }); } }); table.setDefaultRenderer(String.class, new BiColorTableCellRenderer(false)); table.setDefaultRenderer(Boolean.class, new BiColorBooleanTableCellRenderer()); table.getColumnModel().getColumn(0).setCellRenderer(new TitleCellFadeRenderer()); table.getColumnModel().getColumn(3).setCellRenderer(new BiColorTableCellRenderer(true)); table.getColumnModel().getColumn(2).setCellRenderer(new BiColorTableCellRenderer(false) { @SuppressWarnings("unchecked") @Override public Component getTableCellRendererComponent(JTable tableArg, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel lbl = (JLabel) super.getTableCellRendererComponent(tableArg, value, isSelected, hasFocus, row, column); /*if (sorter.getRowFilter() != null) { System.out.println(" getRowCount:"+sorter.getModel().getRowCount()); Pair<String, Integer> col1Pair = (Pair<String, Integer>)sorter.getModel().getValueAt(row, 0); rowData = modelList.get(col1Pair.second); } else { rowData = modelList.get(row); }*/ //System.out.println(" R2:"+row+" "+rowData[0]+"/"+rowData[1]+" - "+rowData[3]+"|"+rowData[4]); if (value instanceof TableInfo) { TableInfo pair = (TableInfo) value; Object[] rowData = modelList.get(pair.getSecond()); lbl.setText(rowData[0].toString()); } else if (value instanceof Pair<?, ?>) { Pair<String, Integer> pair = (Pair<String, Integer>) value; Object[] rowData = modelList.get(pair.getSecond()); boolean isOnForm = rowData[3] instanceof Boolean ? (Boolean) rowData[3] : ((String) rowData[3]).equals("Yes"); boolean isHidden = rowData[4] instanceof Boolean ? (Boolean) rowData[4] : ((String) rowData[4]).equals("true"); if (!isOnForm && !isHidden) { lbl.setForeground(Color.RED); } else if (isOnForm && isHidden) { lbl.setForeground(Color.MAGENTA); } else { lbl.setForeground(Color.BLACK); } lbl.setText(pair.getFirst()); } else { lbl.setText(value.toString()); } return lbl; } }); //UIHelper.makeTableHeadersCentered(table, false); UIHelper.calcColumnWidths(table, null); //Removing fix all button because fix() method is broken (bug #8087)... /*CustomDialog dlg = new CustomDialog((Frame)UIRegistry.getTopWindow(), "", true, CustomDialog.OKCANCELAPPLY, pb.getPanel()) { @Override protected void applyButtonPressed() { fix(this); } }; dlg.setApplyLabel("Fix All");*/ CustomDialog dlg = new CustomDialog((Frame) UIRegistry.getTopWindow(), "", true, CustomDialog.OKCANCEL, pb.getPanel()); //... end removing fix all button dlg.setVisible(true); if (!dlg.isCancelled()) { updateSchema(); } }
From source file:com.circles.model.ApplicationJSON.java
public Hashtable<String, Object> processParent(String key, Hashtable<String, Object> parent, Object childobj) { Hashtable<String, Object> newhead = parent; Hashtable<String, Object> newparent = newhead; if (!key.equals("")) { String[] splitkey = key.split("\\."); for (int i = 0; i < splitkey.length; i++) { if (splitkey.length - 1 == i) { newparent.put(splitkey[i], childobj); } else { if (newparent.containsKey(splitkey[i])) { Object parentobj = newparent.get(splitkey[i]); if (parentobj.getClass().equals(Hashtable.class)) { newparent = (Hashtable<String, Object>) parentobj; } else { Hashtable<String, Object> childhash = new Hashtable<String, Object>(); newparent.put(splitkey[i], childhash); newparent = childhash; }/*from www . j a v a2s .c o m*/ } else { Hashtable<String, Object> childhash = new Hashtable<String, Object>(); newparent.put(splitkey[i], childhash); newparent = childhash; } } } } return newhead; }
From source file:es.itecban.deployment.executionmanager.DefaultPlanExecutor.java
public ExecutionReportType launchPlan(DeploymentPlanType plan) throws Exception { boolean assetCheckActive = this.isAssetCheckingActive(plan.getEnvironment()); if (assetCheckActive) { Hashtable<String, DeploymentUnitType> notApprovedAssetsHs = null; try {/*from w w w . j a v a 2 s . c om*/ // Validate with the RAM if each asset in the plan is approved notApprovedAssetsHs = this.ramManager.validateAssetInPlan(plan); } catch (ServiceUnavailableException e) { logger.info("Error ocurred while communicating with the RAM. " + "Maybe this module is not available as it is optional "); } if (notApprovedAssetsHs != null && notApprovedAssetsHs.size() != 0) { // String messageError = "The following resource is not approved in the " // + "Rational Asset Manager "; // Show only the first in the collection not approved Set<String> notApprovedAssetsSet = notApprovedAssetsHs.keySet(); for (String notApprovedAsset : notApprovedAssetsSet) { // messageError = messageError // + "\r\n" // + notApprovedAsset // + " in component " // + notApprovedAssetsHs.get(notApprovedAsset) // .getName() // + " version_" // + notApprovedAssetsHs.get(notApprovedAsset) // .getVersion(); // not tested throw new MessageException("running.error.assetNotApproved", notApprovedAsset, notApprovedAssetsHs.get(notApprovedAsset).getName(), notApprovedAssetsHs.get(notApprovedAsset).getVersion()); } } } // If here, all the validations has gone succesfully ExecutionReportType report = null; try { report = executorService.launchPlan(plan); if (report == null) throw new Exception("running.error.problemPlan"); } catch (Exception e) { logger.severe("Error launching the plan." + e.getMessage()); throw new Exception(e.getMessage()); } // Set the report launcher user if (report.getResult().equals(PlanResultKindType.OK) && assetCheckActive) { try { this.ramManager.changeDeployedAssetStatus(plan); logger.info("Plan result: " + report.getResult() + ". Changes done in the RAM to the status of the assets"); } catch (ServiceUnavailableException e) { logger.info("Error ocurred while communicating with the RAM. " + "Maybe this module is not available as it is optional "); } } else { logger.info( "Plan result: " + report.getResult() + ". No changes done in RAM to the status of the assets"); } String planName = plan.getName(); String creationUser = planName.split("\\|")[3]; report.setCreationUserId(creationUser); report.setLauncherUserId(AuthenticationManager.getUserName()); reportManager.setCreationUserId(report.getPlanId(), report.getStartTime(), creationUser); reportManager.setLauncherUserId(report.getPlanId(), report.getStartTime(), AuthenticationManager.getUserName()); return report; }
From source file:com.fiorano.openesb.application.aps.Route.java
public void populate(FioranoStaxParser cursor) throws XMLStreamException, FioranoException { //Set cursor to the current DMI element. You can use either markCursor/getNextElement(<element>) API. if (cursor.markCursor(APSConstants.APP_ROUTE)) { // Get Attributes. This MUST be done before accessing any data of element. Hashtable attributes = cursor.getAttributes(); if (attributes != null && attributes.containsKey(APSConstants.IS_P2PROUTE)) { boolean isP2PRoute = XMLUtils.getStringAsBoolean((String) attributes.get(APSConstants.IS_P2PROUTE)); setIsP2PRoute(isP2PRoute);//from w w w . j a v a 2s . c o m } if (attributes != null && attributes.containsKey(APSConstants.IS_PERSISTANT)) { boolean isPersistant = XMLUtils .getStringAsBoolean((String) attributes.get(APSConstants.IS_PERSISTANT)); setIsPersitant(isPersistant); } if (attributes != null && attributes.containsKey(APSConstants.IS_DURABLE)) { boolean isDurable = XMLUtils.getStringAsBoolean((String) attributes.get(APSConstants.IS_DURABLE)); setIsDurable(isDurable); } if (attributes != null && attributes.containsKey(APSConstants.APPLY_TRANSFORMATION_AT_SRC)) { boolean applyTransformationAtSrc = XMLUtils .getStringAsBoolean((String) attributes.get(APSConstants.APPLY_TRANSFORMATION_AT_SRC)); setApplyTransformationAtSrc(applyTransformationAtSrc); } //Get associated Data //String nodeVal = cursor.getText(); // Get Child Elements while (cursor.nextElement()) { String nodeName = cursor.getLocalName(); // For debugging. Remove this befor chekin... // Get Attributes attributes = cursor.getAttributes(); if (nodeName.equalsIgnoreCase("Name")) { String nodeValue = cursor.getText(); setRouteName(nodeValue); } else if (nodeName.equalsIgnoreCase("RouteGUID")) { String nodeValue = cursor.getText(); setRouteGUID(nodeValue); } else if (nodeName.equalsIgnoreCase("TimeToLive")) { long nodeValue = XMLUtils.getStringAsLong(cursor.getText()); setTimeToLive(nodeValue); } else if (nodeName.equalsIgnoreCase("SrcServiceInstance")) { String nodeValue = cursor.getText(); setSrcServInst(nodeValue); } else if (nodeName.equalsIgnoreCase("SrcPort")) { String nodeValue = cursor.getText(); setSrcPortName(nodeValue); } else if (nodeName.equalsIgnoreCase("TransformationXSL")) { String nodeValue = cursor.getCData(); setTransformationXSL(nodeValue); } else if (nodeName.equalsIgnoreCase("Selector")) { String type = (String) attributes.get("type"); //Iterator itr = attributes.values().iterator(); Enumeration namesItr = attributes.keys(); HashMap namespace = null; if (type.equalsIgnoreCase(XPATH_SELECTOR_OLD)) type = MESSAGE_BODY_XPATH; if (type.equalsIgnoreCase(MESSAGE_BODY_XPATH) || type.equalsIgnoreCase(APP_CONTEXT_XPATH)) { while (namesItr.hasMoreElements()) { String attrName = (String) namesItr.nextElement(); if (attrName.startsWith("esb_")) { if (namespace == null) namespace = new HashMap(); String val = (String) attributes.get(attrName); namespace.put(attrName.substring(4), val); } } String value = cursor.getText(); addXPathSelector(type, value, namespace); } else { String value = cursor.getText(); m_selectors.put(type, value); } } else if (nodeName.equalsIgnoreCase("TgtServiceInstance")) { String nodeValue = cursor.getText(); setTrgtServInst(nodeValue); } else if (nodeName.equalsIgnoreCase("TgtPort")) { String nodeValue = cursor.getText(); setTrgtPortName(nodeValue); } else if (nodeName.equalsIgnoreCase("LongDescription")) { String nodeValue = cursor.getText(); setLongDescription(nodeValue); } else if (nodeName.equalsIgnoreCase("ShortDescription")) { String nodeValue = cursor.getText(); setShortDescription(nodeValue); } else if (nodeName.equalsIgnoreCase("Param")) { String nodeValue = cursor.getText(); Param param = new Param(); String name = (String) attributes.get("name"); param.setParamName(name); param.setParamValue(nodeValue); m_params.add(param); } else if (nodeName.equalsIgnoreCase("AlternateDestination")) { AlternateDestination altDestination = new AlternateDestination(); altDestination.setFieldValues(cursor); setAlternateDestination(altDestination); } } } validate(); }
From source file:com.alfaariss.oa.authentication.remote.aselect.RemoteASelectMethod.java
private UserEvent requestAuthenticate(HttpServletRequest oRequest, HttpServletResponse oResponse, ISession oSession, ASelectIDP oASelectOrganization, Collection cForcedOrganizations) throws OAException, IOException { UserEvent oUserEvent = UserEvent.AUTHN_METHOD_FAILED; Hashtable<String, String> htRequest = new Hashtable<String, String>(); try {/*from w ww. ja v a 2 s. c o m*/ String sUID = null; IUser oUser = oSession.getUser(); if (oUser != null) sUID = oUser.getID(); else sUID = oSession.getForcedUserID(); if (sUID != null) { if (_idMapper != null) { sUID = _idMapper.map(sUID); if (sUID == null) { _eventLogger.info(new UserEventLogItem(oSession, oRequest.getRemoteAddr(), UserEvent.AUTHN_METHOD_NOT_SUPPORTED, this, "No user mapping")); return UserEvent.AUTHN_METHOD_NOT_SUPPORTED; } } htRequest.put(PARAM_UID, sUID); } htRequest.put(PARAM_FORCED, String.valueOf(oSession.isForcedAuthentication())); StringBuffer sbMyURL = new StringBuffer(); sbMyURL.append(oRequest.getRequestURL().toString()); sbMyURL.append("?").append(ISession.ID_NAME); sbMyURL.append("=").append(URLEncoder.encode(oSession.getId(), CHARSET)); htRequest.put(PARAM_LOCAL_AS_URL, sbMyURL.toString()); htRequest.put(PARAM_LOCAL_ORG, _sMyOrganization); htRequest.put(PARAM_ASELECTSERVER, oASelectOrganization.getServerID()); ISessionAttributes oAttributes = oSession.getAttributes(); String sRequiredLevel = null; if (oAttributes.contains(ProxyAttributes.class, SESSION_PROXY_REQUIRED_LEVEL)) sRequiredLevel = (String) oAttributes.get(ProxyAttributes.class, SESSION_PROXY_REQUIRED_LEVEL); else sRequiredLevel = String.valueOf(oASelectOrganization.getLevel()); htRequest.put(PARAM_REQUIRED_LEVEL, sRequiredLevel); String sCountry = null; String sLanguage = null; Locale oLocale = oSession.getLocale(); if (oLocale != null) { sCountry = oLocale.getCountry(); sLanguage = oLocale.getLanguage(); } if (sCountry == null && oASelectOrganization.getCountry() != null) sCountry = oASelectOrganization.getCountry(); if (sCountry != null) htRequest.put(PARAM_COUNTRY, sCountry); if (sLanguage == null && oASelectOrganization.getLanguage() != null) sLanguage = oASelectOrganization.getLanguage(); if (sLanguage != null) htRequest.put(PARAM_LANGUAGE, sLanguage); if (cForcedOrganizations != null) {//DD Only send the optional remote_organization parameter if it the value is not the target organization ID Iterator iter = cForcedOrganizations.iterator(); while (iter.hasNext()) { String sRemoteOrg = (String) iter.next(); if (!sRemoteOrg.equals(oASelectOrganization.getID())) { htRequest.put(PARAM_REMOTE_ORGANIZATION, sRemoteOrg); break; } } } if (oASelectOrganization.isArpTargetEnabled()) { String sArpTarget = resolveArpTarget(oAttributes, oSession.getRequestorId()); if (sArpTarget != null) htRequest.put(PARAM_ARP_TARGET, sArpTarget); } if (oASelectOrganization.doSigning()) { String sSignature = createSignature(htRequest); htRequest.put(PARAM_SIGNATURE, sSignature); } htRequest.put(PARAM_REQUEST, AUTHENTICATE); Hashtable<String, String> htResponse = null; try { htResponse = sendRequest(oASelectOrganization.getURL(), htRequest); } catch (IOException e) { _logger.debug("Could not send authenticate request to: " + oASelectOrganization.getURL(), e); throw e; } String sResultCode = htResponse.get(PARAM_RESULTCODE); if (sResultCode == null) { StringBuffer sbError = new StringBuffer("Required parameter ("); sbError.append(PARAM_RESULTCODE); sbError.append(") not found in request=authenticate response ("); sbError.append(htResponse); sbError.append(") from A-Select Organization: "); sbError.append(oASelectOrganization.getServerID()); _logger.warn(sbError.toString()); _eventLogger.info(new UserEventLogItem(oSession, oRequest.getRemoteAddr(), UserEvent.INTERNAL_ERROR, this, "Invalid authenticate response")); throw new OAException(SystemErrors.ERROR_INTERNAL); } if (!ERROR_ASELECT_SUCCESS.equals(sResultCode)) { StringBuffer sbError = new StringBuffer("Response parameter ("); sbError.append(PARAM_RESULTCODE); sbError.append(") from A-Select Organization '"); sbError.append(oASelectOrganization.getServerID()); sbError.append("' contains error code: "); sbError.append(sResultCode); _logger.warn(sbError.toString()); _eventLogger.info(new UserEventLogItem(oSession, oRequest.getRemoteAddr(), UserEvent.AUTHN_METHOD_FAILED, this, sResultCode)); return UserEvent.AUTHN_METHOD_FAILED; } String sRemoteRid = htResponse.get(PARAM_RID); if (sRemoteRid == null) { StringBuffer sbError = new StringBuffer("Required parameter ("); sbError.append(PARAM_RID); sbError.append(") not found in request=authenticate response ("); sbError.append(htResponse); sbError.append(") from A-Select Organization: "); sbError.append(oASelectOrganization.getServerID()); _logger.warn(sbError.toString()); _eventLogger.info(new UserEventLogItem(oSession, oRequest.getRemoteAddr(), UserEvent.INTERNAL_ERROR, this, "Invalid authenticate response")); throw new OAException(SystemErrors.ERROR_INTERNAL); } String sRemoteLoginUrl = htResponse.get(PARAM_AS_URL); if (sRemoteLoginUrl == null) { StringBuffer sbError = new StringBuffer("Required parameter ("); sbError.append(PARAM_AS_URL); sbError.append(") not found in request=authenticate response ("); sbError.append(htResponse); sbError.append(") from A-Select Organization: "); sbError.append(oASelectOrganization.getServerID()); _logger.warn(sbError.toString()); _eventLogger.info(new UserEventLogItem(oSession, oRequest.getRemoteAddr(), UserEvent.INTERNAL_ERROR, this, "Invalid authenticate response")); throw new OAException(SystemErrors.ERROR_INTERNAL); } StringBuffer sbRedirect = new StringBuffer(sRemoteLoginUrl); sbRedirect.append("&").append(PARAM_RID); sbRedirect.append("=").append(sRemoteRid); sbRedirect.append("&").append(PARAM_ASELECTSERVER); sbRedirect.append("=").append(oASelectOrganization.getServerID()); _eventLogger.info(new UserEventLogItem(oSession, oRequest.getRemoteAddr(), UserEvent.AUTHN_METHOD_IN_PROGRESS, this, "Redirect user with request=login1")); oSession.persist(); oUserEvent = UserEvent.AUTHN_METHOD_IN_PROGRESS; try { oResponse.sendRedirect(sbRedirect.toString()); } catch (IOException e) { _logger.debug("Could not send redirect: " + sbRedirect.toString(), e); throw e; } } catch (IOException e) { throw e; } catch (OAException e) { throw e; } catch (Exception e) { if (oSession != null) _eventLogger.info(new UserEventLogItem(oSession, oRequest.getRemoteAddr(), UserEvent.INTERNAL_ERROR, this, null)); else _eventLogger.info(new UserEventLogItem(null, null, null, UserEvent.INTERNAL_ERROR, null, oRequest.getRemoteAddr(), null, this, null)); _logger.fatal("Internal error during 'request=authenticate' API call to: " + oASelectOrganization.getServerID(), e); throw new OAException(SystemErrors.ERROR_INTERNAL); } return oUserEvent; }