Browse Source

应用市场应用安装1

o2sword 5 years ago
parent
commit
ae7e5b2cc2

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

@@ -36,6 +36,7 @@ public class Collect extends ConfigObject {
 	public static String ADDRESS_COLLECT_VALIDATE = "/o2_collect_assemble/jaxrs/unit/validate";
 	public static String ADDRESS_COLLECT_VALIDATE = "/o2_collect_assemble/jaxrs/unit/validate";
 	public static String ADDRESS_COLLECT_VALIDATE_CODE = "/o2_collect_assemble/jaxrs/unit/validate/codeanswer";
 	public static String ADDRESS_COLLECT_VALIDATE_CODE = "/o2_collect_assemble/jaxrs/unit/validate/codeanswer";
 	public static String ADDRESS_COLLECT_APPLICATION_LIST = "/o2_collect_assemble/jaxrs/application/list";
 	public static String ADDRESS_COLLECT_APPLICATION_LIST = "/o2_collect_assemble/jaxrs/application/list";
+	public static String ADDRESS_COLLECT_APPLICATION_DOWN = "/o2_collect_assemble/jaxrs/application/download";
 	public static String COLLECT_TOKEN = "c-token";
 	public static String COLLECT_TOKEN = "c-token";
 
 
 	public static Collect defaultInstance() {
 	public static Collect defaultInstance() {

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

@@ -21,13 +21,16 @@ import com.x.base.core.project.tools.ListTools;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.mime.MultipartEntityBuilder;
 import org.apache.http.entity.mime.MultipartEntityBuilder;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.util.EntityUtils;
 import org.apache.http.util.EntityUtils;
+import org.apache.mina.core.session.IoSession;
 
 
 public class ConnectionAction {
 public class ConnectionAction {
 
 
@@ -194,6 +197,32 @@ public class ConnectionAction {
 		return read(response, connection);
 		return read(response, connection);
 	}
 	}
 
 
+	public static byte[] getFile(String address, List<NameValuePair> heads) throws Exception {
+		try(CloseableHttpClient httpclient = HttpClients.createDefault()){
+			HttpGet httpget = new HttpGet(address);
+			if (ListTools.isNotEmpty(heads)) {
+				String name;
+				String value;
+				for (NameValuePair o : heads) {
+					name = Objects.toString(o.getName(), "");
+					value = Objects.toString(o.getValue(), "");
+					if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(value)) {
+						httpget.addHeader(name, value);
+					}
+				}
+			}
+			HttpResponse response = httpclient.execute(httpget);
+			HttpEntity entity = response.getEntity();
+			if(entity!=null) {
+				InputStream in = entity.getContent();
+				if (in != null){
+					return IOUtils.toByteArray(in);
+				}
+			}
+		}
+		return null;
+	}
+
 	public static ActionResponse multiFormPost(String address, List<NameValuePair> heads, String fileName, byte[] bytes,
 	public static ActionResponse multiFormPost(String address, List<NameValuePair> heads, String fileName, byte[] bytes,
 			Map<String, String> map) throws Exception {
 			Map<String, String> map) throws Exception {
 		ActionResponse response = new ActionResponse();
 		ActionResponse response = new ActionResponse();
@@ -231,6 +260,7 @@ public class ConnectionAction {
 				response.setMessage("convert to json error, address:" + address + ", method: multiFormPost, because:"
 				response.setMessage("convert to json error, address:" + address + ", method: multiFormPost, because:"
 						+ e.getMessage() + ", value:" + value + ".");
 						+ e.getMessage() + ", value:" + value + ".");
 			}
 			}
+			httpClient.close();
 		} catch (Exception e) {
 		} catch (Exception e) {
 			response.setType(ActionResponse.Type.connectFatal);
 			response.setType(ActionResponse.Type.connectFatal);
 			response.setMessage(
 			response.setMessage(

+ 2 - 1
o2server/x_base_core_project/src/main/java/com/x/base/core/project/x_program_center.java

@@ -10,8 +10,9 @@ import com.x.base.core.project.annotation.ModuleType;
 		"com.x.program.center.core.entity.Captcha", "com.x.program.center.core.entity.Code",
 		"com.x.program.center.core.entity.Captcha", "com.x.program.center.core.entity.Code",
 		"com.x.program.center.core.entity.PromptErrorLog", "com.x.program.center.core.entity.UnexpectedErrorLog",
 		"com.x.program.center.core.entity.PromptErrorLog", "com.x.program.center.core.entity.UnexpectedErrorLog",
 		"com.x.program.center.core.entity.Structure", "com.x.program.center.core.entity.WarnLog",
 		"com.x.program.center.core.entity.Structure", "com.x.program.center.core.entity.WarnLog",
-		"com.x.program.center.core.entity.validation.Meta", "com.x.portal.core.entity.Page",
+		"com.x.program.center.core.entity.validation.Meta", "com.x.program.center.core.entity.InstallLog",
 		"com.x.program.center.core.entity.Application", "com.x.program.center.core.entity.Attachment",
 		"com.x.program.center.core.entity.Application", "com.x.program.center.core.entity.Attachment",
+		"com.x.portal.core.entity.Page",
 		"com.x.portal.core.entity.Portal", "com.x.organization.core.entity.Group",
 		"com.x.portal.core.entity.Portal", "com.x.organization.core.entity.Group",
 		"com.x.organization.core.entity.Custom", "com.x.organization.core.entity.Role",
 		"com.x.organization.core.entity.Custom", "com.x.organization.core.entity.Role",
 		"com.x.organization.core.entity.Person", "com.x.organization.core.entity.Identity",
 		"com.x.organization.core.entity.Person", "com.x.organization.core.entity.Identity",

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

@@ -0,0 +1,42 @@
+package com.x.program.center.jaxrs.market;
+
+import com.x.base.core.container.EntityManagerContainer;
+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;
+import com.x.base.core.project.jaxrs.WrapBoolean;
+import com.x.program.center.core.entity.Application;
+import com.x.program.center.core.entity.Attachment;
+
+import java.util.ArrayList;
+import java.util.List;
+
+class ActionInstallOrUpdate 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) {
+				throw new ExceptionEntityNotExist(id, Application.class);
+			}
+
+			Wo wo = new Wo();
+			wo.setValue(true);
+			result.setData(wo);
+			return result;
+		}
+	}
+
+	public static class Wo extends WrapBoolean {
+
+	}
+}

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

@@ -10,7 +10,7 @@ import org.apache.openjpa.persistence.jdbc.Index;
 import javax.persistence.*;
 import javax.persistence.*;
 import java.util.Date;
 import java.util.Date;
 
 
-@ContainerEntity
+@ContainerEntity(dumpSize = 1000, type = ContainerEntity.Type.content, reference = ContainerEntity.Reference.strong)
 @Entity
 @Entity
 @Table(name = PersistenceProperties.Application.table, uniqueConstraints = {
 @Table(name = PersistenceProperties.Application.table, uniqueConstraints = {
 		@UniqueConstraint(name = PersistenceProperties.Application.table + JpaObject.IndexNameMiddle
 		@UniqueConstraint(name = PersistenceProperties.Application.table + JpaObject.IndexNameMiddle
@@ -117,6 +117,12 @@ public class Application extends SliceJpaObject {
 	@Index(name = TABLE + IndexNameMiddle + grade_FIELDNAME)
 	@Index(name = TABLE + IndexNameMiddle + grade_FIELDNAME)
 	private Double grade;
 	private Double grade;
 
 
+	public static final String commentCount_FIELDNAME = "commentCount";
+	@FieldDescribe("评论数")
+	@Column(name = ColumnNamePrefix + commentCount_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + commentCount_FIELDNAME)
+	private Integer commentCount;
+
 	public static final String orderNumber_FIELDNAME = "orderNumber";
 	public static final String orderNumber_FIELDNAME = "orderNumber";
 	@FieldDescribe("排序号,升序排列,为空在最后")
 	@FieldDescribe("排序号,升序排列,为空在最后")
 	@Column(name = ColumnNamePrefix + orderNumber_FIELDNAME)
 	@Column(name = ColumnNamePrefix + orderNumber_FIELDNAME)
@@ -260,4 +266,12 @@ public class Application extends SliceJpaObject {
 	public void setGrade(Double grade) {
 	public void setGrade(Double grade) {
 		this.grade = grade;
 		this.grade = grade;
 	}
 	}
+
+	public Integer getCommentCount() {
+		return commentCount;
+	}
+
+	public void setCommentCount(Integer commentCount) {
+		this.commentCount = commentCount;
+	}
 }
 }

+ 1 - 1
o2server/x_program_center_core_entity/src/main/java/com/x/program/center/core/entity/Attachment.java

@@ -15,7 +15,7 @@ import org.apache.openjpa.persistence.jdbc.Index;
 import javax.persistence.*;
 import javax.persistence.*;
 import java.util.Date;
 import java.util.Date;
 
 
-@ContainerEntity
+@ContainerEntity(dumpSize = 1000, type = ContainerEntity.Type.content, reference = ContainerEntity.Reference.strong)
 @Entity
 @Entity
 @Table(name = PersistenceProperties.Attachment.table, uniqueConstraints = {
 @Table(name = PersistenceProperties.Attachment.table, uniqueConstraints = {
 		@UniqueConstraint(name = PersistenceProperties.Attachment.table + JpaObject.IndexNameMiddle
 		@UniqueConstraint(name = PersistenceProperties.Attachment.table + JpaObject.IndexNameMiddle

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

@@ -0,0 +1,159 @@
+package com.x.program.center.core.entity;
+
+import com.x.base.core.entity.JpaObject;
+import com.x.base.core.entity.SliceJpaObject;
+import com.x.base.core.entity.annotation.CheckPersist;
+import com.x.base.core.entity.annotation.ContainerEntity;
+import com.x.base.core.project.annotation.FieldDescribe;
+import org.apache.openjpa.persistence.jdbc.Index;
+
+import javax.persistence.*;
+import java.util.Date;
+
+@ContainerEntity(dumpSize = 1000, type = ContainerEntity.Type.content, reference = ContainerEntity.Reference.strong)
+@Entity
+@Table(name = PersistenceProperties.InstallLog.table, uniqueConstraints = {
+		@UniqueConstraint(name = PersistenceProperties.InstallLog.table + JpaObject.IndexNameMiddle
+				+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
+						JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+public class InstallLog extends SliceJpaObject {
+
+	private static final long serialVersionUID = -1080102795064855623L;
+
+	private static final String TABLE = PersistenceProperties.InstallLog.table;
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	@FieldDescribe("数据库主键,自动生成.")
+	@Id
+	@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
+	private String id = createId();
+
+	/* 以上为 JpaObject 默认字段 */
+
+	public void onPersist() throws Exception {
+	}
+
+	public static final String name_FIELDNAME = "name";
+	@FieldDescribe("名称")
+	@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + name_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + name_FIELDNAME)
+	@CheckPersist(allowEmpty = false)
+	private String name;
+
+	public static final String category_FIELDNAME = "category";
+	@FieldDescribe("分类")
+	@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + category_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + category_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private String category;
+
+	public static final String version_FIELDNAME = "version";
+	@FieldDescribe("版本")
+	@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + version_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private String version;
+
+	public static final String status_FIELDNAME = "status";
+	@FieldDescribe("状态:valid|invalid.")
+	@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + status_FIELDNAME)
+	@CheckPersist(allowEmpty = false)
+	private String status;
+
+	public static final String installPerson_FIELDNAME = "installPerson";
+	@FieldDescribe("安装用户.")
+	@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + installPerson_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private String installPerson;
+
+	public static final String installTime_FIELDNAME = "installTime";
+	@FieldDescribe("安装时间")
+	@Column(name = ColumnNamePrefix + installTime_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + installTime_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private Date installTime;
+
+	public static final String unInstallPerson_FIELDNAME = "unInstallPerson";
+	@FieldDescribe("卸载用户.")
+	@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + unInstallPerson_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private String unInstallPerson;
+
+	public static final String unInstallTime_FIELDNAME = "unInstallTime";
+	@FieldDescribe("卸载时间")
+	@Column(name = ColumnNamePrefix + unInstallTime_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + unInstallTime_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private Date unInstallTime;
+
+	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 getVersion() {
+		return version;
+	}
+
+	public void setVersion(String version) {
+		this.version = version;
+	}
+
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+
+	public String getInstallPerson() {
+		return installPerson;
+	}
+
+	public void setInstallPerson(String installPerson) {
+		this.installPerson = installPerson;
+	}
+
+	public Date getInstallTime() {
+		return installTime;
+	}
+
+	public void setInstallTime(Date installTime) {
+		this.installTime = installTime;
+	}
+
+	public String getUnInstallPerson() {
+		return unInstallPerson;
+	}
+
+	public void setUnInstallPerson(String unInstallPerson) {
+		this.unInstallPerson = unInstallPerson;
+	}
+
+	public Date getUnInstallTime() {
+		return unInstallTime;
+	}
+
+	public void setUnInstallTime(Date unInstallTime) {
+		this.unInstallTime = unInstallTime;
+	}
+}

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

@@ -72,6 +72,10 @@ public final class PersistenceProperties extends AbstractPersistenceProperties {
 		public static final String table = "CTE_ATTACHMENT";
 		public static final String table = "CTE_ATTACHMENT";
 	}
 	}
 
 
+	public static class InstallLog {
+		public static final String table = "CTE_INSTALL_LOG";
+	}
+
 	public static class Validation {
 	public static class Validation {
 		public static class Meta {
 		public static class Meta {
 			public static final String table = "VAL_META";
 			public static final String table = "VAL_META";

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

@@ -197,6 +197,7 @@ public class Structure extends StorageObject {
 	private String description;
 	private String description;
 
 
 	public static final String descriptionLob_FIELDNAME = "descriptionLob";
 	public static final String descriptionLob_FIELDNAME = "descriptionLob";
+	@FieldDescribe("详细描述.")
 	@Lob
 	@Lob
 	@Basic(fetch = FetchType.EAGER)
 	@Basic(fetch = FetchType.EAGER)
 	@Column(length = JpaObject.length_10M, name = ColumnNamePrefix + descriptionLob_FIELDNAME)
 	@Column(length = JpaObject.length_10M, name = ColumnNamePrefix + descriptionLob_FIELDNAME)