IDEMPIERE-3824 Implement apply packin from folder from command line / improve error messaging and rollback on error
This commit is contained in:
parent
db714f918e
commit
3456ab5b6b
|
@ -32,6 +32,7 @@ import org.compiere.Adempiere;
|
|||
import org.compiere.model.MPInstance;
|
||||
import org.compiere.process.ProcessCall;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.process.ProcessInfoUtil;
|
||||
import org.compiere.util.CLogMgt;
|
||||
import org.compiere.util.Env;
|
||||
import org.eclipse.equinox.app.IApplication;
|
||||
|
@ -76,14 +77,19 @@ public class PackInFolderApplication implements IApplication {
|
|||
instance.createParameter(10, "Folder", directory);
|
||||
pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
|
||||
ProcessCall process = Core.getProcess("org.adempiere.pipo2.PackInFolder");
|
||||
process.startProcess(ctx, pi, null);
|
||||
boolean success = process.startProcess(ctx, pi, null);
|
||||
ProcessInfoUtil.setLogFromDB(pi);
|
||||
StringBuilder msgout = new StringBuilder("Process=").append(pi.getTitle())
|
||||
.append(" Error=").append(pi.isError()).append(" Summary=")
|
||||
.append(pi.getSummary());
|
||||
.append("\n Error=").append(pi.isError())
|
||||
.append("\n Summary=").append(pi.getSummary())
|
||||
.append("\n Logs=\n").append(pi.getLogInfo(false).replaceAll("<br>", "\n"));
|
||||
System.out.println(msgout.toString());
|
||||
if (!success)
|
||||
return new Integer(1);
|
||||
} else {
|
||||
System.out.println("Apply PackIn from Folder usage:");
|
||||
System.out.println("RUN_ApplyPackInFromFolder.sh folder");
|
||||
return new Integer(1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ public class PipoDictionaryService implements IDictionaryService {
|
|||
Trx.get(trxName, false).commit(true);
|
||||
if (logger.isLoggable(Level.INFO)) logger.info("commit " + trxName);
|
||||
} catch (Exception e) {
|
||||
Trx.get(trxName, false).rollback();
|
||||
adPackageImp.setP_Msg(e.getLocalizedMessage());
|
||||
packIn.getNotifier().addFailureLine(e.getLocalizedMessage());
|
||||
packIn.setSuccess(false);
|
||||
|
|
|
@ -159,6 +159,10 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack
|
|||
m_processInfo = processInfo;
|
||||
}
|
||||
|
||||
public ProcessInfo getProcessInfo() {
|
||||
return m_processInfo;
|
||||
}
|
||||
|
||||
public void setProcessUI(IProcessUI processUI) {
|
||||
m_processUI = processUI;
|
||||
};
|
||||
|
|
|
@ -169,7 +169,12 @@ public class PackInApplicationActivator extends AbstractActivator {
|
|||
currentFile = zipFile;
|
||||
if (!packIn(zipFile)) {
|
||||
// stop processing further packages if one fail
|
||||
addLog(Level.WARNING, "Failed application of " + zipFile);
|
||||
String msg = "Failed application of " + zipFile;
|
||||
addLog(Level.SEVERE, msg);
|
||||
if (getProcessInfo() != null) {
|
||||
getProcessInfo().setError(true);
|
||||
getProcessInfo().setSummary("@Error@: " + msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
addLog(Level.INFO, "Successful application of " + zipFile);
|
||||
|
|
Loading…
Reference in New Issue