o2sword 5 лет назад
Родитель
Сommit
80f53d387d
14 измененных файлов с 591 добавлено и 147 удалено
  1. 33 0
      o2server/x_base_core_project/src/main/java/com/x/base/core/entity/enums/CommonStatus.java
  2. 0 1
      o2server/x_base_core_project/src/main/java/com/x/base/core/project/connection/ConnectionAction.java
  3. 5 1
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/input/ActionCover.java
  4. 14 9
      o2server/x_portal_assemble_designer/src/main/java/com/x/portal/assemble/designer/jaxrs/input/ActionCover.java
  5. 15 10
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/input/ActionCover.java
  6. 68 0
      o2server/x_program_center/src/main/java/com/x/program/center/Business.java
  7. 0 4
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionGet.java
  8. 143 0
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionInstallLogListPaging.java
  9. 242 9
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionInstallOrUpdate.java
  10. 0 11
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionListPaging.java
  11. 38 1
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/MarketAction.java
  12. 2 92
      o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/ActionDispatchResource.java
  13. 15 0
      o2server/x_program_center_core_entity/src/main/java/com/x/program/center/core/entity/InstallLog.java
  14. 16 9
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/input/ActionCover.java

+ 33 - 0
o2server/x_base_core_project/src/main/java/com/x/base/core/entity/enums/CommonStatus.java

@@ -0,0 +1,33 @@
+package com.x.base.core.entity.enums;
+
+/**
+ * 通用状态枚举类
+ */
+public enum CommonStatus {
+
+	VALID("1", "正常"), INVALID("0", "已删除");
+	private String value;
+	private String name;
+
+	private CommonStatus(String value, String name) {
+		this.value = value;
+		this.name = name;
+	}
+
+	public String getValue() {
+		return value;
+	}
+
+	public void setValue(String value) {
+		this.value = value == null ? null : value.trim();
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name == null ? null : name.trim();
+	}
+
+}

+ 0 - 1
o2server/x_base_core_project/src/main/java/com/x/base/core/project/connection/ConnectionAction.java

@@ -30,7 +30,6 @@ import org.apache.http.entity.mime.MultipartEntityBuilder;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.util.EntityUtils;
-import org.apache.mina.core.session.IoSession;
 
 public class ConnectionAction {
 

+ 5 - 1
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/input/ActionCover.java

@@ -53,7 +53,11 @@ class ActionCover extends BaseAction {
 		AppInfo appInfo = business.entityManagerContainer().find(wi.getId(), AppInfo.class);
 
 		if (null == appInfo) {
-			throw new ExceptionAppInfoNotExist(wi.getId());
+			//throw new ExceptionAppInfoNotExist(wi.getId());
+			appInfo = WrapCms.inCopier.copy(wi);
+			appInfo.setAppName(this.idleAppInfoName(business, appInfo.getAppName(), appInfo.getId()));
+			appInfo.setAppAlias(this.idleAppInfoAlias(business, appInfo.getAppAlias(), appInfo.getId()));
+			persistObjects.add(appInfo);
 		}
 
 		//2020年1月16日 O2LEE 保存栏目信息对应的配置支持信息JSON ---->start

+ 14 - 9
o2server/x_portal_assemble_designer/src/main/java/com/x/portal/assemble/designer/jaxrs/input/ActionCover.java

@@ -46,24 +46,27 @@ class ActionCover extends BaseAction {
 			Wo wo = new Wo();
 			Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
 			Business business = new Business(emc);
-			Portal portal = business.entityManagerContainer().find(wi.getId(), Portal.class);
-			if (null == portal) {
-				throw new ExceptionPortalNotExist(wi.getId());
-			}
-			if (!business.editable(effectivePerson, portal)) {
-				throw new ExceptionPortalAccessDenied(effectivePerson.getName(), portal.getName(), portal.getId());
-			}
 
-			this.cover(business, wi, portal);
+			Portal portal = this.cover(business, wi, effectivePerson);
 			wo.setId(portal.getId());
 			result.setData(wo);
 			return result;
 		}
 	}
 
-	private void cover(Business business, Wi wi, Portal portal) throws Exception {
+	private Portal cover(Business business, Wi wi, EffectivePerson effectivePerson) throws Exception {
 		List<JpaObject> persistObjects = new ArrayList<>();
 
+		Portal portal = business.entityManagerContainer().find(wi.getId(), Portal.class);
+		if (null == portal) {
+			portal = WrapPortal.inCopier.copy(wi);
+			portal.setName(this.idlePortalName(business, portal.getName(), portal.getId()));
+			portal.setAlias(this.idlePortalAlias(business, portal.getAlias(), portal.getId()));
+			persistObjects.add(portal);
+		}else if (!business.editable(effectivePerson, portal)) {
+			throw new ExceptionPortalAccessDenied(effectivePerson.getName(), portal.getName(), portal.getId());
+		}
+
 		for (WrapWidget _o : wi.getWidgetList()) {
 			Widget obj = business.entityManagerContainer().find(_o.getId(), Widget.class);
 			if (null != obj) {
@@ -147,6 +150,8 @@ class ActionCover extends BaseAction {
 		ApplicationCache.notify(Page.class);
 		ApplicationCache.notify(Widget.class);
 		ApplicationCache.notify(Portal.class);
+
+		return portal;
 	}
 
 	private <T extends JpaObject> String idleNameWithPortal(Business business, String portalId, String name,

+ 15 - 10
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/input/ActionCover.java

@@ -87,24 +87,27 @@ class ActionCover extends BaseAction {
 			Wo wo = new Wo();
 			Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
 			Business business = new Business(emc);
-			Application application = business.entityManagerContainer().find(wi.getId(), Application.class);
-			if (null == application) {
-				throw new ExceptionApplicationNotExist(wi.getId());
-			}
-			if (!business.editable(effectivePerson, application)) {
-				throw new ExceptionApplicationAccessDenied(effectivePerson.getName(), application.getName(),
-						application.getId());
-			}
-			this.cover(business, wi, application, effectivePerson);
+
+			Application application = this.cover(business, wi, effectivePerson);
 			wo.setId(application.getId());
 			result.setData(wo);
 			return result;
 		}
 	}
 
-	private void cover(Business business, Wi wi, Application application, EffectivePerson effectivePerson) throws Exception {
+	private Application cover(Business business, Wi wi, EffectivePerson effectivePerson) throws Exception {
 		List<JpaObject> persistObjects = new ArrayList<>();
 		List<JpaObject> removeObjects = new ArrayList<>();
+		Application application = business.entityManagerContainer().find(wi.getId(), Application.class);
+		if (null == application) {
+			application = WrapProcessPlatform.inCopier.copy(wi);
+			application.setName(this.idleApplicationName(business, application.getName(), application.getId()));
+			application.setAlias(this.idleApplicationAlias(business, application.getAlias(), application.getId()));
+			persistObjects.add(application);
+		}else if (!business.editable(effectivePerson, application)) {
+			throw new ExceptionApplicationAccessDenied(effectivePerson.getName(), application.getName(),
+					application.getId());
+		}
 		for (WrapForm _o : wi.getFormList()) {
 			Form form = business.entityManagerContainer().find(_o.getId(), Form.class);
 			if (null != form) {
@@ -328,6 +331,8 @@ class ActionCover extends BaseAction {
 		ApplicationCache.notify(Script.class);
 		ApplicationCache.notify(Process.class);
 		ApplicationCache.notify(Application.class);
+
+		return application;
 	}
 
 	private <T extends JpaObject, W extends JpaObject> List<T> orphanFormElement(Business business, List<W> list,

+ 68 - 0
o2server/x_program_center/src/main/java/com/x/program/center/Business.java

@@ -1,7 +1,12 @@
 package com.x.program.center;
 
 import com.x.base.core.project.config.Collect;
+import com.x.base.core.project.config.Nodes;
+import com.x.base.core.project.gson.XGsonBuilder;
 import com.x.base.core.project.http.TokenType;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+import com.x.base.core.project.tools.Crypto;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
@@ -13,11 +18,19 @@ import com.x.base.core.project.jaxrs.WrapBoolean;
 import com.x.program.center.factory.PersonFactory;
 import com.x.program.center.factory.UnitFactory;
 
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.net.Socket;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 public class Business {
 
+	private static Logger logger = LoggerFactory.getLogger(Business.class);
+
 	private EntityManagerContainer emc;
 
 	public Business(EntityManagerContainer emc) throws Exception {
@@ -145,4 +158,59 @@ public class Business {
 
 	}
 
+	public static List<String> dispatch(boolean asNew, String fileName, String filePath, byte[] bytes) throws Exception{
+		List<String> list = new ArrayList<>();
+		Nodes nodes = Config.nodes();
+		for (String node : nodes.keySet()){
+			boolean flag = false;
+
+			try (Socket socket = new Socket(node, nodes.get(node).nodeAgentPort())) {
+				socket.setKeepAlive(true);
+				socket.setSoTimeout(10000);
+				try (DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
+					 DataInputStream dis = new DataInputStream(socket.getInputStream())){
+					Map<String, Object> commandObject = new HashMap<>();
+					commandObject.put("command", "uploadResource:"+fileName);
+					commandObject.put("credential", Crypto.rsaEncrypt("o2@", Config.publicKey()));
+
+					Map<String, Object> param = new HashMap<>();
+					param.put("fileName", fileName);
+					param.put("asNew", asNew);
+					if(StringUtils.isNotEmpty(filePath)){
+						param.put("filePath", filePath);
+					}
+					commandObject.put("param", param);
+					dos.writeUTF(XGsonBuilder.toJson(commandObject));
+					dos.flush();
+					dos.writeInt(bytes.length);
+					dos.flush();
+
+					try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes)){
+						byte[] onceBytes = new byte[1024];
+						int length = 0;
+						while((length = bis.read(onceBytes, 0, onceBytes.length)) != -1) {
+							dos.write(onceBytes, 0, length);
+							dos.flush();
+						}
+					}
+
+					String result = dis.readUTF();
+					logger.print("socket dispatch resource {} to {}:{} result={}", fileName, node, nodes.get(node).nodeAgentPort(), result);
+					if("success".equals(result)){
+						flag = true;
+						list.add(node+":success");
+					}else{
+						list.add(node + ":failure");
+					}
+				}
+
+			} catch (Exception ex) {
+				list.add(node + ":failure-"+ex.getMessage());
+				logger.print("socket dispatch resource to {}:{} error={}", node, nodes.get(node).nodeAgentPort(), ex.getMessage());
+			}
+
+		}
+		return list;
+	}
+
 }

+ 0 - 4
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionGet.java

@@ -5,7 +5,6 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.project.annotation.FieldDescribe;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -19,9 +18,6 @@ class ActionGet extends BaseAction {
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-			if (effectivePerson.isAnonymous()) {
-				throw new ExceptionAccessDenied(effectivePerson);
-			}
 			ActionResult<Wo> result = new ActionResult<>();
 			Application app = emc.find(id, Application.class);
 			if (null == app) {

+ 143 - 0
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionInstallLogListPaging.java

@@ -0,0 +1,143 @@
+package com.x.program.center.jaxrs.market;
+
+import com.google.gson.JsonElement;
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.entity.JpaObject;
+import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.bean.WrapCopier;
+import com.x.base.core.project.bean.WrapCopierFactory;
+import com.x.base.core.project.gson.GsonPropertyObject;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.tools.DateTools;
+import com.x.base.core.project.tools.StringTools;
+import com.x.program.center.Business;
+import com.x.program.center.core.entity.InstallLog;
+import com.x.program.center.core.entity.InstallLog_;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Tuple;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.util.List;
+
+class ActionInstallLogListPaging extends BaseAction {
+
+	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, Integer page, Integer size, JsonElement jsonElement)
+			throws Exception {
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			Business business = new Business(emc);
+			ActionResult<List<Wo>> result = new ActionResult<>();
+			Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
+			Predicate p = this.toFilterPredicate(effectivePerson, business, wi);
+			List<Wo> wos = emc.fetchDescPaging(InstallLog.class, Wo.copier, p, page, size, InstallLog.createTime_FIELDNAME);
+			result.setData(wos);
+			result.setCount(emc.count(InstallLog.class, p));
+			return result;
+		}
+	}
+
+	private Predicate toFilterPredicate(EffectivePerson effectivePerson, Business business, Wi wi) throws Exception {
+		EntityManager em = business.entityManagerContainer().get(InstallLog.class);
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class);
+		Root<InstallLog> root = cq.from(InstallLog.class);
+		Predicate p = cb.conjunction();
+
+		if(StringUtils.isNotEmpty(wi.getName())){
+			String key = StringTools.escapeSqlLikeKey(wi.getName());
+			if (StringUtils.isNotEmpty(key)) {
+				p = cb.and(p,cb.like(root.get(InstallLog_.name), "%" + key + "%", StringTools.SQL_ESCAPE_CHAR));
+			}
+		}
+
+		if(StringUtils.isNotEmpty(wi.getStatus())){
+			p = cb.and(p, cb.equal(root.get(InstallLog_.status), wi.getStatus()));
+		}
+
+		if(StringUtils.isNotEmpty(wi.getCategory())){
+			p = cb.and(p, cb.equal(root.get(InstallLog_.category), wi.getCategory()));
+		}
+
+		if (DateTools.isDateTimeOrDate(wi.getStartTime())) {
+			p = cb.and(p, cb.greaterThan(root.get(InstallLog_.createTime), DateTools.parse(wi.getStartTime())));
+		}
+		if (DateTools.isDateTimeOrDate(wi.getEndTime())) {
+			p = cb.and(p, cb.lessThan(root.get(InstallLog_.createTime), DateTools.parse(wi.getEndTime())));
+		}
+		return p;
+	}
+
+	public class Wi extends GsonPropertyObject {
+
+		@FieldDescribe("名称")
+		private String name;
+
+		@FieldDescribe("分类")
+		private String category;
+
+		@FieldDescribe("状态:1(正常)|0(失效)")
+		private String status;
+
+		@FieldDescribe("开始时间yyyy-MM-dd HH:mm:ss")
+		private String startTime;
+
+		@FieldDescribe("结束时间yyyy-MM-dd HH:mm:ss")
+		private String endTime;
+
+		public String getName() {
+			return name;
+		}
+
+		public void setName(String name) {
+			this.name = name;
+		}
+
+		public String getCategory() {
+			return category;
+		}
+
+		public void setCategory(String category) {
+			this.category = category;
+		}
+
+		public String getStatus() {
+			return status;
+		}
+
+		public void setStatus(String status) {
+			this.status = status;
+		}
+
+		public String getStartTime() {
+			return startTime;
+		}
+
+		public void setStartTime(String startTime) {
+			this.startTime = startTime;
+		}
+
+		public String getEndTime() {
+			return endTime;
+		}
+
+		public void setEndTime(String endTime) {
+			this.endTime = endTime;
+		}
+	}
+
+	public static class Wo extends InstallLog {
+
+		private static final long serialVersionUID = -2553925573532406246L;
+
+		static WrapCopier<InstallLog, Wo> copier = WrapCopierFactory.wo(InstallLog.class, Wo.class,
+				JpaObject.singularAttributeField(InstallLog.class, true, true), null);
+
+
+	}
+
+}

+ 242 - 9
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionInstallOrUpdate.java

@@ -1,42 +1,275 @@
 package com.x.program.center.jaxrs.market;
 
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.entity.enums.CommonStatus;
+import com.x.base.core.project.*;
 import com.x.base.core.project.annotation.FieldDescribe;
-import com.x.base.core.project.bean.WrapCopier;
-import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.exception.ExceptionAccessDenied;
+import com.x.base.core.project.bean.NameValuePair;
+import com.x.base.core.project.config.Collect;
+import com.x.base.core.project.config.Config;
+import com.x.base.core.project.connection.CipherConnectionAction;
+import com.x.base.core.project.connection.ConnectionAction;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
+import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.jaxrs.WoId;
 import com.x.base.core.project.jaxrs.WrapBoolean;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+import com.x.base.core.project.tools.DefaultCharset;
+import com.x.base.core.project.tools.FileTools;
+import com.x.base.core.project.tools.JarTools;
+import com.x.base.core.project.tools.ListTools;
+import com.x.cms.core.entity.element.wrap.WrapCms;
+import com.x.portal.core.entity.wrap.WrapPortal;
+import com.x.processplatform.core.entity.element.wrap.WrapProcessPlatform;
+import com.x.program.center.Business;
+import com.x.program.center.ThisApplication;
+import com.x.program.center.WrapModule;
 import com.x.program.center.core.entity.Application;
-import com.x.program.center.core.entity.Attachment;
+import com.x.program.center.core.entity.InstallLog;
+import com.x.program.center.core.entity.wrap.WrapAgent;
+import com.x.program.center.core.entity.wrap.WrapInvoke;
+import com.x.program.center.core.entity.wrap.WrapServiceModule;
+import com.x.query.core.entity.wrap.WrapQuery;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
 
+import java.io.File;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
+import java.util.UUID;
 
 class ActionInstallOrUpdate extends BaseAction {
 
+	private static Logger logger = LoggerFactory.getLogger(ActionInstallOrUpdate.class);
+
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-			if (effectivePerson.isAnonymous()) {
-				throw new ExceptionAccessDenied(effectivePerson);
-			}
 			ActionResult<Wo> result = new ActionResult<>();
+			Business business = new Business(emc);
 			Application app = emc.find(id, Application.class);
 			if (null == app) {
 				throw new ExceptionEntityNotExist(id, Application.class);
 			}
-
+			logger.print("{}发起安装或更新应用:{}", effectivePerson.getDistinguishedName(), app.getName());
 			Wo wo = new Wo();
-			wo.setValue(true);
+			wo.setValue(false);
+			if(BooleanUtils.isTrue(Config.collect().getEnable())) {
+				String token = business.loginCollect();
+				if(StringUtils.isNotEmpty(token)){
+					byte[] bytes = ConnectionAction.getFile(Config.collect().url(Collect.ADDRESS_COLLECT_APPLICATION_DOWN),
+							ListTools.toList(new NameValuePair(Collect.COLLECT_TOKEN, token)));
+					if(bytes!=null){
+						WrapModule module = this.install(bytes);
+						if(module!=null) {
+							wo.setValue(true);
+							emc.beginTransaction(InstallLog.class);
+							InstallLog installLog = emc.find(id, InstallLog.class);
+							boolean exist = true;
+							if (installLog == null) {
+								installLog = new InstallLog();
+								installLog.setId(app.getId());
+								exist = false;
+							}
+							installLog.setName(app.getName());
+							installLog.setVersion(app.getVersion());
+							installLog.setCategory(app.getCategory());
+							installLog.setStatus(CommonStatus.VALID.getValue());
+							installLog.setData(gson.toJson(module));
+							installLog.setInstallPerson(effectivePerson.getDistinguishedName());
+							installLog.setInstallTime(new Date());
+							installLog.setUnInstallPerson(null);
+							installLog.setUnInstallTime(null);
+							if(!exist){
+								emc.persist(installLog);
+							}
+							emc.commit();
+						}
+					}
+				}
+			}
+
 			result.setData(wo);
 			return result;
 		}
 	}
 
+	private WrapModule install(byte[] bytes) throws Exception{
+		WrapModule module = null;
+		File tempFile = new File(Config.base(), "local/temp/install");
+		FileTools.forceMkdir(tempFile);
+		FileUtils.cleanDirectory(tempFile);
+		File zipFile = new File(tempFile.getAbsolutePath(), UUID.randomUUID().toString()+".zip");
+		FileUtils.writeByteArrayToFile(zipFile, bytes);
+		File dist = new File(tempFile.getAbsolutePath(), "data");
+		FileTools.forceMkdir(dist);
+		JarTools.unjar(zipFile, new ArrayList<>(), dist, true);
+
+		File[] files = dist.listFiles();
+		for(File file : files){
+			if(!file.isDirectory()){
+				if(file.getName().toLowerCase().endsWith(".xapp")){
+					String json = FileUtils.readFileToString(file, DefaultCharset.charset);
+					Gson gson = new Gson();
+					JsonElement jsonElement = gson.fromJson(json, JsonElement.class);
+					module = this.convertToWrapIn(jsonElement, WrapModule.class);
+					this.installModule(module);
+				}
+				if(file.getName().toLowerCase().endsWith(".zip")){
+					logger.print("开始安装静态资源");
+					try {
+						Business.dispatch(true, file.getName(), "", FileUtils.readFileToByteArray(file));
+					} catch (Exception e) {
+						logger.print("模块安装成功但静态资源安装失败:{}",e.getMessage());
+					}
+				}
+			}
+		}
+		return module;
+	}
+
+	private InstallWo installModule(WrapModule module) throws Exception{
+		InstallWo wo = new InstallWo();
+		logger.print("开始安装应用");
+		for (WrapProcessPlatform obj : module.getProcessPlatformList()) {
+			wo.getProcessPlatformList()
+					.add(ThisApplication.context().applications()
+							.putQuery(x_processplatform_assemble_designer.class,
+									Applications.joinQueryUri("input", "cover"), obj)
+							.getData(WoId.class).getId());
+			obj.setApplicationDictList(null);
+			obj.setFileList(null);
+			obj.setFormList(null);
+			obj.setProcessList(null);
+			obj.setScriptList(null);
+		}
+		for (WrapCms obj : module.getCmsList()) {
+			wo.getCmsList()
+					.add(ThisApplication.context().applications()
+							.putQuery(x_cms_assemble_control.class,
+									Applications.joinQueryUri("input", "cover"), obj)
+							.getData(WoId.class).getId());
+			obj.setAppDictList(null);
+			obj.setCategoryInfoList(null);
+			obj.setFileList(null);
+			obj.setFormList(null);
+			obj.setScriptList(null);
+		}
+		for (WrapPortal obj : module.getPortalList()) {
+			wo.getPortalList()
+					.add(ThisApplication.context().applications()
+							.putQuery(x_portal_assemble_designer.class,
+									Applications.joinQueryUri("input", "cover"), obj)
+							.getData(WoId.class).getId());
+			obj.setFileList(null);
+			obj.setPageList(null);
+			obj.setScriptList(null);
+			obj.setWidgetList(null);
+		}
+		if(module.getQueryList()!=null){
+			for (WrapQuery obj : module.getQueryList()) {
+				wo.getQueryList()
+						.add(ThisApplication.context().applications()
+								.putQuery(x_query_assemble_designer.class,
+										Applications.joinQueryUri("input", "cover"), obj)
+								.getData(WoId.class).getId());
+				obj.setRevealList(null);
+				obj.setViewList(null);
+				obj.setStatementList(null);
+				obj.setViewList(null);
+				obj.setTableList(null);
+			}
+		}
+
+		if(module.getServiceModuleList()!=null) {
+			for (WrapServiceModule obj : module.getServiceModuleList()) {
+				wo.getServiceModuleList()
+						.add(CipherConnectionAction.put(false,
+								Config.url_x_program_center_jaxrs("input", "cover"), obj)
+								.getData(WoId.class).getId());
+				if (obj.getAgentList() != null) {
+					for (WrapAgent agent : obj.getAgentList()) {
+						agent.setText(null);
+					}
+				}
+				if (obj.getInvokeList() != null) {
+					for(WrapInvoke invoke : obj.getInvokeList()){
+						invoke.setText(null);
+					}
+				}
+			}
+		}
+
+		return wo;
+	}
+
 	public static class Wo extends WrapBoolean {
 
 	}
+
+	public static class InstallWo extends GsonPropertyObject {
+
+		@FieldDescribe("流程应用")
+		private List<String> processPlatformList = new ArrayList<>();
+
+		@FieldDescribe("门户应用")
+		private List<String> portalList = new ArrayList<>();
+
+		@FieldDescribe("统计应用")
+		private List<String> queryList = new ArrayList<>();
+
+		@FieldDescribe("内容管理应用")
+		private List<String> cmsList = new ArrayList<>();
+
+		@FieldDescribe("服务管理应用")
+		private List<String> serviceModuleList = new ArrayList<>();
+
+		public List<String> getProcessPlatformList() {
+			return processPlatformList;
+		}
+
+		public void setProcessPlatformList(List<String> processPlatformList) {
+			this.processPlatformList = processPlatformList;
+		}
+
+		public List<String> getPortalList() {
+			return portalList;
+		}
+
+		public void setPortalList(List<String> portalList) {
+			this.portalList = portalList;
+		}
+
+		public List<String> getQueryList() {
+			return queryList;
+		}
+
+		public void setQueryList(List<String> queryList) {
+			this.queryList = queryList;
+		}
+
+		public List<String> getCmsList() {
+			return cmsList;
+		}
+
+		public void setCmsList(List<String> cmsList) {
+			this.cmsList = cmsList;
+		}
+
+		public List<String> getServiceModuleList() {
+			return serviceModuleList;
+		}
+
+		public void setServiceModuleList(List<String> serviceModuleList) {
+			this.serviceModuleList = serviceModuleList;
+		}
+	}
+
 }

+ 0 - 11
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionListPaging.java

@@ -88,9 +88,6 @@ class ActionListPaging extends BaseAction {
 		@FieldDescribe("分类")
 		private String category;
 
-		@FieldDescribe("状态:draft|audit|publish")
-		private String status;
-
 		@FieldDescribe("排序字段:createTime(创建时间,默认)|orderNumber(排序)|recommend(推荐指数)")
 		private String orderBy;
 
@@ -119,14 +116,6 @@ class ActionListPaging extends BaseAction {
 			this.category = category;
 		}
 
-		public String getStatus() {
-			return status;
-		}
-
-		public void setStatus(String status) {
-			this.status = status;
-		}
-
 		public String getOrderBy() {
 			return orderBy;
 		}

+ 38 - 1
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/MarketAction.java

@@ -25,7 +25,7 @@ public class MarketAction extends StandardJaxrsAction {
 
 	private static Logger logger = LoggerFactory.getLogger(MarketAction.class);
 
-	@JaxrsMethodDescribe(value = "分页查询.", action = ActionListPaging.class)
+	@JaxrsMethodDescribe(value = "应用分页查询.", action = ActionListPaging.class)
 	@POST
 	@Path("list/paging/{page}/size/{size}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@@ -97,4 +97,41 @@ public class MarketAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 
+	@JaxrsMethodDescribe(value = "安装或更新应用.", action = ActionInstallOrUpdate.class)
+	@GET
+	@Path("{flag}/install/or/update")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void installOrUpdate(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+					@JaxrsParameterDescribe("标识") @PathParam("flag") String flag) {
+		ActionResult<ActionInstallOrUpdate.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionInstallOrUpdate().execute(effectivePerson, flag);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
+	@JaxrsMethodDescribe(value = "安装记录分页查询.", action = ActionInstallLogListPaging.class)
+	@POST
+	@Path("list/install/log/paging/{page}/size/{size}")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void installLogListPaging(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+						   @JaxrsParameterDescribe("分页") @PathParam("page") Integer page,
+						   @JaxrsParameterDescribe("每页数量") @PathParam("size") Integer size, JsonElement jsonElement) {
+		ActionResult<List<ActionInstallLogListPaging.Wo>> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionInstallLogListPaging().execute(effectivePerson, page, size, jsonElement);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, jsonElement);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
+	}
+
 }

+ 2 - 92
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/module/ActionDispatchResource.java

@@ -13,6 +13,7 @@ import com.x.base.core.project.jaxrs.WrapStringList;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.Crypto;
+import com.x.program.center.Business;
 import com.x.program.center.ThisApplication;
 import org.apache.commons.lang3.StringUtils;
 import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
@@ -49,102 +50,11 @@ class ActionDispatchResource extends BaseAction {
 		}
 
 		Wo wo = new Wo();
-		wo.setValueList(dispatch(asNew, fileName, filePath, bytes));
+		wo.setValueList(Business.dispatch(asNew, fileName, filePath, bytes));
 		result.setData(wo);
 		return result;
 	}
 
-	private List<String> dispatch(boolean asNew, String fileName, String filePath, byte[] bytes) throws Exception{
-		List<String> list = new ArrayList<>();
-		Nodes nodes = Config.nodes();
-		for (String node : nodes.keySet()){
-			boolean flag = false;
-
-			try (Socket socket = new Socket(node, nodes.get(node).nodeAgentPort())) {
-				socket.setKeepAlive(true);
-				socket.setSoTimeout(10000);
-				try (DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
-					 DataInputStream dis = new DataInputStream(socket.getInputStream())){
-					Map<String, Object> commandObject = new HashMap<>();
-					commandObject.put("command", "uploadResource:"+fileName);
-					commandObject.put("credential", Crypto.rsaEncrypt("o2@", Config.publicKey()));
-
-					Map<String, Object> param = new HashMap<>();
-					param.put("fileName", fileName);
-					param.put("asNew", asNew);
-					if(StringUtils.isNotEmpty(filePath)){
-						param.put("filePath", filePath);
-					}
-					commandObject.put("param", param);
-					dos.writeUTF(XGsonBuilder.toJson(commandObject));
-					dos.flush();
-					dos.writeInt(bytes.length);
-					dos.flush();
-
-					try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes)){
-						byte[] onceBytes = new byte[1024];
-						int length = 0;
-						while((length = bis.read(onceBytes, 0, onceBytes.length)) != -1) {
-							dos.write(onceBytes, 0, length);
-							dos.flush();
-						}
-					}
-
-					String result = dis.readUTF();
-					logger.print("socket dispatch resource {} to {}:{} result={}", fileName, node, nodes.get(node).nodeAgentPort(), result);
-					if("success".equals(result)){
-						flag = true;
-						list.add(node+":success");
-					}else{
-						list.add(node + ":failure");
-					}
-				}
-
-			} catch (Exception ex) {
-				list.add(node + ":failure-"+ex.getMessage());
-				logger.print("socket dispatch resource to {}:{} error={}", node, nodes.get(node).nodeAgentPort(), ex.getMessage());
-			}
-
-			/*if(!flag) {
-				Map.Entry<String, CenterServer> centerEntry = Config.nodes().centerServers().findByNode(node);
-				if (centerEntry != null) {
-					String url = Config.url_x_program_center_jaxrs(centerEntry, "sysresource", "upload", "resource", "as", "new", String.valueOf(asNew));
-					Map<String, String> param = new HashMap<>();
-					if(StringUtils.isNotEmpty(filePath)){
-						param.put("filePath", filePath);
-					}
-					ActionResponse response = CipherConnectionAction.multiFormPost(false, url, fileName, bytes, param);
-					logger.print("dispatch resource to {} result={}", url, XGsonBuilder.toJson(response));
-					if (response.getType().equals(ActionResponse.Type.success)) {
-						list.add(node + ":success");
-						flag = true;
-					}
-				}
-			}
-
-			if(!flag) {
-				Application app = ThisApplication.context().applications().findOneAppByNode(node);
-				if (app != null) {
-					String url = app.getUrlJaxrsRoot() + "sysresource/upload/resource/as/new/" + asNew;
-					Map<String, String> param = new HashMap<>();
-					if(StringUtils.isNotEmpty(filePath)){
-						param.put("filePath", filePath);
-					}
-					ActionResponse response = CipherConnectionAction.multiFormPost(false, url, fileName, bytes, param);
-					logger.print("dispatch to {} result={}", url, XGsonBuilder.toJson(response));
-					if (response.getType().equals(ActionResponse.Type.success)) {
-						list.add(node + ":success");
-					} else {
-						list.add(node + ":failure");
-					}
-				}else{
-					list.add(node+":failure");
-				}
-			}*/
-		}
-		return list;
-	}
-
 	public static class Wo extends WrapStringList {
 
 	}

+ 15 - 0
o2server/x_program_center_core_entity/src/main/java/com/x/program/center/core/entity/InstallLog.java

@@ -67,6 +67,13 @@ public class InstallLog extends SliceJpaObject {
 	@CheckPersist(allowEmpty = false)
 	private String status;
 
+	public static final String data_FIELDNAME = "data";
+	@FieldDescribe("安装概要内容.")
+	@Lob
+	@Basic(fetch = FetchType.EAGER)
+	@Column(length = JpaObject.length_2K, name = ColumnNamePrefix + data_FIELDNAME)
+	private String data;
+
 	public static final String installPerson_FIELDNAME = "installPerson";
 	@FieldDescribe("安装用户.")
 	@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + installPerson_FIELDNAME)
@@ -125,6 +132,14 @@ public class InstallLog extends SliceJpaObject {
 		this.status = status;
 	}
 
+	public String getData() {
+		return data;
+	}
+
+	public void setData(String data) {
+		this.data = data;
+	}
+
 	public String getInstallPerson() {
 		return installPerson;
 	}

+ 16 - 9
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/input/ActionCover.java

@@ -43,22 +43,27 @@ class ActionCover extends BaseAction {
 			Wo wo = new Wo();
 			Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
 			Business business = new Business(emc);
-			Query query = business.entityManagerContainer().find(wi.getId(), Query.class);
-			if (null == query) {
-				throw new ExceptionQueryNotExist(wi.getId());
-			}
-			if (!business.editable(effectivePerson, query)) {
-				throw new ExceptionQueryAccessDenied(effectivePerson.getName(), query.getName(), query.getId());
-			}
-			this.cover(business, wi, query);
+
+			Query query = this.cover(business, wi, effectivePerson);
 			wo.setId(query.getId());
 			result.setData(wo);
 			return result;
 		}
 	}
 
-	private void cover(Business business, Wi wi, Query query) throws Exception {
+	private Query cover(Business business, Wi wi, EffectivePerson effectivePerson) throws Exception {
 		List<JpaObject> persistObjects = new ArrayList<>();
+
+		Query query = business.entityManagerContainer().find(wi.getId(), Query.class);
+		if(query == null){
+			query = WrapQuery.inCopier.copy(wi);
+			query.setName(this.idleQueryName(business, query.getName(), query.getId()));
+			query.setAlias(this.idleQueryAlias(business, query.getAlias(), query.getId()));
+			persistObjects.add(query);
+		}else if (!business.editable(effectivePerson, query)) {
+			throw new ExceptionQueryAccessDenied(effectivePerson.getName(), query.getName(), query.getId());
+		}
+
 		for (WrapView _o : wi.getViewList()) {
 			View obj = business.entityManagerContainer().find(_o.getId(), View.class);
 			if (null != obj) {
@@ -169,6 +174,8 @@ class ActionCover extends BaseAction {
 		if(!wi.getRevealList().isEmpty()){
 			ApplicationCache.notify(Reveal.class);
 		}
+
+		return query;
 	}
 
 	private <T extends JpaObject> String idleNameWithQuery(Business business, String queryId, String name, Class<T> cls,