/** * Execute Task locally and wait * * @param cmd command * @return execution info */ public String executeLocal(String cmd) { log.config(cmd); if (m_task != null && m_task.isAlive()) m_task.interrupt(); m_task = new Task(cmd); m_task.start(); StringBuffer sb = new StringBuffer(); while (true) { // Give it a bit of time try { Thread.sleep(500); } catch (InterruptedException ioe) { log.log(Level.SEVERE, cmd, ioe); } // Info to user sb.append(m_task.getOut()) .append("\n-----------\n") .append(m_task.getErr()) .append("\n-----------"); // Are we done? if (!m_task.isAlive()) break; } log.config("done"); return sb.toString(); } // executeLocal
/** * Validate User * * @param ldapURL provider url - e.g. ldap://dc.compiere.org * @param domain domain name = e.g. compiere.org * @param userName user name - e.g. jjanke * @param password password * @return true if validated with ldap */ public static boolean validate(String ldapURL, String domain, String userName, String password) { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); // ldap://dc.compiere.org env.put(Context.PROVIDER_URL, ldapURL); env.put(Context.SECURITY_AUTHENTICATION, "simple"); // [email protected] StringBuffer principal = new StringBuffer(userName).append("@").append(domain); env.put(Context.SECURITY_PRINCIPAL, principal.toString()); env.put(Context.SECURITY_CREDENTIALS, password); // try { // Create the initial context InitialLdapContext ctx = new InitialLdapContext(env, null); // DirContext ctx = new InitialDirContext(env); // Test - Get the attributes Attributes answer = ctx.getAttributes(""); // Print the answer if (false) dump(answer); } catch (AuthenticationException e) { log.info("Error: " + principal + " - " + e.getLocalizedMessage()); return false; } catch (Exception e) { log.log(Level.SEVERE, ldapURL + " - " + principal, e); return false; } log.info("OK: " + principal); return true; } // validate
/** * String Representation * * @return info */ @Override public String toString() { StringBuffer sb = new StringBuffer("MGoal["); sb.append(get_ID()) .append("-") .append(getName()) .append(",") .append(getGoalPerformance()) .append("]"); return sb.toString(); } // toString
/** * String Representation * * @return info */ @Override public String toString() { StringBuffer sb = new StringBuffer("MPeriod["); sb.append(get_ID()) .append("-") .append(getName()) .append(", ") .append(getStartDate()) .append("-") .append(getEndDate()) .append("]"); return sb.toString(); } // toString
/** * Get Changes as HTML string * * @return changes */ public String getChangesHTML() { StringBuffer sb = new StringBuffer(); getChangeHTML(sb, "Priority"); getChangeHTML(sb, "PriorityUser"); getChangeHTML(sb, "R_Category_ID"); getChangeHTML(sb, "R_Group_ID"); getChangeHTML(sb, "R_RequestType_ID"); getChangeHTML(sb, "R_Resolution_ID"); getChangeHTML(sb, "R_Status_ID"); getChangeHTML(sb, "SalesRep_ID"); getChangeHTML(sb, "Summary"); // // getChangeHTML(sb, "AD_Org_ID"); // always stored getChangeHTML(sb, "AD_Role_ID"); getChangeHTML(sb, "AD_User_ID"); getChangeHTML(sb, "C_Activity_ID"); getChangeHTML(sb, "C_BPartner_ID"); getChangeHTML(sb, "C_Invoice_ID"); getChangeHTML(sb, "C_Order_ID"); getChangeHTML(sb, "C_Payment_ID"); getChangeHTML(sb, "C_Project_ID"); getChangeHTML(sb, "DateNextAction"); getChangeHTML(sb, "IsEscalated"); getChangeHTML(sb, "IsInvoiced"); getChangeHTML(sb, "IsSelfService"); getChangeHTML(sb, "M_InOut_ID"); getChangeHTML(sb, "M_Product_ID"); getChangeHTML(sb, "A_Asset_ID"); if (sb.length() == 0) sb.append("./."); // Unicode check char[] chars = sb.toString().toCharArray(); sb = new StringBuffer(chars.length); for (char c : chars) { if (c > 255) sb.append("&#").append(c).append(";"); else sb.append(c); } return sb.toString(); } // getChangesHTML
/** * String Representation * * @return info */ @Override public String toString() { StringBuffer sb = new StringBuffer("MTask["); sb.append(get_ID()) .append("-") .append(getName()) .append(";Server=") .append(isServerProcess()) .append(";") .append(getOS_Command()) .append("]"); return sb.toString(); } // toString
/** * Fill the table using m_sql * * @param table table */ private static void tableLoad(MiniTable table) { // log.finest(m_sql + " - " + m_groupBy); String sql = MRole.getDefault() .addAccessSQL(m_sql.toString(), "tab", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO) + m_groupBy + m_orderBy; log.finest(sql); try { Statement stmt = DB.createStatement(); ResultSet rs = stmt.executeQuery(sql); table.loadTable(rs); stmt.close(); } catch (SQLException e) { log.log(Level.SEVERE, sql, e); } } // tableLoad
/** * String Representation incl. Result * * @return Scipt */ @Override public String toString() { StringBuffer sb = new StringBuffer(m_variable); sb.append(" { ").append(m_script).append(" } = ").append(getResult(true)); return sb.toString(); } // toString