package com.vci.server.bof.server.create; import org.apache.commons.lang3.StringUtils; import com.vci.common.log.ServerWithLog4j; import com.vci.common.utility.ObjectUtility; import com.vci.corba.common.data.VCIInvocationInfo; import com.vci.corba.omd.data.BusinessObject; import com.vci.corba.common.VCIError; import com.vci.server.base.persistence.dao.HibernateSessionFactory; import com.vci.server.base.utility.LogRecordUtil; import com.vci.server.bof.server.ServiceFacadeExecuteHelper; import com.vci.server.bof.service.BOFactoryServices; public class CreateBO extends ServiceFacadeExecuteHelper{ private static ServiceFacadeExecuteHelper instance = null; public static ServiceFacadeExecuteHelper getInstance() { if(instance == null) { instance = new CreateBO(); } return instance; } @Override protected Object doAction() throws Throwable { BusinessObject bo = params.getBo(); try { BOFactoryServices services = BOFactoryServices.getInstance(); if (bo.oid.trim().equals("")) { bo.oid = ObjectUtility.getNewObjectID36(); } if (bo.revisionid.trim().equals("")) { bo.revisionid = ObjectUtility.getNewObjectID36(); } if (bo.nameoid.trim().equals("")) { bo.nameoid = ObjectUtility.getNewObjectID36(); } BusinessObject currentBO = services.createBusinessObject(bo, params.isRevision(), params.isNewVersion()); //日志记录 // VCIInvocationInfo info = HibernateSessionFactory.getVciSessionInfo(); // String ip = "127.0.0.1"; // if(info!=null){ // ip = info.clientIPInfo == null||"".equals(info.clientIPInfo) ?"127.0.0.1":info.clientIPInfo; // } //recordLog(bo.creator, bo.btName, ip, "创建", bo.btName, StringUtils.isNotBlank(bo.name)?bo.name:(StringUtils.isNotBlank(bo.id)?bo.id:bo.oid), bo.oid); LogRecordUtil.writeGeneralSuccessLog(bo, "创建"); return currentBO; } catch (VCIError e) { throw this.getLocalString(e.code, e); } catch (Exception e) { //e.printStackTrace(); ServerWithLog4j.logger.error(e); throw this.getLocalString("P0010SOF-00001", e); } catch (Throwable t) { //t.printStackTrace(); ServerWithLog4j.logger.error(t); throw this.getLocalString("P0010SOF-00001", t); } } }