List of usage examples for org.apache.commons.lang StringUtils startsWithIgnoreCase
public static boolean startsWithIgnoreCase(String str, String prefix)
Case insensitive check if a String starts with a specified prefix.
From source file:com.sfs.whichdoctor.dao.AddressVerificationDAOImpl.java
/** * Process the address verification./*from w w w .j a v a 2 s. c o m*/ * * @param addressVerification the address verification * @return true, if successful * @throws WhichDoctorDaoException the which doctor dao exception */ public boolean process(final AddressVerificationBean av) throws WhichDoctorDaoException { boolean success = false; if (av.getOutputAddress() == null) { throw new WhichDoctorDaoException("No valid output address exists"); } if (StringUtils.isBlank(av.getReturnCode())) { throw new WhichDoctorDaoException("This address verification record is yet" + "to be verified"); } UserBean systemUser = getSystemUser("Address", "Verification"); PrivilegesBean privileges = new PrivilegesBean(); try { privileges = this.privilegesDAO.load(); } catch (SFSDaoException sfe) { dataLogger.error("Error loading privileges: " + sfe.getMessage()); throw new WhichDoctorDaoException("Error loading privileges: " + sfe.getMessage()); } Collection<String> processableReturnCodes = getProcessableReturnCodes(); boolean canProcess = false; for (String code : processableReturnCodes) { if (StringUtils.startsWithIgnoreCase(av.getReturnCode(), code)) { canProcess = true; } } if (canProcess) { // Load the current address AddressBean address = null; try { address = this.addressDAO.loadGUID(av.getAddressGUID()); } catch (WhichDoctorDaoException wde) { dataLogger.error("Error loading related address: " + wde.getMessage()); } if (address != null) { if (address.compare(av.getOutputAddress(), false)) { // The address is different - update the address and status AddressBean updated = mergeAddress(address, av.getOutputAddress()); if (StringUtils.isBlank(updated.getState())) { // Check to see if a state is available updated.setState(addressDAO.getState(updated.getCity(), updated.getCountry())); } updated.setVerificationStatus("Verified address"); try { updated.setLogMessage("Automatic address verification update"); int updateId = addressDAO.modify(updated, systemUser, privileges); if (updateId > 0) { // Address successfully updated updateProcessStatus(av.getAddressVerificationId(), PROCESSED, ""); } else { // The address was not updated dataLogger.error("The address could not be updated"); updateProcessStatus(av.getAddressVerificationId(), PROCESS_ERROR, "The address could not be updated"); } } catch (Exception e) { // Error updating the address dataLogger.error("Error updating verified address: " + e.getMessage(), e); updateProcessStatus(av.getAddressVerificationId(), PROCESS_ERROR, "Error updating verified address: " + e.getMessage()); } } else { // The address is not different - update the status updateProcessStatus(av.getAddressVerificationId(), PROCESSED, "The verified address was the same" + " as the current address"); } } else { // The address does not exist record the error and update the status updateProcessStatus(av.getAddressVerificationId(), PROCESS_ERROR, "The address does not exist"); } } return success; }
From source file:jp.primecloud.auto.process.puppet.PuppetComponentProcess.java
public void createNodeManifest(ComponentProcessContext context) { // ??// w w w . ja va 2 s .co m Farm farm = farmDao.read(context.getFarmNo()); User user = userDao.read(farm.getUserNo()); List<Component> components = componentDao.readByFarmNo(context.getFarmNo()); Map<Long, Component> componentMap = new HashMap<Long, Component>(); for (Component component : components) { componentMap.put(component.getComponentNo(), component); } List<Instance> instances = instanceDao.readInInstanceNos(context.getRunningInstanceNos()); Map<Long, Instance> instanceMap = new HashMap<Long, Instance>(); for (Instance instance : instances) { instanceMap.put(instance.getInstanceNo(), instance); } List<ComponentType> componentTypes = componentTypeDao.readAll(); Map<Long, ComponentType> componentTypeMap = new HashMap<Long, ComponentType>(); for (ComponentType componentType : componentTypes) { componentTypeMap.put(componentType.getComponentTypeNo(), componentType); } // myCloud?? List<Instance> allDbInstances = new ArrayList<Instance>(); // myCloud?? List<Instance> allApInstances = new ArrayList<Instance>(); // myCloud?WEB? List<Instance> allWebInstances = new ArrayList<Instance>(); // ????? Map<Long, List<Instance>> dbInstancesMap = new HashMap<Long, List<Instance>>(); // ????? Map<Long, List<Instance>> apInstancesMap = new HashMap<Long, List<Instance>>(); // ???WEB?? Map<Long, List<Instance>> webInstancesMap = new HashMap<Long, List<Instance>>(); // myCloud??????? List<ComponentInstance> allComponentInstances = componentInstanceDao .readInInstanceNos(context.getRunningInstanceNos()); for (ComponentInstance componentInstance : allComponentInstances) { // ?? if (BooleanUtils.isNotTrue(componentInstance.getEnabled()) || BooleanUtils.isNotTrue(componentInstance.getAssociate())) { continue; } Component component = componentMap.get(componentInstance.getComponentNo()); Instance instance = instanceMap.get(componentInstance.getInstanceNo()); ComponentType componentType = componentTypeMap.get(component.getComponentTypeNo()); if (ComponentConstants.LAYER_NAME_DB.equals(componentType.getLayer())) { allDbInstances.add(instance); List<Instance> dbInstances = dbInstancesMap.get(component.getComponentNo()); if (dbInstances == null) { dbInstances = new ArrayList<Instance>(); } dbInstances.add(instance); dbInstancesMap.put(component.getComponentNo(), dbInstances); } else if (ComponentConstants.LAYER_NAME_AP_JAVA.equals(componentType.getLayer())) { allApInstances.add(instance); List<Instance> apInstances = apInstancesMap.get(component.getComponentNo()); if (apInstances == null) { apInstances = new ArrayList<Instance>(); } apInstances.add(instance); apInstancesMap.put(component.getComponentNo(), apInstances); } else if (ComponentConstants.LAYER_NAME_WEB.equals(componentType.getLayer())) { allWebInstances.add(instance); List<Instance> webInstances = webInstancesMap.get(component.getComponentNo()); if (webInstances == null) { webInstances = new ArrayList<Instance>(); } webInstances.add(instance); webInstancesMap.put(component.getComponentNo(), webInstances); } } for (Instance instance : instances) { Platform platform = platformDao.read(instance.getPlatformNo()); //OS?windows??????? Image image = imageDao.read(instance.getImageNo()); if (StringUtils.startsWithIgnoreCase(image.getOs(), PCCConstant.OS_NAME_WIN)) { continue; } Map<String, Object> rootMap = new HashMap<String, Object>(); rootMap.put("farm", farm); rootMap.put("user", user); rootMap.put("components", components); rootMap.put("instance", instance); rootMap.put("platform", platform); // ??? List<Component> associatedComponents = new ArrayList<Component>(); List<ComponentType> associatedComponentTypes = new ArrayList<ComponentType>(); List<ComponentInstance> componentInstances = componentInstanceDao .readByInstanceNo(instance.getInstanceNo()); for (ComponentInstance componentInstance : componentInstances) { // ?? if (BooleanUtils.isNotTrue(componentInstance.getEnabled()) || BooleanUtils.isNotTrue(componentInstance.getAssociate())) { continue; } Component component = componentMap.get(componentInstance.getComponentNo()); ComponentType componentType = componentTypeMap.get(component.getComponentTypeNo()); associatedComponents.add(component); associatedComponentTypes.add(componentType); } rootMap.put("associatedComponents", associatedComponents); rootMap.put("associatedComponentTypes", associatedComponentTypes); // ???? List<Instance> dbInstances = new ArrayList<Instance>(); // ???? List<Instance> apInstances = new ArrayList<Instance>(); // ???WEB? List<Instance> webInstances = new ArrayList<Instance>(); for (Component component : associatedComponents) { ComponentType componentType = componentTypeMap.get(component.getComponentTypeNo()); if (ComponentConstants.LAYER_NAME_DB.equals(componentType.getLayer())) { dbInstances = dbInstancesMap.get(component.getComponentNo()); } else if (ComponentConstants.LAYER_NAME_AP_JAVA.equals(componentType.getLayer())) { apInstances = apInstancesMap.get(component.getComponentNo()); } else if (ComponentConstants.LAYER_NAME_WEB.equals(componentType.getLayer())) { webInstances = webInstancesMap.get(component.getComponentNo()); } } rootMap.put("dbInstances", dbInstances); rootMap.put("apInstances", apInstances); rootMap.put("webInstances", webInstances); rootMap.put("allDbInstances", allDbInstances); rootMap.put("allApInstances", allApInstances); rootMap.put("allWebInstances", allWebInstances); File manifestFile = new File(manifestDir, instance.getFqdn() + ".pp"); generateManifest("node.ftl", rootMap, manifestFile, "UTF-8"); } }
From source file:com.antsdb.saltedfish.server.mysql.replication.MysqlSlave.java
private void onQuery(QueryEvent event) throws SQLException { String sql = event.getSql().toString(); if (sql.equalsIgnoreCase("BEGIN")) { return;//from w ww . j a va 2 s . com } if (StringUtils.startsWithIgnoreCase(sql, "grant ")) { // dont process grants. return; } if (StringUtils.startsWithIgnoreCase(sql, "flush ")) { // dont process flush privileges. return; } String dbname = event.getDatabaseName().toString(); if (!StringUtils.isEmpty(dbname)) { this.session.run("USE " + dbname); } this.session.run(sql); return; }
From source file:eionet.cr.dao.helpers.CsvImportHelper.java
/** * Stores the additional meta data from wizard inputs. * * @throws DAOException//from w w w . j a v a 2 s. c om * @throws RepositoryException * @throws IOException */ public void saveWizardInputs() throws DAOException, RepositoryException, IOException { HarvestSourceDAO dao = DAOFactory.get().getDao(HarvestSourceDAO.class); dao.insertUpdateSourceMetadata(fileUri, Predicates.CR_OBJECTS_TYPE, ObjectDTO.createLiteral(objectsType)); if (StringUtils.isNotEmpty(fileLabel)) { dao.insertUpdateSourceMetadata(fileUri, Predicates.RDFS_LABEL, ObjectDTO.createLiteral(fileLabel)); } ObjectDTO[] uniqueColTitles = new ObjectDTO[uniqueColumns.size()]; for (int i = 0; i < uniqueColumns.size(); i++) { uniqueColTitles[i] = ObjectDTO.createLiteral(uniqueColumns.get(i)); } dao.insertUpdateSourceMetadata(fileUri, Predicates.CR_OBJECTS_UNIQUE_COLUMN, uniqueColTitles); // Copyright information if (StringUtils.isNotEmpty(publisher)) { if (StringUtils.startsWithIgnoreCase(publisher, "http")) { dao.insertUpdateSourceMetadata(fileUri, Predicates.DCTERMS_PUBLISHER, ObjectDTO.createResource(publisher)); } else { dao.insertUpdateSourceMetadata(fileUri, Predicates.DCTERMS_PUBLISHER, ObjectDTO.createLiteral(publisher)); } } if (StringUtils.startsWithIgnoreCase(license, "http")) { dao.insertUpdateSourceMetadata(fileUri, Predicates.DCTERMS_LICENSE, ObjectDTO.createResource(license)); } else { dao.insertUpdateSourceMetadata(fileUri, Predicates.DCTERMS_RIGHTS, ObjectDTO.createLiteral(license)); } if (StringUtils.isNotEmpty(attribution)) { dao.insertUpdateSourceMetadata(fileUri, Predicates.DCTERMS_BIBLIOGRAPHIC_CITATION, ObjectDTO.createLiteral(attribution)); } if (StringUtils.isNotEmpty(source)) { if (StringUtils.startsWithIgnoreCase(source, "http")) { dao.insertUpdateSourceMetadata(fileUri, Predicates.DCTERMS_SOURCE, ObjectDTO.createResource(source)); } else { dao.insertUpdateSourceMetadata(fileUri, Predicates.DCTERMS_SOURCE, ObjectDTO.createLiteral(source)); } } }
From source file:com.hangum.tadpole.rdb.core.dialog.job.CreateJobDialog.java
/** * Create contents of the dialog.// w w w . j a va2 s. co m * * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite containerInput = (Composite) super.createDialogArea(parent); GridLayout gl_containerInput = (GridLayout) containerInput.getLayout(); gl_containerInput.verticalSpacing = 1; gl_containerInput.horizontalSpacing = 1; gl_containerInput.marginHeight = 1; gl_containerInput.marginWidth = 1; Composite compositeHead = new Composite(containerInput, SWT.NONE); compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); compositeHead.setLayout(new GridLayout(2, false)); lblJobId = new Label(compositeHead, SWT.NONE); lblJobId.setText("Job ID"); textJob = new Text(compositeHead, SWT.BORDER | SWT.READ_ONLY | SWT.RIGHT); GridData gd_textJob = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); gd_textJob.widthHint = 100; textJob.setLayoutData(gd_textJob); textJob.setText(this.jobDao.getJob() + ""); Label lblObjectType = new Label(compositeHead, SWT.NONE); lblObjectType.setText(Messages.get().CreateJobDialog_FirstStartDatetime); Composite composite = new Composite(compositeHead, SWT.NONE); composite.setLayout(new GridLayout(2, false)); btnSpecify = new Button(composite, SWT.RADIO); btnSpecify.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // ? ? ?? ?... dateStartDate.setEnabled(true); dateStartTime.setEnabled(true); Calendar c = Calendar.getInstance(); dateStartDate.setDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)); dateStartTime.setDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)); dateStartTime.setTime(c.get(Calendar.HOUR), c.get(Calendar.MINUTE), c.get(Calendar.SECOND)); createScript(); } }); btnSpecify.setText(Messages.get().CreateJobDialog_specification); btnNext = new Button(composite, SWT.RADIO); btnNext.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { dateStartDate.setEnabled(false); dateStartTime.setEnabled(false); createScript(); } }); btnNext.setText(Messages.get().CreateJobDialog_NextIterationExecutionCycle); if (this.jobDao.getJob() > 0) { btnNext.setSelection(true); } else { btnSpecify.setSelection(true); } dateStartDate = new DateTime(composite, SWT.BORDER); dateStartDate.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { createScript(); } }); GridData gd_dateStartDate = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_dateStartDate.widthHint = 120; dateStartDate.setLayoutData(gd_dateStartDate); dateStartTime = new DateTime(composite, SWT.BORDER | SWT.TIME); dateStartTime.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { createScript(); } }); GridData gd_dateStartTime = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_dateStartTime.widthHint = 120; dateStartTime.setLayoutData(gd_dateStartTime); dateStartTime.setSize(104, 27); Label lblObjectName = new Label(compositeHead, SWT.NONE); lblObjectName.setText(Messages.get().CreateJobDialog_IterationExecutionCycle); Composite composite_3 = new Composite(compositeHead, SWT.NONE); composite_3.setLayout(new GridLayout(2, false)); comboRepeat = new Combo(composite_3, SWT.READ_ONLY); comboRepeat.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setRepeatString(); createScript(); } }); // "? ? ??", "7? ??", "30? ??", "?? ??", "? 6?", comboRepeat.setItems(new String[] { Messages.get().EveryNight, Messages.get().Every7Days, Messages.get().Every30Days, Messages.get().EverySunday, Messages.get().Every6Morning, // "3? ", " 1? ??", " 1? 6 30?" Messages.get().Every3Hours, Messages.get().EveryFristDayMonth, Messages.get().EveryFirstDayAm }); GridData gd_comboRepeat = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_comboRepeat.widthHint = 250; comboRepeat.setLayoutData(gd_comboRepeat); comboRepeat.setVisibleItemCount(8); textRepeat = new Text(composite_3, SWT.BORDER); textRepeat.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent event) { createScript(); } }); GridData gd_textRepeat = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_textRepeat.minimumWidth = 200; gd_textRepeat.widthHint = 300; textRepeat.setLayoutData(gd_textRepeat); if (this.jobDao.getJob() <= 0) { comboRepeat.select(0); this.setRepeatString(); } else { textRepeat.setText(this.jobDao.getInterval()); } Label lblParsing = new Label(compositeHead, SWT.NONE); lblParsing.setText(Messages.get().CreateJobDialog_analysis); Composite composite_2 = new Composite(compositeHead, SWT.NONE); composite_2.setLayout(new GridLayout(2, false)); btnParse = new Button(composite_2, SWT.RADIO); btnParse.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { createScript(); } }); GridData gd_btnParse = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_btnParse.widthHint = 120; btnParse.setLayoutData(gd_btnParse); btnParse.setText("Parse"); btnNoParse = new Button(composite_2, SWT.RADIO); btnNoParse.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { createScript(); } }); GridData gd_btnNoParse = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_btnNoParse.widthHint = 120; btnNoParse.setLayoutData(gd_btnNoParse); btnNoParse.setText("No Parse"); btnParse.setSelection(true); // ? ?. ? . composite_2.setEnabled(this.jobDao.getJob() <= 0); lblNewLabel = new Label(compositeHead, SWT.NONE); lblNewLabel.setText(""); Composite composite_1 = new Composite(compositeHead, SWT.NONE); composite_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); composite_1.setLayout(new GridLayout(3, false)); comboType = new Combo(composite_1, SWT.READ_ONLY); comboType.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (StringUtils.startsWithIgnoreCase(PublicTadpoleDefine.OBJECT_TYPE.PACKAGES.name(), comboType.getText()) || StringUtils.startsWithIgnoreCase(PublicTadpoleDefine.OBJECT_TYPE.PROCEDURES.name(), comboType.getText())) { initMainObject(comboType.getText()); } else { //PL/SQL ? ?. textScript.setText("DBMS_OUTPUT.PUT_LINE('today is ' || to_char(sysdate)); "); createScript(); } } }); comboType.setItems(new String[] { "Procedure", "Package", "PL/SQL Block" }); comboType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); comboType.select(0); comboObject = new Combo(composite_1, SWT.READ_ONLY); comboObject.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (StringUtils.startsWithIgnoreCase(PublicTadpoleDefine.OBJECT_TYPE.PACKAGES.name(), comboType.getText())) { // ? ?(, ) . initPackgeBodys(comboObject.getText()); } else if (StringUtils.startsWithIgnoreCase(PublicTadpoleDefine.OBJECT_TYPE.PROCEDURES.name(), comboType.getText())) { // ? ?? . initParameters(comboObject.getSelectionIndex()); } createScript(); } }); GridData gd_comboObject = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_comboObject.widthHint = 200; comboObject.setLayoutData(gd_comboObject); comboSubObject = new Combo(composite_1, SWT.READ_ONLY); comboSubObject.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { initParameters(comboSubObject.getSelectionIndex()); createScript(); } }); comboSubObject.setEnabled(false); GridData gd_comboSubObject = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_comboSubObject.widthHint = 200; comboSubObject.setLayoutData(gd_comboSubObject); SashForm sashForm = new SashForm(containerInput, SWT.VERTICAL); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); grpTables = new Group(sashForm, SWT.NONE); GridLayout gl_grpTables = new GridLayout(1, false); gl_grpTables.horizontalSpacing = 2; gl_grpTables.verticalSpacing = 2; gl_grpTables.marginHeight = 2; gl_grpTables.marginWidth = 2; grpTables.setLayout(gl_grpTables); grpTables.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); grpTables.setText(Messages.get().CreateJobDialog_executedScript); textScript = new Text(grpTables, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI); textScript.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent event) { createScript(); } }); textScript.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { createScript(); } }); GridData gd_textScript = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1); gd_textScript.heightHint = 100; gd_textScript.minimumHeight = 100; textScript.setLayoutData(gd_textScript); textScript.setText(this.jobDao.getWhat()); label_1 = new Label(grpTables, SWT.NONE); label_1.setText(Messages.get().Preview); textPreview = new Text(grpTables, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI); textPreview.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); initMainObject(this.comboType.getText()); createScript(); // google analytic AnalyticCaller.track(this.getClass().getName()); return containerInput; }
From source file:com.microsoft.alm.plugin.external.commands.Command.java
/** * This method evaluates a line of output to see if it contains something that is expected. * If not, it returns false.//from w w w. ja v a 2 s .c om * There are 3 kinds of expected lines: * 1) lines that begin with an expected prefix * 2) lines that contain a folder path (/path/path:) * 3) empty lines * All other types of lines are unexpected. */ protected boolean isOutputLineExpected(final String line, final String[] expectedPrefixes, final boolean filePathsAreExpected) { final String trimmed = line != null ? line.trim() : null; if (StringUtils.isNotEmpty(trimmed)) { // If we are expecting file paths, check for a file path pattern (ex. /path/path2:) if (filePathsAreExpected && isFilePath(line)) { // This matched our file path pattern, so it is expected return true; } // Next, check for one of the expected prefixes if (expectedPrefixes != null) { for (final String prefix : expectedPrefixes) { if (StringUtils.startsWithIgnoreCase(line, prefix)) { // The line starts with an expected prefix so it is expected return true; } } } // The line is not empty and does not contain anything we expect // So, it is probably an error. return false; } // Just return true for empty lines return true; }
From source file:com.btobits.automator.ant.sql.task.SQLCompareTask.java
private void validateParameter() throws BuildException { if (StringUtils.isBlank(driver)) { throw new BuildException("Driver must be specifed."); }/* www.j a va2 s . c om*/ if (StringUtils.isBlank(url)) { throw new BuildException("Url must be specifed."); } if (StringUtils.isBlank(user)) { throw new BuildException("User must be specifed."); } if (password == null) { throw new BuildException("Password cannot be null."); } if (StringUtils.isBlank(query)) { throw new BuildException("Query must be specifed."); } query = StringUtils.trim(query); if (!StringUtils.startsWithIgnoreCase(query, "SELECT")) { throw new BuildException("Query must start witch 'SELECT' statement."); } }
From source file:jp.primecloud.auto.process.puppet.PuppetNodesProcess.java
protected void runPuppet(Instance instance) { Image image = imageDao.read(instance.getImageNo()); // Puppet??//from w w w. j a v a 2s . c o m try { processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, null, instance, "PuppetManifestApply", new String[] { instance.getFqdn(), "base_coordinate" }); puppetClient.runClient(instance.getFqdn()); if (StringUtils.startsWithIgnoreCase(image.getOs(), PCCConstant.OS_NAME_WIN)) { // TODO ????????? // 1?puppet run???????????????2? // LinuxOS?????puppet?postrun_command???????1?? log.debug(MessageUtils.format( "run the puppet process(base_coordinate) twice for windows instance. (fqdn={0})", instance.getFqdn())); puppetClient.runClient(instance.getFqdn()); } } catch (RuntimeException e) { processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, null, instance, "PuppetManifestApplyFail", new String[] { instance.getFqdn(), "base_coordinate" }); // ?????????? String code = (e instanceof AutoException) ? AutoException.class.cast(e).getCode() : null; if ("EPUPPET-000003".equals(code) || "EPUPPET-000007".equals(code)) { log.warn(e.getMessage()); processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, null, instance, "PuppetManifestApply", new String[] { instance.getFqdn(), "base_coordinate" }); try { puppetClient.runClient(instance.getFqdn()); } catch (RuntimeException e2) { processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, null, instance, "PuppetManifestApplyFail", new String[] { instance.getFqdn(), "base_coordinate" }); throw e2; } } else { throw e; } } processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, null, instance, "PuppetManifestApplyFinish", new String[] { instance.getFqdn(), "base_coordinate" }); }
From source file:com.tesora.dve.mysqlapi.repl.MyReplicationVisitorDispatch.java
@Override public void visit(MyQueryLogEvent packet) throws PEException { boolean switchToDb = true; ServerDBConnection conn = null;/*from w ww. j a va 2s . c om*/ String dbName = packet.getDbName(); String origQuery = packet.getOrigQuery(); try { if (!this.includeDatabase(plugin, dbName)) { // still want to update log position if we filter out message updateBinLogPosition(packet, plugin); return; } if (StringUtils.startsWithIgnoreCase(origQuery, "CREATE DATABASE") || StringUtils.startsWithIgnoreCase(origQuery, "DROP DATABASE")) { switchToDb = false; } conn = plugin.getServerDBConnection(); // If any session variables are to be set do it first plugin.getSessionVariableCache().setAllSessionVariableValues(conn); if (logger.isDebugEnabled()) { logger.debug("** START QueryLog Event **"); if (switchToDb) logger.debug("USE " + dbName); logger.debug(origQuery); logger.debug("** END QueryLog Event **"); } if (switchToDb) conn.setCatalog(dbName); // since we don't want to parse here to determine if a time function is specified // set the TIMESTAMP variable to the master statement execution time conn.executeUpdate("set " + VariableConstants.REPL_SLAVE_TIMESTAMP_NAME + "=" + packet.getCommonHeader().getTimestamp()); boolean unset = handleAutoIncrement(conn, plugin.getSessionVariableCache().getIntVarValue()); conn.executeUpdate(packet.getQuery().array()); if (unset) conn.executeUpdate("set " + VariableConstants.REPL_SLAVE_INSERT_ID_NAME + "=null"); updateBinLogPosition(packet, plugin); } catch (Exception e) { if (plugin.validateErrorAndStop(packet.getErrorCode(), e)) { logger.error("Error occurred during replication processing: ", e); try { conn.execute("ROLLBACK"); } catch (SQLException e1) { throw new PEException("Error attempting to rollback after exception", e); // NOPMD by doug on 18/12/12 8:07 AM } } else { packet.setSkipErrors(true, "Replication Slave failed processing: '" + origQuery + "' but slave_skip_errors is active. Replication processing will continue"); } throw new PEException("Error executing: " + origQuery, e); } finally { // NOPMD by doug on 18/12/12 8:08 AM // Clear all the session variables since they are only good for one // event plugin.getSessionVariableCache().clearAllSessionVariables(); } }
From source file:com.adobe.acs.tools.explain_query.impl.ExplainQueryServlet.java
private JSONArray compositeQueryDataToJSON(Collection<CompositeData> queries) throws JSONException { final JSONArray jsonArray = new JSONArray(); for (CompositeData query : queries) { Long duration = (Long) query.get("duration"); Integer occurrenceCount = (Integer) query.get("occurrenceCount"); String language = (String) query.get("language"); String statement = (String) query.get("statement"); if (!ArrayUtils.contains(LANGUAGES, language)) { // Not a supported language continue; } else if (StringUtils.startsWithIgnoreCase(statement, "EXPLAIN ") || StringUtils.startsWithIgnoreCase(statement, "MEASURE ")) { // Don't show EXPLAIN or MEASURE queries continue; }/*from w w w . jav a 2s . c om*/ final JSONObject json = new JSONObject(); try { json.put("duration", duration); json.put("language", language); json.put("occurrenceCount", occurrenceCount); json.put("statement", statement); jsonArray.put(json); } catch (JSONException e) { log.warn("Could not add query to results [ {} ]", statement); continue; } } return jsonArray; }