/** * Get/Put Error Info in String * * @param ctx context * @param errorsOnly if true errors otherwise log * @return error info */ public String getErrorInfo(Properties ctx, boolean errorsOnly) { checkContext(); StringBuffer sb = new StringBuffer(); // if (errorsOnly) { LinkedList<LogRecord[]> m_history = (LinkedList<LogRecord[]>) Env.getCtx().get(HISTORY_KEY); for (int i = 0; i < m_history.size(); i++) { sb.append("-------------------------------\n"); LogRecord[] records = (LogRecord[]) m_history.get(i); for (int j = 0; j < records.length; j++) { LogRecord record = records[j]; sb.append(getFormatter().format(record)); } } } else { LinkedList<LogRecord> m_logs = (LinkedList<LogRecord>) Env.getCtx().get(LOGS_KEY); for (int i = 0; i < m_logs.size(); i++) { LogRecord record = (LogRecord) m_logs.get(i); sb.append(getFormatter().format(record)); } } sb.append("\n"); CLogMgt.getInfo(sb); CLogMgt.getInfoDetail(sb, ctx); // return sb.toString(); } // getErrorInfo
/** * Test * * @param args ignored */ public static void main(String[] args) { Adempiere.startupEnvironment(false); CLogMgt.setLevel(Level.CONFIG); ColumnEncryption columnEncryption = new ColumnEncryption(); int processId = 328; // AD_ColumnEncryption int columnId = 417; // AD_User - Password Env.setContext(Env.getCtx(), I_AD_Column.COLUMNNAME_AD_Column_ID, columnId); MPInstance instance; MPInstancePara instanceParameters; instance = new MPInstance(Env.getCtx(), processId, columnId); instance.saveEx(); instanceParameters = new MPInstancePara(instance, 10); instanceParameters.setParameter(I_AD_Column.COLUMNNAME_IsEncrypted, true); instanceParameters.saveEx(); instanceParameters = new MPInstancePara(instance, 20); instanceParameters.setParameter("ChangeSetting", true); instanceParameters.saveEx(); ProcessInfo pi = new ProcessInfo("AD_ColumnEncryption", processId); pi.setRecord_ID(instance.getRecord_ID()); pi.setAD_PInstance_ID(instance.getAD_PInstance_ID()); pi.setAD_Client_ID(0); pi.setAD_User_ID(100); columnEncryption.startProcess(Env.getCtx(), pi, null); /*List<MUser> users = new Query(Env.getCtx(), I_AD_User.Table_Name , "Password IS NOT NULL", null).list(); for (MUser user : users) { user.setPassword(user.getPassword()); user.saveEx(); }*/ processId = 53259; // Convert password to hashed pi = new ProcessInfo("AD_User_HashPassword", processId); pi.setAD_Client_ID(0); pi.setAD_User_ID(100); HashPasswords process = new HashPasswords(); process.startProcess(Env.getCtx(), pi, null); }