List of usage examples for java.lang StringBuffer setLength
@Override public synchronized void setLength(int newLength)
From source file:org.kie.workbench.common.stunner.bpmn.backend.legacy.Bpmn2JsonMarshaller.java
private void setThrowEventProperties(ThrowEvent event, Map<String, Object> properties, Definitions def) { if (event.getInputSet() != null) { List<DataInput> dataInputs = event.getInputSet().getDataInputRefs(); StringBuffer dinbuff = new StringBuffer(); for (DataInput din : dataInputs) { dinbuff.append(din.getName()); String dtype = getAnyAttributeValue(din, "dtype"); if (dtype != null && !dtype.isEmpty()) { dinbuff.append(":").append(dtype); }//from w ww .j av a 2s. co m dinbuff.append(","); } if (dinbuff.length() > 0) { dinbuff.setLength(dinbuff.length() - 1); } String datainput = dinbuff.toString(); properties.put(DATAINPUT, datainput); StringBuilder associationBuff = new StringBuilder(); marshallDataInputAssociations(associationBuff, event.getDataInputAssociation()); String assignmentString = associationBuff.toString(); if (assignmentString.endsWith(",")) { assignmentString = assignmentString.substring(0, assignmentString.length() - 1); } properties.put(DATAINPUTASSOCIATIONS, assignmentString); setAssignmentsInfoProperty(datainput, null, null, null, assignmentString, properties); } // signal scope String signalScope = Utils.getMetaDataValue(event.getExtensionValues(), "customScope"); if (signalScope != null) { properties.put(SIGNALSCOPE, signalScope); } // event definitions List<EventDefinition> eventdefs = event.getEventDefinitions(); for (EventDefinition ed : eventdefs) { if (ed instanceof TimerEventDefinition) { TimerEventDefinition ted = (TimerEventDefinition) ed; if (ted.getTimeDate() != null) { properties.put(TIMEDATE, ((FormalExpression) ted.getTimeDate()).getBody()); } if (ted.getTimeDuration() != null) { properties.put(TIMEDURATION, ((FormalExpression) ted.getTimeDuration()).getBody()); } if (ted.getTimeCycle() != null) { properties.put(TIMECYCLE, ((FormalExpression) ted.getTimeCycle()).getBody()); if (((FormalExpression) ted.getTimeCycle()).getLanguage() != null) { properties.put(TIMECYCLELANGUAGE, ((FormalExpression) ted.getTimeCycle()).getLanguage()); } } } else if (ed instanceof SignalEventDefinition) { if (((SignalEventDefinition) ed).getSignalRef() != null) { // find signal with the corresponding id boolean foundSignalRef = false; List<RootElement> rootElements = def.getRootElements(); for (RootElement re : rootElements) { if (re instanceof Signal) { if (re.getId().equals(((SignalEventDefinition) ed).getSignalRef())) { properties.put(SIGNALREF, ((Signal) re).getName()); foundSignalRef = true; } } } if (!foundSignalRef) { properties.put(SIGNALREF, ""); } } else { properties.put(SIGNALREF, ""); } } else if (ed instanceof ErrorEventDefinition) { if (((ErrorEventDefinition) ed).getErrorRef() != null && ((ErrorEventDefinition) ed).getErrorRef().getErrorCode() != null) { properties.put(ERRORREF, ((ErrorEventDefinition) ed).getErrorRef().getErrorCode()); } else { properties.put(ERRORREF, ""); } } else if (ed instanceof ConditionalEventDefinition) { FormalExpression conditionalExp = (FormalExpression) ((ConditionalEventDefinition) ed) .getCondition(); if (conditionalExp.getBody() != null) { properties.put(CONDITIONEXPRESSION, conditionalExp.getBody()); } if (conditionalExp.getLanguage() != null) { String languageVal = conditionalExp.getLanguage(); if (languageVal.equals("http://www.jboss.org/drools/rule")) { properties.put(CONDITIONLANGUAGE, "drools"); } else if (languageVal.equals("http://www.mvel.org/2.0")) { properties.put(CONDITIONLANGUAGE, "mvel"); } else { // default to drools properties.put(CONDITIONLANGUAGE, "drools"); } } } else if (ed instanceof EscalationEventDefinition) { if (((EscalationEventDefinition) ed).getEscalationRef() != null) { Escalation esc = ((EscalationEventDefinition) ed).getEscalationRef(); if (esc.getEscalationCode() != null && esc.getEscalationCode().length() > 0) { properties.put(ESCALATIONCODE, esc.getEscalationCode()); } else { properties.put(ESCALATIONCODE, ""); } } } else if (ed instanceof MessageEventDefinition) { if (((MessageEventDefinition) ed).getMessageRef() != null) { Message msg = ((MessageEventDefinition) ed).getMessageRef(); properties.put(MESSAGEREF, msg.getId()); } } else if (ed instanceof CompensateEventDefinition) { if (((CompensateEventDefinition) ed).getActivityRef() != null) { Activity act = ((CompensateEventDefinition) ed).getActivityRef(); properties.put(ACTIVITYREF, act.getName()); } } } }
From source file:org.jbpm.designer.bpmn2.impl.Bpmn2JsonMarshaller.java
private void setThrowEventProperties(ThrowEvent event, Map<String, Object> properties, Definitions def) { if (event.getInputSet() != null) { List<DataInput> dataInputs = event.getInputSet().getDataInputRefs(); StringBuffer dinbuff = new StringBuffer(); for (DataInput din : dataInputs) { dinbuff.append(din.getName()); String dtype = getAnyAttributeValue(din, "dtype"); if (dtype != null && !dtype.isEmpty()) { dinbuff.append(":").append(dtype); }//from ww w. ja v a 2 s . c o m dinbuff.append(","); } if (dinbuff.length() > 0) { dinbuff.setLength(dinbuff.length() - 1); } properties.put("datainput", dinbuff.toString()); StringBuilder associationBuff = new StringBuilder(); marshallDataInputAssociations(associationBuff, event.getDataInputAssociation()); String assignmentString = associationBuff.toString(); if (assignmentString.endsWith(",")) { assignmentString = assignmentString.substring(0, assignmentString.length() - 1); } properties.put("datainputassociations", assignmentString); } // signal scope String signalScope = Utils.getMetaDataValue(event.getExtensionValues(), "customScope"); if (signalScope != null) { properties.put("signalscope", signalScope); } // event definitions List<EventDefinition> eventdefs = getEventDefinitionsForEvent(event); for (EventDefinition ed : eventdefs) { if (ed instanceof TimerEventDefinition) { TimerEventDefinition ted = (TimerEventDefinition) ed; if (ted.getTimeDate() != null) { try { properties.put("timedate", ((FormalExpression) ted.getTimeDate()).getBody()); } catch (Exception e) { _logger.info("Could not find timedate for: " + ted); } } if (ted.getTimeDuration() != null) { try { properties.put("timeduration", ((FormalExpression) ted.getTimeDuration()).getBody()); } catch (Exception e) { _logger.info("Could not find timeduration for: " + ted); } } if (ted.getTimeCycle() != null) { try { properties.put("timecycle", ((FormalExpression) ted.getTimeCycle()).getBody()); if (((FormalExpression) ted.getTimeCycle()).getLanguage() != null) { properties.put("timecyclelanguage", ((FormalExpression) ted.getTimeCycle()).getLanguage()); } } catch (Exception e) { _logger.info("Could not find timecycle for: " + ted); } } } else if (ed instanceof SignalEventDefinition) { if (((SignalEventDefinition) ed).getSignalRef() != null) { // find signal with the corresponding id boolean foundSignalRef = false; List<RootElement> rootElements = def.getRootElements(); for (RootElement re : rootElements) { if (re instanceof Signal) { if (re.getId().equals(((SignalEventDefinition) ed).getSignalRef())) { properties.put("signalref", ((Signal) re).getName()); foundSignalRef = true; } } } if (!foundSignalRef) { properties.put("signalref", ""); } } else { properties.put("signalref", ""); } } else if (ed instanceof ErrorEventDefinition) { if (((ErrorEventDefinition) ed).getErrorRef() != null && ((ErrorEventDefinition) ed).getErrorRef().getErrorCode() != null) { properties.put("errorref", ((ErrorEventDefinition) ed).getErrorRef().getErrorCode()); } else { properties.put("errorref", ""); } } else if (ed instanceof ConditionalEventDefinition) { try { FormalExpression conditionalExp = (FormalExpression) ((ConditionalEventDefinition) ed) .getCondition(); if (conditionalExp.getBody() != null) { properties.put("conditionexpression", conditionalExp.getBody()); } if (conditionalExp.getLanguage() != null) { String languageVal = conditionalExp.getLanguage(); if (languageVal.equals("http://www.jboss.org/drools/rule")) { properties.put("conditionlanguage", "drools"); } else if (languageVal.equals("http://www.mvel.org/2.0")) { properties.put("conditionlanguage", "mvel"); } else { // default to drools properties.put("conditionlanguage", "drools"); } } } catch (Exception e) { _logger.info("Could not find conditionexpression for: " + ed); } } else if (ed instanceof EscalationEventDefinition) { if (((EscalationEventDefinition) ed).getEscalationRef() != null) { Escalation esc = ((EscalationEventDefinition) ed).getEscalationRef(); if (esc.getEscalationCode() != null && esc.getEscalationCode().length() > 0) { properties.put("escalationcode", esc.getEscalationCode()); } else { properties.put("escalationcode", ""); } } } else if (ed instanceof MessageEventDefinition) { setMessageRefProperties(properties, ((MessageEventDefinition) ed).getMessageRef()); } else if (ed instanceof CompensateEventDefinition) { if (((CompensateEventDefinition) ed).getActivityRef() != null) { Activity act = ((CompensateEventDefinition) ed).getActivityRef(); properties.put("activityref", act.getName()); } } } }
From source file:org.kie.workbench.common.stunner.bpmn.backend.legacy.Bpmn2JsonMarshaller.java
private void setCatchEventProperties(CatchEvent event, Map<String, Object> properties, Definitions def) { if (event.getOutputSet() != null) { List<DataOutput> dataOutputs = event.getOutputSet().getDataOutputRefs(); StringBuffer doutbuff = new StringBuffer(); for (DataOutput dout : dataOutputs) { doutbuff.append(dout.getName()); String dtype = getAnyAttributeValue(dout, "dtype"); if (dtype != null && !dtype.isEmpty()) { doutbuff.append(":").append(dtype); }// w w w. j a v a 2 s . c om doutbuff.append(","); } if (doutbuff.length() > 0) { doutbuff.setLength(doutbuff.length() - 1); } String dataoutput = doutbuff.toString(); properties.put(DATAOUTPUT, dataoutput); List<DataOutputAssociation> outputAssociations = event.getDataOutputAssociation(); StringBuffer doutassociationbuff = new StringBuffer(); for (DataOutputAssociation doa : outputAssociations) { String doaName = ((DataOutput) doa.getSourceRef().get(0)).getName(); if (doaName != null && doaName.length() > 0) { doutassociationbuff.append("[dout]" + ((DataOutput) doa.getSourceRef().get(0)).getName()); doutassociationbuff.append("->"); doutassociationbuff.append(doa.getTargetRef().getId()); doutassociationbuff.append(","); } } if (doutassociationbuff.length() > 0) { doutassociationbuff.setLength(doutassociationbuff.length() - 1); } String assignments = doutassociationbuff.toString(); properties.put(DATAOUTPUTASSOCIATIONS, assignments); setAssignmentsInfoProperty(null, null, dataoutput, null, assignments, properties); } // event definitions List<EventDefinition> eventdefs = event.getEventDefinitions(); for (EventDefinition ed : eventdefs) { if (ed instanceof TimerEventDefinition) { TimerEventDefinition ted = (TimerEventDefinition) ed; if (ted.getTimeDate() != null) { properties.put(TIMEDATE, ((FormalExpression) ted.getTimeDate()).getBody()); } if (ted.getTimeDuration() != null) { properties.put(TIMEDURATION, ((FormalExpression) ted.getTimeDuration()).getBody()); } if (ted.getTimeCycle() != null) { properties.put(TIMECYCLE, ((FormalExpression) ted.getTimeCycle()).getBody()); if (((FormalExpression) ted.getTimeCycle()).getLanguage() != null) { properties.put(TIMECYCLELANGUAGE, ((FormalExpression) ted.getTimeCycle()).getLanguage()); } } } else if (ed instanceof SignalEventDefinition) { if (((SignalEventDefinition) ed).getSignalRef() != null) { // find signal with the corresponding id boolean foundSignalRef = false; List<RootElement> rootElements = def.getRootElements(); for (RootElement re : rootElements) { if (re instanceof Signal) { if (re.getId().equals(((SignalEventDefinition) ed).getSignalRef())) { properties.put("signalref", ((Signal) re).getName()); foundSignalRef = true; } } } if (!foundSignalRef) { properties.put(SIGNALREF, ""); } } else { properties.put(SIGNALREF, ""); } } else if (ed instanceof ErrorEventDefinition) { if (((ErrorEventDefinition) ed).getErrorRef() != null && ((ErrorEventDefinition) ed).getErrorRef().getErrorCode() != null) { properties.put(ERRORREF, ((ErrorEventDefinition) ed).getErrorRef().getErrorCode()); } else { properties.put(ERRORREF, ""); } } else if (ed instanceof ConditionalEventDefinition) { FormalExpression conditionalExp = (FormalExpression) ((ConditionalEventDefinition) ed) .getCondition(); if (conditionalExp.getBody() != null) { properties.put(CONDITIONEXPRESSION, conditionalExp.getBody().replaceAll("\n", "\\\\n")); } if (conditionalExp.getLanguage() != null) { String languageVal = conditionalExp.getLanguage(); if (languageVal.equals("http://www.jboss.org/drools/rule")) { properties.put(CONDITIONLANGUAGE, "drools"); } else if (languageVal.equals("http://www.mvel.org/2.0")) { properties.put(CONDITIONLANGUAGE, "mvel"); } else { // default to drools properties.put(CONDITIONLANGUAGE, "drools"); } } } else if (ed instanceof EscalationEventDefinition) { if (((EscalationEventDefinition) ed).getEscalationRef() != null) { Escalation esc = ((EscalationEventDefinition) ed).getEscalationRef(); if (esc.getEscalationCode() != null && esc.getEscalationCode().length() > 0) { properties.put(ESCALATIONCODE, esc.getEscalationCode()); } else { properties.put(ESCALATIONCODE, ""); } } } else if (ed instanceof MessageEventDefinition) { if (((MessageEventDefinition) ed).getMessageRef() != null) { Message msg = ((MessageEventDefinition) ed).getMessageRef(); properties.put(MESSAGEREF, msg.getId()); } } else if (ed instanceof CompensateEventDefinition) { if (((CompensateEventDefinition) ed).getActivityRef() != null) { Activity act = ((CompensateEventDefinition) ed).getActivityRef(); properties.put(ACTIVITYREF, act.getName()); } } } }
From source file:org.jbpm.designer.bpmn2.impl.Bpmn2JsonMarshaller.java
private void setCatchEventProperties(CatchEvent event, Map<String, Object> properties, Definitions def) { if (event.getOutputSet() != null) { List<DataOutput> dataOutputs = event.getOutputSet().getDataOutputRefs(); StringBuffer doutbuff = new StringBuffer(); for (DataOutput dout : dataOutputs) { doutbuff.append(dout.getName()); String dtype = getAnyAttributeValue(dout, "dtype"); if (dtype != null && !dtype.isEmpty()) { doutbuff.append(":").append(dtype); }//from w ww.j a va2 s . com doutbuff.append(","); } if (doutbuff.length() > 0) { doutbuff.setLength(doutbuff.length() - 1); } properties.put("dataoutput", doutbuff.toString()); List<DataOutputAssociation> outputAssociations = event.getDataOutputAssociation(); StringBuffer doutassociationbuff = new StringBuffer(); for (DataOutputAssociation doa : outputAssociations) { String doaName = ((DataOutput) doa.getSourceRef().get(0)).getName(); if (doaName != null && doaName.length() > 0) { doutassociationbuff.append("[dout]" + updateDataInputOutputDashes(((DataOutput) doa.getSourceRef().get(0)).getName())); doutassociationbuff.append("->"); doutassociationbuff.append(doa.getTargetRef().getId()); doutassociationbuff.append(","); } } if (doutassociationbuff.length() > 0) { doutassociationbuff.setLength(doutassociationbuff.length() - 1); } properties.put("dataoutputassociations", doutassociationbuff.toString()); } // event definitions List<EventDefinition> eventdefs = getEventDefinitionsForEvent(event); for (EventDefinition ed : eventdefs) { if (ed instanceof TimerEventDefinition) { TimerEventDefinition ted = (TimerEventDefinition) ed; if (ted.getTimeDate() != null) { try { properties.put("timedate", ((FormalExpression) ted.getTimeDate()).getBody()); } catch (Exception e) { _logger.info("Could not find timedate for : " + ted); } } if (ted.getTimeDuration() != null) { try { properties.put("timeduration", ((FormalExpression) ted.getTimeDuration()).getBody()); } catch (Exception e) { _logger.info("Could not find timeduration for : " + ted); } } if (ted.getTimeCycle() != null) { try { properties.put("timecycle", ((FormalExpression) ted.getTimeCycle()).getBody()); if (((FormalExpression) ted.getTimeCycle()).getLanguage() != null) { properties.put("timecyclelanguage", ((FormalExpression) ted.getTimeCycle()).getLanguage()); } } catch (Exception e) { _logger.info("Could not find timecycle for : " + ted); } } } else if (ed instanceof SignalEventDefinition) { if (((SignalEventDefinition) ed).getSignalRef() != null) { // find signal with the corresponding id boolean foundSignalRef = false; List<RootElement> rootElements = def.getRootElements(); for (RootElement re : rootElements) { if (re instanceof Signal) { if (re.getId().equals(((SignalEventDefinition) ed).getSignalRef())) { properties.put("signalref", ((Signal) re).getName()); foundSignalRef = true; } } } if (!foundSignalRef) { properties.put("signalref", ""); } } else { properties.put("signalref", ""); } } else if (ed instanceof ErrorEventDefinition) { if (((ErrorEventDefinition) ed).getErrorRef() != null && ((ErrorEventDefinition) ed).getErrorRef().getErrorCode() != null) { properties.put("errorref", ((ErrorEventDefinition) ed).getErrorRef().getErrorCode()); } else { properties.put("errorref", ""); } } else if (ed instanceof ConditionalEventDefinition) { try { FormalExpression conditionalExp = (FormalExpression) ((ConditionalEventDefinition) ed) .getCondition(); if (conditionalExp.getBody() != null) { properties.put("conditionexpression", conditionalExp.getBody().replaceAll("\n", "\\\\n")); } if (conditionalExp.getLanguage() != null) { String languageVal = conditionalExp.getLanguage(); if (languageVal.equals("http://www.jboss.org/drools/rule")) { properties.put("conditionlanguage", "drools"); } else if (languageVal.equals("http://www.mvel.org/2.0")) { properties.put("conditionlanguage", "mvel"); } else { // default to drools properties.put("conditionlanguage", "drools"); } } } catch (Exception e) { _logger.info("Could not find conditional expression for: " + ed); } } else if (ed instanceof EscalationEventDefinition) { if (((EscalationEventDefinition) ed).getEscalationRef() != null) { Escalation esc = ((EscalationEventDefinition) ed).getEscalationRef(); if (esc.getEscalationCode() != null && esc.getEscalationCode().length() > 0) { properties.put("escalationcode", esc.getEscalationCode()); } else { properties.put("escalationcode", ""); } } } else if (ed instanceof MessageEventDefinition) { setMessageRefProperties(properties, ((MessageEventDefinition) ed).getMessageRef()); } else if (ed instanceof CompensateEventDefinition) { if (((CompensateEventDefinition) ed).getActivityRef() != null) { Activity act = ((CompensateEventDefinition) ed).getActivityRef(); properties.put("activityref", act.getName()); } } } // custom SLA due date marshalCustomSLADueDateMetadata(event, properties); }
From source file:com.pureinfo.studio.db.txt2SRM.impl.SchoolSCITxtImportRunner.java
/** * return sql states if no properties set return null * // w w w.j a va 2 s.c o m * @param _sNewObj * @param _sStrSQL * @param _sIsToTemp */ private String getSqlStrBuffer(DolphinObject _newObj, String _sStrSQL, boolean _bIsToTemp) { StringBuffer sbuff = null; boolean bStringProperty; if (_sStrSQL.length() > 0) { StringTokenizer st = new StringTokenizer(_sStrSQL, ",", false); // if (_bIsToTemp) { // sbuff = new StringBuffer("select * from {this}0 where "); // } // else { // sbuff = new StringBuffer("select * from {this} where "); // } sbuff = new StringBuffer(); try { String sValueWhole, sValue, sTableRowValue; while (st.hasMoreElements()) { sValueWhole = (String) st.nextElement(); sValue = sValueWhole.substring(0, sValueWhole.indexOf("-")); sTableRowValue = sValueWhole.substring(sValueWhole.indexOf("-") + 1); if (_newObj.getProperty(sValue) != null) { bStringProperty = _newObj.getProperty(sValue) instanceof String || _newObj.getProperty(sValue) instanceof Date; if ((bStringProperty && _newObj.getPropertyAsString(sValue).trim().length() > 0) || (!bStringProperty)) { if (sbuff.length() > 0) { sbuff.append(" and "); } sbuff.append(sTableRowValue); sbuff.append('='); if (bStringProperty) sbuff.append('\''); String sPropertyValue = _newObj.getPropertyAsString(sValue); sPropertyValue = StrUtil.escapeEncode(sPropertyValue); sPropertyValue = StrUtil.sqlEncode(sPropertyValue); sPropertyValue = removeBlank(sPropertyValue); sbuff.append(sPropertyValue); if (bStringProperty) sbuff.append('\''); } } } return sbuff.length() > 0 ? sbuff.toString() : null; } finally { sbuff.setLength(0); } } return null; }
From source file:hudson.plugins.dimensionsscm.CheckOutAPITask.java
public Boolean execute(File area, VirtualChannel channel) throws IOException { boolean bRet = true; try {/*from w ww. j ava 2 s . c o m*/ StringBuffer cmdOutput = new StringBuffer(); FilePath wa = new FilePath(area); // Emulate SVN plugin // - if workspace exists and it is not managed by this project, blow it away // if (bFreshBuild) { if (listener.getLogger() != null) { listener.getLogger().println( "[DIMENSIONS] Checking out a fresh workspace because this project has not been built before..."); listener.getLogger().flush(); } } if (wa.exists() && (isDelete || bFreshBuild)) { Logger.Debug("Deleting '" + wa.toURI() + "'..."); listener.getLogger().println("[DIMENSIONS] Removing '" + wa.toURI() + "'..."); listener.getLogger().flush(); wa.deleteContents(); } String baseline = myResolver.resolve("DM_BASELINE"); String requests = myResolver.resolve("DM_REQUEST"); if (baseline != null) { baseline = baseline.trim(); baseline = baseline.toUpperCase(); } if (requests != null) { requests = requests.replaceAll(" ", ""); requests = requests.toUpperCase(); } Logger.Debug("Extra parameters - " + baseline + " " + requests); String cmdLog = null; if (baseline != null && baseline.length() == 0) baseline = null; if (requests != null && requests.length() == 0) requests = null; if (listener.getLogger() != null) { if (requests != null) listener.getLogger().println("[DIMENSIONS] Checking out request(s) \"" + requests + "\" - ignoring project folders..."); else if (baseline != null) listener.getLogger().println("[DIMENSIONS] Checking out baseline \"" + baseline + "\"..."); else listener.getLogger().println("[DIMENSIONS] Checking out project \"" + projectId + "\"..."); listener.getLogger().flush(); } if (version == 10 && requests != null) { String[] requestsProcess = requests.split(","); if (requestsProcess.length == 0) { requestsProcess[0] = requests; } listener.getLogger().println( "[DIMENSIONS] Defaulting to read-only permissions as this is the only available mode..."); for (int xx = 0; xx < requestsProcess.length; xx++) { if (!bRet) break; String folderN = "/"; File fileName = new File(folderN); FilePath dname = new FilePath(fileName); String reqId = requestsProcess[xx]; Logger.Debug("Checking out '" + folderN + "'..."); // Checkout the folder bRet = dmSCM.checkout(key, projectId, dname, wa, cmdOutput, baseline, reqId, isRevert, isExpand, isNoMetadata, "DEFAULT"); Logger.Debug("SCM checkout returned " + bRet); if (!bRet && isForce) bRet = true; if (cmdLog == null) cmdLog = "\n"; cmdLog += cmdOutput; cmdOutput.setLength(0); cmdLog += "\n"; } } else { // Iterate through the project folders and process them in Dimensions for (int ii = 0; ii < folders.length; ii++) { if (!bRet) break; String folderN = folders[ii]; File fileName = new File(folderN); FilePath dname = new FilePath(fileName); Logger.Debug("Checking out '" + folderN + "'..."); // Checkout the folder bRet = dmSCM.checkout(key, projectId, dname, wa, cmdOutput, baseline, requests, isRevert, isExpand, isNoMetadata, permissions); Logger.Debug("SCM checkout returned " + bRet); if (!bRet && isForce) bRet = true; if (cmdLog == null) cmdLog = "\n"; cmdLog += cmdOutput; cmdOutput.setLength(0); cmdLog += "\n"; if (requests != null) break; } } if (cmdLog.length() > 0 && listener.getLogger() != null) { Logger.Debug("Found command output to log to the build logger"); listener.getLogger().println("[DIMENSIONS] (Note: Dimensions command output was - "); cmdLog = cmdLog.replaceAll("\n\n", "\n"); listener.getLogger().println(cmdLog.replaceAll("\n", "\n[DIMENSIONS] ") + ")"); listener.getLogger().flush(); } if (!bRet) { listener.getLogger() .println("[DIMENSIONS] =========================================================="); listener.getLogger() .println("[DIMENSIONS] The Dimensions checkout command returned a failure status."); listener.getLogger() .println("[DIMENSIONS] Please review the command output and correct any issues"); listener.getLogger().println("[DIMENSIONS] that may have been detected."); listener.getLogger() .println("[DIMENSIONS] =========================================================="); listener.getLogger().flush(); } } catch (Exception e) { String errMsg = e.getMessage(); if (errMsg == null) { errMsg = "An unknown error occurred. Please try the operation again."; } listener.fatalError("Unable to run checkout callout - " + errMsg); // e.printStackTrace(); //throw new IOException("Unable to run checkout callout - " + e.getMessage()); bRet = false; } return bRet; }
From source file:com.tremolosecurity.unison.proxy.auth.twitter.TwitterAuth.java
public void doGet(HttpServletRequest request, HttpServletResponse response, AuthStep as) throws IOException, ServletException { HttpSession session = ((HttpServletRequest) request).getSession(); HashMap<String, Attribute> authParams = (HashMap<String, Attribute>) session .getAttribute(ProxyConstants.AUTH_MECH_PARAMS); ConfigManager cfg = (ConfigManager) request.getAttribute(ProxyConstants.TREMOLO_CFG_OBJ); MyVDConnection myvd = cfg.getMyVD(); String consumerKey = authParams.get("consumerKey").getValues().get(0); String consumerSecret = authParams.get("consumerSecret").getValues().get(0); String accessToken = authParams.get("accessToken").getValues().get(0); String accessSecret = authParams.get("accessSecret").getValues().get(0); boolean linkToDirectory = Boolean.parseBoolean(authParams.get("linkToDirectory").getValues().get(0)); String noMatchOU = authParams.get("noMatchOU").getValues().get(0); String uidAttr = authParams.get("uidAttr").getValues().get(0); String lookupFilter = authParams.get("lookupFilter").getValues().get(0); //String userLookupClassName = authParams.get("userLookupClassName").getValues().get(0); UrlHolder holder = (UrlHolder) request.getAttribute(ProxyConstants.AUTOIDM_CFG); RequestHolder reqHolder = ((AuthController) session.getAttribute(ProxyConstants.AUTH_CTL)).getHolder(); URL reqURL = new URL(request.getRequestURL().toString()); String redirectURL = reqURL.getProtocol() + "://" + reqURL.getHost(); if (reqURL.getPort() != -1) { redirectURL += ":" + reqURL.getPort(); }//from w w w . j a v a 2 s .c o m String urlChain = holder.getUrl().getAuthChain(); AuthChainType act = holder.getConfig().getAuthChains().get(reqHolder.getAuthChainName()); AuthMechType amt = act.getAuthMech().get(as.getId()); String authMechName = amt.getName(); redirectURL += cfg.getAuthMechs().get(authMechName).getUri(); if (request.getParameter("oauth_verifier") == null) { BasicHttpClientConnectionManager bhcm = new BasicHttpClientConnectionManager( GlobalEntries.getGlobalEntries().getConfigManager().getHttpClientSocketRegistry()); RequestConfig rc = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build(); CloseableHttpClient http = HttpClients.custom().setConnectionManager(bhcm).setDefaultRequestConfig(rc) .build(); HttpPost post = new HttpPost("https://api.twitter.com/oauth/request_token"); this.signRequest(post, "", accessToken, accessSecret, consumerKey, consumerSecret); CloseableHttpResponse httpResp = http.execute(post); BufferedReader in = new BufferedReader(new InputStreamReader(httpResp.getEntity().getContent())); StringBuffer token = new StringBuffer(); String line = null; while ((line = in.readLine()) != null) { token.append(line); } httpResp.close(); bhcm.close(); System.err.println(token); List<NameValuePair> parsed = URLEncodedUtils.parse(token.toString(), Charsets.UTF_8); HashMap<String, String> accessTokens = new HashMap<String, String>(); for (NameValuePair nvp : parsed) { accessTokens.put(nvp.getName(), nvp.getValue()); } request.getSession().setAttribute("twitterAccessToken", accessTokens); StringBuffer b = new StringBuffer().append("https://api.twitter.com/oauth/authenticate?oauth_token=") .append(accessTokens.get("oauth_token")); response.sendRedirect(b.toString()); } else { String oauthVerifier = request.getParameter("oauth_verifier"); HashMap<String, String> accessTokens = (HashMap<String, String>) request.getSession() .getAttribute("twitterAccessToken"); BasicHttpClientConnectionManager bhcm = new BasicHttpClientConnectionManager( GlobalEntries.getGlobalEntries().getConfigManager().getHttpClientSocketRegistry()); RequestConfig rc = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build(); CloseableHttpClient http = HttpClients.custom().setConnectionManager(bhcm).setDefaultRequestConfig(rc) .build(); HttpUriRequest post = new HttpPost(); try { post = RequestBuilder.post().setUri(new java.net.URI("https://api.twitter.com/oauth/access_token")) .addParameter("oauth_verifier", oauthVerifier).build(); } catch (URISyntaxException e) { throw new ServletException("Could not create post request"); } this.signRequest(post, "oauth_verifier=" + oauthVerifier, accessTokens.get("oauth_token"), accessTokens.get("oauth_token_secret"), consumerKey, consumerSecret); CloseableHttpResponse httpResp = http.execute(post); BufferedReader in = new BufferedReader(new InputStreamReader(httpResp.getEntity().getContent())); StringBuffer token = new StringBuffer(); String line = null; while ((line = in.readLine()) != null) { token.append(line); } EntityUtils.consumeQuietly(httpResp.getEntity()); httpResp.close(); System.err.println(token); List<NameValuePair> parsed = URLEncodedUtils.parse(token.toString(), Charsets.UTF_8); HashMap<String, String> userTokens = new HashMap<String, String>(); for (NameValuePair nvp : parsed) { userTokens.put(nvp.getName(), nvp.getValue()); } request.getSession().setAttribute("twitterUserToken", accessTokens); HttpGet get = new HttpGet( "https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true"); this.signRequest(get, "", userTokens.get("oauth_token"), userTokens.get("oauth_token_secret"), consumerKey, consumerSecret); httpResp = http.execute(get); in = new BufferedReader(new InputStreamReader(httpResp.getEntity().getContent())); token.setLength(0); line = null; while ((line = in.readLine()) != null) { token.append(line); } EntityUtils.consumeQuietly(httpResp.getEntity()); httpResp.close(); System.err.println(token); httpResp.close(); bhcm.close(); Map attrs = com.cedarsoftware.util.io.JsonReader.jsonToMaps(token.toString()); if (!linkToDirectory) { loadUnlinkedUser(session, noMatchOU, uidAttr, act, attrs); as.setSuccess(true); } else { lookupUser(as, session, myvd, noMatchOU, uidAttr, lookupFilter, act, attrs); } String redirectToURL = request.getParameter("target"); if (redirectToURL != null && !redirectToURL.isEmpty()) { reqHolder.setURL(redirectToURL); } holder.getConfig().getAuthManager().nextAuth(request, response, session, false); } }
From source file:com.pureinfo.srm.product.action.Product3indexListAction.java
/** * @throws PureException/* w ww .ja va2s . co m*/ * @see com.pureinfo.ark.interaction.list.ISearchAction#getHeadTable() */ public String getHeadTable() throws PureException { // String sDeptId = request.getParameter("dp_department"); String sAudit = request.getParameter("audit"); String sProduct0Id = request.getParameter("Nproduct0Id"); int nAuditForm = request.getInt("dp_status", "", 0); StringBuffer sbuff = new StringBuffer(); try { String sHeadTable = super.getHeadTable(); if (sHeadTable != null) { sbuff.append(sHeadTable); } if (request.getBoolean("audit") || (!request.getBoolean("audit") && !isAddAuthor())) { sbuff.append("<tr><TD align=\"right\"> \n"); sbuff.append("<a href=\"../product/product-3index-choose-duplicate.jsp?audit=" + request.getBoolean("audit") + "\" title=\"\" target=\"_blank\"><font color = \"blue\">[]</font></a>"); sbuff.append(" "); int nBeginDateYear = this.getBeginYear(); sbuff.append("<SELECT name=\"beginDateYear\"> \n"); sbuff.append("<OPTION value=\"0\">" + SHOW_RANGE_MIN + "</OPTION>"); for (int i = SHOW_RANGE_MIN; i <= SHOW_RANGE_MAX; i++) { sbuff.append("<OPTION value=\"").append(i).append('"'); if (nBeginDateYear == i) { sbuff.append(" selected"); } sbuff.append('>').append(i).append("</OPTION>"); } sbuff.append("</SELECT>"); int nEndDateYear = this.getEndYear(); sbuff.append("<SELECT name=\"endDateYear\"> \n"); for (int i = SHOW_RANGE_MIN; i <= SHOW_RANGE_MAX; i++) { sbuff.append("<OPTION value=\"").append(i).append('"'); if (nEndDateYear == i) { sbuff.append(" selected"); } sbuff.append('>').append(i).append("</OPTION>"); } sbuff.append("</SELECT>"); // sbuff.append("(,)"); if (!request.getBoolean("audit")) { sbuff.append("<select name=\"dp_status\">"); sbuff.append("<option value=\"\"></option>"); sbuff.append("<option value=\""); sbuff.append(SRMConstants.PRODUCT_STATUS_AUDIT_WAIT1); sbuff.append("\""); if (SRMConstants.PRODUCT_STATUS_AUDIT_WAIT1 == nAuditForm) { sbuff.append(" selected"); } sbuff.append("></option>"); sbuff.append("<option value=\""); sbuff.append(SRMConstants.PRODUCT_STATUS_AUDIT_BACK1); sbuff.append("\""); if (SRMConstants.PRODUCT_STATUS_AUDIT_BACK1 == nAuditForm) { sbuff.append(" selected"); } sbuff.append("></option>"); sbuff.append("</select>"); sbuff.append("<input type=\"hidden\" name=\"dp_productForm\" value=\"") .append(ProductConstants.PRODUCT_FORM_3INDEX).append("\">"); sbuff.append("<input type=\"hidden\" name=\"audit\" value=\"").append(sAudit).append("\">"); sbuff.append("<input type=\"hidden\" name=\"Nproduct0Id\" value=\"").append(sProduct0Id) .append("\">"); } sbuff.append(SRMWebHelper .renderCountOfPage(request.getInt(SRMWebHelper.COUNT_OF_PAGE, "", 15))); sbuff.append("<input type=\"submit\" value=\"\">"); sbuff.append("</td></tr>"); } return sbuff.toString(); } finally { sbuff.setLength(0); } }
From source file:com.buildml.main.CliUtils.java
/** * Helper method for displaying a path and all it's children, called exclusively by * printFileSet()./* w ww.j a v a2s . co m*/ * * @param outStream The PrintStream on which to display paths. * @param pathSoFar This path's parent path as a string, complete with trailing "/". * @param buildStore The BuildStore in which these paths belong. * @param thisPathId The path to display (assuming it's in the filesToShow FileSet). * @param resultFileSet The set of files to be displayed (if null, show them all). * @param filterFileSet If not-null, used to filter which paths from resultFileSet * should be displayed (set to null to display everything). * @param showRoots Whether to show path roots. * @param showPkgs Whether to show the package names. */ private static void printFileSetHelper(PrintStream outStream, StringBuffer pathSoFar, IBuildStore buildStore, int thisPathId, FileSet resultFileSet, FileSet filterFileSet, boolean showRoots, boolean showPkgs) { IFileMgr fileMgr = buildStore.getFileMgr(); IPackageMgr pkgMgr = buildStore.getPackageMgr(); IPackageMemberMgr pkgMemberMgr = buildStore.getPackageMemberMgr(); IPackageRootMgr pkgRootMgr = buildStore.getPackageRootMgr(); /* StringBuilders for forming the package name and the root names */ StringBuilder pkgString = null; StringBuilder rootString = null; /* should this path be displayed? */ if (!shouldBeDisplayed(thisPathId, resultFileSet, filterFileSet)) { return; } /* fetch this path's name */ String baseName = fileMgr.getBaseName(thisPathId); /* get this path's list of children */ Integer children[] = fileMgr.getChildPaths(thisPathId); /* * Figure out whether this path has attached roots. */ String rootNames[] = null; if (showRoots) { rootNames = pkgRootMgr.getRootsAtPath(thisPathId); } /* * If we've been asked to display file packages, prepare the string to be printed. */ if (showPkgs) { pkgString = new StringBuilder(); /* fetch the file's package and scope */ PackageDesc pkgAndScopeId = pkgMemberMgr.getPackageOfMember(IPackageMemberMgr.TYPE_FILE, thisPathId); if (pkgAndScopeId == null) { pkgString.append("Invalid file"); } /* if valid, fetch the human-readable names */ else { String pkgName = pkgMgr.getName(pkgAndScopeId.pkgId); String scopeName = pkgMemberMgr.getScopeName(pkgAndScopeId.pkgScopeId); /* if we can't fetch the text name of the package or scope... */ if (pkgName == null || scopeName == null) { pkgString.append("Invalid package"); } /* else, both names are valid, append them to the string */ else { pkgString.append(pkgName); pkgString.append(" - "); pkgString.append(scopeName); } } } /* * Does this path have a root (and we were asked to show roots)? * If so, prepare the string to be printed. */ if ((rootNames != null) && (rootNames.length > 0)) { rootString = new StringBuilder(); /* display a root name, or comma-separated root names */ rootString.append(" ("); for (int i = 0; i < rootNames.length; i++) { if (i != 0) { rootString.append(' '); } rootString.append('@'); rootString.append(rootNames[i]); } rootString.append(')'); } /* show packages, if requested. Truncate to a fixed column width. */ if (pkgString != null) { if (pkgString.length() > PACKAGE_NAME_WIDTH - 1) { pkgString.setLength(PACKAGE_NAME_WIDTH - 1); } outStream.print(pkgString); PrintUtils.indent(outStream, PACKAGE_NAME_WIDTH - pkgString.length()); } /* Display this path, prefixed by the absolute pathSoFar */ outStream.print(pathSoFar); outStream.print(baseName); /* show roots, if requested */ if (rootString != null) { outStream.print(rootString); } outStream.println(); /* if there are children, call ourselves recursively to display them */ if (children.length != 0) { /* append this path onto the pathSoFar, since it'll become the pathSoFar for each child */ int pathSoFarLen = pathSoFar.length(); pathSoFar.append(baseName); if (baseName.charAt(0) != '/') { pathSoFar.append('/'); } /* display each of the children */ for (int i = 0; i < children.length; i++) { printFileSetHelper(outStream, pathSoFar, buildStore, children[i], resultFileSet, filterFileSet, showRoots, showPkgs); } /* remove our base name from the pathSoFar, so our caller sees the correct value again */ pathSoFar.setLength(pathSoFarLen); } }
From source file:com.vladium.emma.report.html.ReportGenerator.java
private void embedSrcFile(final SrcFileItem item, final HTMLDocument page, final IntObjectMap /* line num:int->anchor name:String */ anchorMap, final SourcePathCache cache) { if ($assert.ENABLED) { $assert.ASSERT(item != null, "null input: item"); $assert.ASSERT(page != null, "null input: page"); }/*from w ww . j ava 2s .c om*/ final String fileName = item.getName(); if ($assert.ENABLED) $assert.ASSERT(fileName.endsWith(".java"), "cache only handles .java extensions"); // TODO: should I keep VM names in package items? final String packageVMName = ((PackageItem) item.getParent()).getVMName(); boolean success = false; final HTMLTable srcTable = new HTMLTable("100%", null, null, "0"); if (cache != null) // TODO: do this check earlier, in outer scope { srcTable.setClass(CSS_SOURCE); final File srcFile = cache.find(packageVMName, fileName); if (srcFile != null) { BufferedReader in = null; try { in = new BufferedReader(new FileReader(srcFile), IO_BUF_SIZE); final boolean markupCoverage = m_hasLineNumberInfo; final int unitsType = m_settings.getUnitsType(); IntObjectMap /* line num:int -> SrcFileItem.LineCoverageData */ lineCoverageMap = null; StringBuffer tooltipBuffer = null; if (markupCoverage) { lineCoverageMap = item.getLineCoverage(); $assert.ASSERT(lineCoverageMap != null, "null: lineCoverageMap"); tooltipBuffer = new StringBuffer(64); } int l = 1; for (String line; (line = in.readLine()) != null; ++l) { final HTMLTable.IRow srcline = srcTable.newRow(); final HTMLTable.ICell lineNumCell = srcline.newCell(); lineNumCell.setClass(CSS_LINENUM); if (anchorMap != null) { final int adjustedl = l < SRC_LINE_OFFSET ? l : l + SRC_LINE_OFFSET; final String anchor = (String) anchorMap.get(adjustedl); if (anchor != null) { final IElement a = IElement.Factory.create(Tag.A); //a.getAttributes ().set (Attribute.ID, anchor); ID anchoring does not work in NS 4.0 a.getAttributes().set(Attribute.NAME, anchor); a.setText(Integer.toString(l), true); lineNumCell.add(a); } else { lineNumCell.setText(Integer.toString(l), true); } } else { lineNumCell.setText(Integer.toString(l), true); } final HTMLTable.ICell lineTxtCell = srcline.newCell(); lineTxtCell.setText(line.length() > 0 ? line : " ", true); if (markupCoverage) { final SrcFileItem.LineCoverageData lCoverageData = (SrcFileItem.LineCoverageData) lineCoverageMap .get(l); if (lCoverageData != null) { switch (lCoverageData.m_coverageStatus) { case SrcFileItem.LineCoverageData.LINE_COVERAGE_ZERO: srcline.setClass(CSS_COVERAGE_ZERO); break; case SrcFileItem.LineCoverageData.LINE_COVERAGE_PARTIAL: { srcline.setClass(CSS_COVERAGE_PARTIAL); if (USE_LINE_COVERAGE_TOOLTIPS) { tooltipBuffer.setLength(0); final int[] coverageRatio = lCoverageData.m_coverageRatio[unitsType]; final int d = coverageRatio[0]; final int n = coverageRatio[1]; m_format.format((double) n / d, tooltipBuffer, m_fieldPosition); tooltipBuffer.append(" line coverage ("); tooltipBuffer.append(n); tooltipBuffer.append(" out of "); tooltipBuffer.append(d); switch (unitsType) { case IItemAttribute.UNITS_COUNT: tooltipBuffer.append(" basic blocks)"); break; case IItemAttribute.UNITS_INSTR: tooltipBuffer.append(" instructions)"); break; } // [Opera does not display TITLE tooltios on <TR> elements] lineNumCell.getAttributes().set(Attribute.TITLE, tooltipBuffer.toString()); lineTxtCell.getAttributes().set(Attribute.TITLE, tooltipBuffer.toString()); } } break; case SrcFileItem.LineCoverageData.LINE_COVERAGE_COMPLETE: srcline.setClass(CSS_COVERAGE_COMPLETE); break; default: $assert.ASSERT(false, "invalid line coverage status: " + lCoverageData.m_coverageStatus); } // end of switch } } } success = true; } catch (Throwable t) { t.printStackTrace(System.out); // TODO: logging success = false; } finally { if (in != null) try { in.close(); } catch (Throwable ignore) { } in = null; } } } if (!success) { srcTable.setClass(CSS_INVISIBLE_TABLE); final HTMLTable.IRow row = srcTable.newTitleRow(); row.newCell().setText("[source file '" + Descriptors.combineVMName(packageVMName, fileName) + "' not found in sourcepath]", false); } page.add(srcTable); }