提交 8aa9f3cb 编写于 作者: O o2null

Merge branch 'feature/门户缓存优化' into 'develop'

【平台】门户缓存优化

See merge request o2oa/o2oa!1453
......@@ -25,7 +25,6 @@ import com.x.organization.core.entity.Unit;
import com.x.organization.core.entity.Unit_;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGet extends BaseAction {
......
package com.x.organization.assemble.personal;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.instrument.Instrument;
import com.x.organization.assemble.personal.factory.GroupFactory;
import com.x.organization.assemble.personal.factory.IdentityFactory;
......@@ -11,27 +10,21 @@ import com.x.organization.assemble.personal.factory.RoleFactory;
import com.x.organization.assemble.personal.factory.UnitAttributeFactory;
import com.x.organization.assemble.personal.factory.UnitDutyFactory;
import com.x.organization.assemble.personal.factory.UnitFactory;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.PersonAttribute;
import com.x.organization.core.entity.Role;
import com.x.organization.core.entity.Unit;
import com.x.organization.core.entity.UnitAttribute;
import com.x.organization.core.entity.UnitDuty;
import net.sf.ehcache.Ehcache;
import com.x.organization.core.entity.*;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.organization.core.entity.accredit.Empower;
public class Business {
private EntityManagerContainer emc;
private Ehcache cache;
private CacheCategory cache;
public Business(EntityManagerContainer emc) throws Exception {
this.emc = emc;
this.cache = ApplicationCache.instance().getCache(Group.class, Role.class, Person.class, PersonAttribute.class,
Unit.class, UnitDuty.class, UnitAttribute.class, Identity.class);
this.cache = new CacheCategory(Group.class, Role.class, Person.class, PersonAttribute.class,
Unit.class, UnitDuty.class, UnitAttribute.class, Identity.class, Definition.class,
Empower.class, Custom.class);
}
public EntityManagerContainer entityManagerContainer() {
......@@ -119,7 +112,7 @@ public class Business {
return instrument;
}
public Ehcache cache() {
public CacheCategory cache() {
return cache;
}
......
......@@ -22,8 +22,9 @@ import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Group_;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.Person;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class GroupFactory extends AbstractFactory {
......@@ -36,14 +37,13 @@ public class GroupFactory extends AbstractFactory {
return null;
}
Group o = null;
Element element = this.business.cache().get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (Group) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
o = (Group) optional.get();
} else {
o = this.pickObject(flag);
this.business.cache().put(new Element(flag, o));
CacheManager.put(business.cache(), cacheKey, o);
}
return o;
}
......@@ -51,14 +51,13 @@ public class GroupFactory extends AbstractFactory {
public List<Group> pick(List<String> flags) throws Exception {
List<Group> list = new ArrayList<>();
for (String str : flags) {
Element element = this.business.cache().get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((Group) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
list.add((Group) optional.get());
} else {
Group o = this.pickObject(str);
this.business.cache().put(new Element(str, o));
CacheManager.put(business.cache(), cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -14,14 +14,14 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.organization.assemble.personal.AbstractFactory;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Identity_;
import com.x.organization.core.entity.PersistenceProperties;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class IdentityFactory extends AbstractFactory {
......@@ -34,14 +34,13 @@ public class IdentityFactory extends AbstractFactory {
return null;
}
Identity o = null;
Element element = this.business.cache().get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (Identity) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
o = (Identity) optional.get();
} else {
o = this.pickObject(flag);
this.business.cache().put(new Element(flag, o));
CacheManager.put(business.cache(), cacheKey, o);
}
return o;
}
......@@ -80,14 +79,13 @@ public class IdentityFactory extends AbstractFactory {
public List<Identity> pick(List<String> flags) throws Exception {
List<Identity> list = new ArrayList<>();
for (String str : flags) {
Element element = this.business.cache().get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((Identity) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
list.add((Identity) optional.get());
} else {
Identity o = this.pickObject(str);
this.business.cache().put(new Element(str, o));
CacheManager.put(business.cache(), cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -14,14 +14,14 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.organization.assemble.personal.AbstractFactory;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.PersonAttribute;
import com.x.organization.core.entity.PersonAttribute_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class PersonAttributeFactory extends AbstractFactory {
......@@ -34,14 +34,13 @@ public class PersonAttributeFactory extends AbstractFactory {
return null;
}
PersonAttribute o = null;
Element element = this.business.cache().get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (PersonAttribute) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
o = (PersonAttribute) optional.get();
} else {
o = this.pickObject(flag);
this.business.cache().put(new Element(flag, o));
CacheManager.put(business.cache(), cacheKey, o);
}
return o;
}
......@@ -80,14 +79,13 @@ public class PersonAttributeFactory extends AbstractFactory {
public List<PersonAttribute> pick(List<String> flags) throws Exception {
List<PersonAttribute> list = new ArrayList<>();
for (String str : flags) {
Element element = this.business.cache().get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((PersonAttribute) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
list.add((PersonAttribute) optional.get());
} else {
PersonAttribute o = this.pickObject(str);
this.business.cache().put(new Element(str, o));
CacheManager.put(business.cache(), cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -17,15 +17,16 @@ import org.apache.commons.lang3.StringUtils;
import com.x.base.core.entity.tools.JpaObjectTools;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.base.core.project.tools.Crypto;
import com.x.organization.assemble.personal.AbstractFactory;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Person_;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
import net.sf.ehcache.Element;
public class PersonFactory extends AbstractFactory {
......@@ -38,14 +39,13 @@ public class PersonFactory extends AbstractFactory {
return null;
}
Person o = null;
Element element = this.business.cache().get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (Person) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
o = (Person) optional.get();
} else {
o = this.pickObject(flag);
this.business.cache().put(new Element(flag, o));
CacheManager.put(business.cache(), cacheKey, o);
}
return o;
}
......@@ -84,14 +84,13 @@ public class PersonFactory extends AbstractFactory {
public List<Person> pick(List<String> flags) throws Exception {
List<Person> list = new ArrayList<>();
for (String str : flags) {
Element element = this.business.cache().get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((Person) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
list.add((Person) optional.get());
} else {
Person o = this.pickObject(str);
this.business.cache().put(new Element(str, o));
CacheManager.put(business.cache(), cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -14,14 +14,15 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.organization.assemble.personal.AbstractFactory;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.Role;
import com.x.organization.core.entity.Role_;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
import net.sf.ehcache.Element;
public class RoleFactory extends AbstractFactory {
......@@ -34,14 +35,13 @@ public class RoleFactory extends AbstractFactory {
return null;
}
Role o = null;
Element element = this.business.cache().get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (Role) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
o = (Role) optional.get();
} else {
o = this.pickObject(flag);
this.business.cache().put(new Element(flag, o));
CacheManager.put(business.cache(), cacheKey, o);
}
return o;
}
......@@ -80,14 +80,13 @@ public class RoleFactory extends AbstractFactory {
public List<Role> pick(List<String> flags) throws Exception {
List<Role> list = new ArrayList<>();
for (String str : flags) {
Element element = this.business.cache().get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((Role) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
list.add((Role) optional.get());
} else {
Role o = this.pickObject(str);
this.business.cache().put(new Element(str, o));
CacheManager.put(business.cache(), cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -14,14 +14,14 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.organization.assemble.personal.AbstractFactory;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.UnitAttribute;
import com.x.organization.core.entity.UnitAttribute_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class UnitAttributeFactory extends AbstractFactory {
......@@ -34,14 +34,13 @@ public class UnitAttributeFactory extends AbstractFactory {
return null;
}
UnitAttribute o = null;
Element element = this.business.cache().get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (UnitAttribute) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
o = (UnitAttribute) optional.get();
} else {
o = this.pickObject(flag);
this.business.cache().put(new Element(flag, o));
CacheManager.put(business.cache(), cacheKey, o);
}
return o;
}
......@@ -80,14 +79,13 @@ public class UnitAttributeFactory extends AbstractFactory {
public List<UnitAttribute> pick(List<String> flags) throws Exception {
List<UnitAttribute> list = new ArrayList<>();
for (String str : flags) {
Element element = this.business.cache().get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((UnitAttribute) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
list.add((UnitAttribute) optional.get());
} else {
UnitAttribute o = this.pickObject(str);
this.business.cache().put(new Element(str, o));
CacheManager.put(business.cache(), cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -14,14 +14,14 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.organization.assemble.personal.AbstractFactory;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.UnitDuty;
import com.x.organization.core.entity.UnitDuty_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class UnitDutyFactory extends AbstractFactory {
......@@ -34,14 +34,13 @@ public class UnitDutyFactory extends AbstractFactory {
return null;
}
UnitDuty o = null;
Element element = this.business.cache().get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (UnitDuty) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
o = (UnitDuty) optional.get();
} else {
o = this.pickObject(flag);
this.business.cache().put(new Element(flag, o));
CacheManager.put(business.cache(), cacheKey, o);
}
return o;
}
......@@ -80,14 +79,13 @@ public class UnitDutyFactory extends AbstractFactory {
public List<UnitDuty> pick(List<String> flags) throws Exception {
List<UnitDuty> list = new ArrayList<>();
for (String str : flags) {
Element element = this.business.cache().get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((UnitDuty) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
list.add((UnitDuty) optional.get());
} else {
UnitDuty o = this.pickObject(str);
this.business.cache().put(new Element(str, o));
CacheManager.put(business.cache(), cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -21,8 +21,9 @@ import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.Unit;
import com.x.organization.core.entity.Unit_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class UnitFactory extends AbstractFactory {
......@@ -35,14 +36,13 @@ public class UnitFactory extends AbstractFactory {
return null;
}
Unit o = null;
Element element = this.business.cache().get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (Unit) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
o = (Unit) optional.get();
} else {
o = this.pickObject(flag);
this.business.cache().put(new Element(flag, o));
CacheManager.put(business.cache(), cacheKey, o);
}
return o;
}
......@@ -97,14 +97,13 @@ public class UnitFactory extends AbstractFactory {
public List<Unit> pick(List<String> flags) throws Exception {
List<Unit> list = new ArrayList<>();
for (String str : flags) {
Element element = this.business.cache().get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((Unit) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
list.add((Unit) optional.get());
} else {
Unit o = this.pickObject(str);
this.business.cache().put(new Element(str, o));
CacheManager.put(business.cache(), cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -2,7 +2,7 @@ package com.x.organization.assemble.personal.jaxrs.custom;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -24,7 +24,7 @@ class ActionDelete extends BaseAction {
emc.remove(o);
emc.commit();
wo.setId(o.getId());
ApplicationCache.notify(Custom.class, effectivePerson.getDistinguishedName());
CacheManager.notify(Custom.class, effectivePerson.getDistinguishedName());
}
result.setData(wo);
return result;
......
......@@ -3,6 +3,7 @@ package com.x.organization.assemble.personal.jaxrs.definition;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -24,7 +25,7 @@ class ActionDelete extends BaseAction {
emc.remove(o);
emc.commit();
wo.setId(o.getId());
ApplicationCache.notify(Definition.class);
CacheManager.notify(Definition.class);
}
result.setData(wo);
return result;
......
......@@ -4,6 +4,7 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -30,7 +31,7 @@ class ActionEdit extends BaseAction {
emc.persist(definition, CheckPersistType.all);
}
emc.commit();
ApplicationCache.notify(Definition.class);
CacheManager.notify(Definition.class);
Wo wo = new Wo();
wo.setId(definition.getId());
result.setData(wo);
......
......@@ -6,9 +6,11 @@ import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.Definition;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGet extends BaseAction {
......@@ -16,17 +18,18 @@ class ActionGet extends BaseAction {
ActionResult<String> execute(EffectivePerson effectivePerson, String name) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<String> result = new ActionResult<>();
String cacheKey = name;
Element element = cache.get(cacheKey);
CacheKey cacheKey = new CacheKey(name);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
String wo = "";
if (null != element) {
wo = (String) element.getObjectValue();
if (optional.isPresent()) {
wo = (String) optional.get();
} else {
Definition o = emc.flag(name, Definition.class);
if (null != o) {
wo = o.getData();
cache.put(new Element(cacheKey, wo));
CacheManager.put(business.cache(), cacheKey, wo);
}
}
result.setData(wo);
......
package com.x.organization.assemble.personal.jaxrs.empower;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
......@@ -44,7 +45,7 @@ class ActionCreate extends BaseAction {
emc.beginTransaction(Empower.class);
emc.persist(empower, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Empower.class);
CacheManager.notify(Empower.class);
Wo wo = new Wo();
wo.setId(empower.getId());
result.setData(wo);
......
......@@ -4,6 +4,7 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
......@@ -26,7 +27,7 @@ class ActionDelete extends BaseAction {
emc.beginTransaction(Empower.class);
emc.remove(empower, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(Empower.class);
CacheManager.notify(Empower.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
......@@ -4,6 +4,7 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -27,7 +28,7 @@ class ActionDisable extends BaseAction {
empower.setEnable(false);
emc.check(empower, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Empower.class);
CacheManager.notify(Empower.class);
Wo wo = new Wo();
wo.setId(empower.getId());
result.setData(wo);
......
package com.x.organization.assemble.personal.jaxrs.empower;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
......@@ -49,7 +50,7 @@ class ActionEdit extends BaseAction {
emc.beginTransaction(Empower.class);
emc.check(empower, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Empower.class);
CacheManager.notify(Empower.class);
Wo wo = new Wo();
wo.setId(empower.getId());
result.setData(wo);
......
......@@ -4,6 +4,7 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -27,7 +28,7 @@ class ActionEnable extends BaseAction {
empower.setEnable(true);
emc.check(empower, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Empower.class);
CacheManager.notify(Empower.class);
Wo wo = new Wo();
wo.setId(empower.getId());
result.setData(wo);
......
......@@ -7,13 +7,11 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.accredit.Empower;
import net.sf.ehcache.Element;
class ActionListTo extends BaseAction {
......
......@@ -7,13 +7,11 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.accredit.Empower;
import net.sf.ehcache.Element;
class ActionListToEnable extends BaseAction {
......
......@@ -7,14 +7,11 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.accredit.Empower;
import net.sf.ehcache.Element;
class ActionListWithCurrentPerson extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
......
......@@ -7,15 +7,15 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
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.organization.assemble.personal.Business;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.accredit.Empower;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionListWithPerson extends BaseAction {
......@@ -27,13 +27,13 @@ class ActionListWithPerson extends BaseAction {
if (null == person) {
throw new ExceptionEntityNotExist(flag);
}
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), person.getDistinguishedName());
Element element = cache.get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), person.getDistinguishedName());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, person.getDistinguishedName());
cache.put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
return result;
......
......@@ -8,6 +8,7 @@ import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -48,7 +49,7 @@ class ActionManagerCreate extends BaseAction {
emc.beginTransaction(Empower.class);
emc.persist(empower, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Empower.class);
CacheManager.notify(Empower.class);
Wo wo = new Wo();
wo.setId(empower.getId());
result.setData(wo);
......
......@@ -4,6 +4,7 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
......@@ -24,7 +25,7 @@ class ActionManagerDelete extends BaseAction {
emc.beginTransaction(Empower.class);
emc.remove(empower, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(Empower.class);
CacheManager.notify(Empower.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
......@@ -8,6 +8,7 @@ import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -50,7 +51,7 @@ class ActionManagerEdit extends BaseAction {
emc.beginTransaction(Empower.class);
emc.check(empower, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Empower.class);
CacheManager.notify(Empower.class);
Wo wo = new Wo();
wo.setId(empower.getId());
result.setData(wo);
......
......@@ -10,7 +10,6 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionEntityFieldEmpty;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.organization.assemble.personal.Business;
......@@ -19,12 +18,9 @@ import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.accredit.Empower;
import com.x.organization.core.entity.accredit.Empower_;
import net.sf.ehcache.Ehcache;
abstract class BaseAction extends StandardJaxrsAction {
protected static Ehcache cache = ApplicationCache.instance().getCache(Empower.class);
protected void check(Business business, Empower empower) throws Exception {
if (StringUtils.isEmpty(empower.getFromIdentity())) {
throw new ExceptionEmptyFromIdentity();
......
......@@ -4,6 +4,7 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
......@@ -26,7 +27,7 @@ class ActionDelete extends BaseAction {
emc.beginTransaction(EmpowerLog.class);
emc.remove(empowerLog, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(EmpowerLog.class);
CacheManager.notify(EmpowerLog.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
......@@ -8,15 +8,15 @@ import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.type.GenderType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoFile;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.Person;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGetWithPerson extends BaseAction {
......@@ -24,13 +24,13 @@ class ActionGetWithPerson extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((Wo) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
Wo wo = this.get(business, flag);
business.cache().put(new Element(cacheKey, wo));
CacheManager.put(business.cache(), cacheKey, wo);
result.setData(wo);
}
return result;
......
......@@ -8,6 +8,7 @@ import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -46,7 +47,7 @@ class ActionEdit extends BaseAction {
emc.check(person, CheckPersistType.all);
emc.commit();
/** 刷新缓存 */
ApplicationCache.notify(Person.class);
CacheManager.notify(Person.class);
/** 通知x_collect_service_transmit同步数据到collect */
business.instrument().collect().person();
Wo wo = new Wo();
......
......@@ -17,7 +17,6 @@ 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.cache.ApplicationCache;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -35,8 +34,9 @@ import com.x.organization.core.entity.Role_;
import com.x.organization.core.entity.Unit;
import com.x.organization.core.entity.UnitDuty;
import com.x.organization.core.entity.UnitDuty_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGet extends BaseAction {
......@@ -44,11 +44,11 @@ class ActionGet extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(),
CacheKey cacheKey = new CacheKey(this.getClass(),
effectivePerson.getDistinguishedName());
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((Wo) element.getObjectValue());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
if (Config.token().isInitialManager(effectivePerson.getDistinguishedName())) {
/** 如果是xadmin单独处理 */
......@@ -65,7 +65,7 @@ class ActionGet extends BaseAction {
this.referenceIdentity(business, wo);
this.referenceRole(business, wo);
this.referenceGroup(business, wo);
business.cache().put(new Element(cacheKey, wo));
CacheManager.put(business.cache(), cacheKey, wo);
result.setData(wo);
}
}
......
......@@ -8,15 +8,15 @@ import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.type.GenderType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoFile;
import com.x.organization.assemble.personal.Business;
import com.x.organization.core.entity.Person;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGetIcon extends BaseAction {
......@@ -24,14 +24,13 @@ class ActionGetIcon extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(),
effectivePerson.getDistinguishedName());
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((Wo) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), effectivePerson.getDistinguishedName());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
Wo wo = this.get(business, effectivePerson);
business.cache().put(new Element(cacheKey, wo));
CacheManager.put(business.cache(), cacheKey, wo);
result.setData(wo);
}
return result;
......
......@@ -6,6 +6,7 @@ import java.io.ByteArrayOutputStream;
import javax.imageio.ImageIO;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.codec.binary.Base64;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.imgscalr.Scalr;
......@@ -60,7 +61,7 @@ class ActionSetIcon extends BaseAction {
person.setIconLdpi(icon_l);
emc.commit();
ApplicationCache.notify(Person.class);
CacheManager.notify(Person.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
......@@ -6,6 +6,7 @@ import java.io.ByteArrayOutputStream;
import javax.imageio.ImageIO;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.codec.binary.Base64;
import org.imgscalr.Scalr;
......@@ -58,7 +59,7 @@ class ActionSetIconOctetStream extends BaseAction {
person.setIconLdpi(icon_l);
emc.commit();
ApplicationCache.notify(Person.class);
CacheManager.notify(Person.class);
Wo wo = new Wo();
wo.setId(person.getId());
result.setData(wo);
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.personal.jaxrs.person;
import java.util.Date;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -94,7 +95,7 @@ class ActionSetPassword extends BaseAction {
emc.beginTransaction(Person.class);
business.person().setPassword(person, wi.getNewPassword());
emc.commit();
ApplicationCache.notify(Person.class);
CacheManager.notify(Person.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
package com.x.organization.assemble.personal.jaxrs.reset;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -98,7 +99,7 @@ public class ActionSetPasswordAnonymous extends BaseAction {
emc.beginTransaction(Person.class);
business.person().setPassword(person, wi.getNewPassword());
emc.commit();
ApplicationCache.notify(Person.class);
CacheManager.notify(Person.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
......@@ -9,6 +9,7 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.CacheManager;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
......@@ -49,7 +50,7 @@ public class DisableExpiredEmpower extends AbstractJob {
o.setEnable(false);
}
emc.commit();
ApplicationCache.notify(Empower.class);
CacheManager.notify(Empower.class);
}
}
......
package com.x.portal.assemble.designer.jaxrs.file;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
......@@ -9,7 +10,6 @@ import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionDuplicateFlag;
import com.x.base.core.project.exception.ExceptionDuplicateRestrictFlag;
......@@ -56,7 +56,7 @@ class ActionCreate extends BaseAction {
}
emc.persist(file, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(File.class);
CacheManager.notify(File.class);
Wo wo = new Wo();
wo.setId(file.getId());
result.setData(wo);
......
......@@ -4,6 +4,7 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
......@@ -32,7 +33,7 @@ class ActionDelete extends BaseAction {
emc.beginTransaction(File.class);
emc.remove(file, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(File.class);
CacheManager.notify(File.class);
Wo wo = new Wo();
wo.setId(file.getId());
result.setData(wo);
......
......@@ -5,7 +5,6 @@ import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -13,22 +12,23 @@ import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.jaxrs.WoFile;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionDownload extends StandardJaxrsAction {
private Ehcache cache = ApplicationCache.instance().getCache(File.class);
private CacheCategory cacheCategory = new CacheCategory(File.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag);
Element element = cache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
} else {
File file = emc.flag(flag, File.class);
if (null == file) {
......@@ -48,7 +48,7 @@ class ActionDownload extends StandardJaxrsAction {
* 对10M以下的文件进行缓存
*/
if (bs.length < (1024 * 1024 * 10)) {
cache.put(new Element(cacheKey, wo));
CacheManager.put(cacheCategory, cacheKey, wo);
}
}
result.setData(wo);
......
package com.x.portal.assemble.designer.jaxrs.file;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
......@@ -57,7 +58,7 @@ class ActionEdit extends BaseAction {
}
emc.check(file, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(File.class);
CacheManager.notify(File.class);
Wo wo = new Wo();
wo.setId(file.getId());
result.setData(wo);
......
package com.x.portal.assemble.designer.jaxrs.file;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
......@@ -43,7 +44,7 @@ class ActionUpload extends BaseAction {
file.setFileName(fileName);
}
emc.commit();
ApplicationCache.notify(File.class);
CacheManager.notify(File.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
......@@ -10,6 +10,7 @@ import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -146,10 +147,10 @@ class ActionCover extends BaseAction {
business.entityManagerContainer().persist(o);
}
business.entityManagerContainer().commit();
ApplicationCache.notify(Script.class);
ApplicationCache.notify(Page.class);
ApplicationCache.notify(Widget.class);
ApplicationCache.notify(Portal.class);
CacheManager.notify(Script.class);
CacheManager.notify(Page.class);
CacheManager.notify(Widget.class);
CacheManager.notify(Portal.class);
return portal;
}
......
......@@ -4,7 +4,6 @@ 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.project.annotation.FieldDescribe;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -20,8 +19,8 @@ import com.x.portal.core.entity.wrap.WrapPage;
import com.x.portal.core.entity.wrap.WrapPortal;
import com.x.portal.core.entity.wrap.WrapScript;
import com.x.portal.core.entity.wrap.WrapWidget;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionSelect extends BaseAction {
......@@ -44,7 +43,8 @@ class ActionSelect extends BaseAction {
cacheObject.setName(portal.getName());
cacheObject.setPortal(wrapPortal);
String flag = StringTools.uniqueToken();
this.cache.put(new Element(flag, cacheObject));
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
CacheManager.put(this.cache, cacheKey, cacheObject);
Wo wo = XGsonBuilder.convert(wrapPortal, Wo.class);
wo.setFlag(flag);
result.setData(wo);
......
......@@ -6,8 +6,9 @@ import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoFile;
import com.x.base.core.project.tools.DefaultCharset;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionSelectFile extends BaseAction {
......@@ -16,11 +17,12 @@ class ActionSelectFile extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Element element = cache.get(flag);
if (null == element || null == element.getObjectValue()) {
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(this.cache, cacheKey);
if (!optional.isPresent()) {
throw new ExceptionFlagNotExist(flag);
}
CacheObject cacheObject = (CacheObject) element.getObjectValue();
CacheObject cacheObject = (CacheObject) optional.get();
Wo wo = new Wo(gson.toJson(cacheObject.getPortal()).getBytes(DefaultCharset.name),
this.contentType(true, cacheObject.getName() + extension),
this.contentDisposition(true, cacheObject.getName() + extension));
......
......@@ -9,17 +9,15 @@ import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.wrap.WrapPortal;
import net.sf.ehcache.Ehcache;
import com.x.base.core.project.cache.Cache.CacheCategory;
abstract class BaseAction extends StandardJaxrsAction {
protected Ehcache cache = ApplicationCache.instance().getCache(CacheObject.class);
protected CacheCategory cache = new CacheCategory(CacheObject.class);
protected <T extends JpaObject> List<String> listWithPortal(Business business, Portal portal, Class<T> cls)
throws Exception {
......
package com.x.portal.assemble.designer.jaxrs.page;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
......@@ -9,7 +10,6 @@ import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -44,8 +44,8 @@ class ActionCreate extends BaseAction {
portal.setFirstPage(page.getId());
}
emc.commit();
ApplicationCache.notify(Page.class);
ApplicationCache.notify(Portal.class);
CacheManager.notify(Page.class);
CacheManager.notify(Portal.class);
Wo wo = new Wo();
wo.setId(page.getId());
result.setData(wo);
......
package com.x.portal.assemble.designer.jaxrs.page;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
......@@ -44,8 +44,8 @@ class ActionDelete extends BaseAction {
}
}
emc.commit();
ApplicationCache.notify(Page.class);
ApplicationCache.notify(Portal.class);
CacheManager.notify(Page.class);
CacheManager.notify(Portal.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
package com.x.portal.assemble.designer.jaxrs.page;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
......@@ -9,7 +10,6 @@ import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -50,8 +50,8 @@ class ActionEdit extends BaseAction {
portal.setFirstPage(page.getId());
}
emc.commit();
ApplicationCache.notify(Page.class);
ApplicationCache.notify(Portal.class);
CacheManager.notify(Page.class);
CacheManager.notify(Portal.class);
Wo wo = new Wo();
wo.setId(page.getId());
result.setData(wo);
......
......@@ -5,14 +5,14 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGet extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
......@@ -20,17 +20,17 @@ class ActionGet extends BaseAction {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = cache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(id);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
} else {
Page page = emc.find(id, Page.class);
if (null == page) {
throw new PageNotExistedException(id);
}
wo = Wo.copier.copy(page);
cache.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
Portal portal = emc.find(wo.getPortal(), Portal.class);
if (null == portal) {
......
......@@ -2,17 +2,15 @@ package com.x.portal.assemble.designer.jaxrs.page;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Ehcache;
import com.x.base.core.project.cache.Cache.CacheCategory;
abstract class BaseAction extends StandardJaxrsAction {
static Ehcache cache = ApplicationCache.instance().getCache(Page.class);
static CacheCategory cache = new CacheCategory(Page.class);
void checkName(Business business, Page page) throws Exception {
if (StringUtils.isEmpty(page.getName())) {
......
......@@ -9,7 +9,7 @@ import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -35,7 +35,7 @@ class ActionCreate extends BaseAction {
this.checkAlias(business, portal);
emc.persist(portal, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Portal.class);
CacheManager.notify(Portal.class);
Wo wo = new Wo();
wo.setId(portal.getId());
result.setData(wo);
......
......@@ -5,7 +5,7 @@ import java.util.List;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
......@@ -41,11 +41,11 @@ class ActionDelete extends BaseAction {
this.removeFile(business, portal.getId());
emc.remove(portal, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(Portal.class);
ApplicationCache.notify(Widget.class);
ApplicationCache.notify(Page.class);
ApplicationCache.notify(Script.class);
ApplicationCache.notify(File.class);
CacheManager.notify(Portal.class);
CacheManager.notify(Widget.class);
CacheManager.notify(Page.class);
CacheManager.notify(Script.class);
CacheManager.notify(File.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
......@@ -9,7 +9,7 @@ import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -41,10 +41,10 @@ class ActionEdit extends BaseAction {
this.checkAlias(business, o);
emc.check(o, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Portal.class);
ApplicationCache.notify(Widget.class);
ApplicationCache.notify(Page.class);
ApplicationCache.notify(Script.class);
CacheManager.notify(Portal.class);
CacheManager.notify(Widget.class);
CacheManager.notify(Page.class);
CacheManager.notify(Script.class);
Wo wo = new Wo();
wo.setId(o.getId());
result.setData(wo);
......
......@@ -5,13 +5,13 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGet extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
......@@ -19,10 +19,10 @@ class ActionGet extends BaseAction {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = cache.get(cacheKey);
if (null != element && null != element.getObjectValue()) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(id);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
} else {
Portal o = emc.find(id, Portal.class);
if (null == o) {
......@@ -32,7 +32,7 @@ class ActionGet extends BaseAction {
throw new InvisibleException(effectivePerson.getDistinguishedName(), o.getName(), o.getId());
}
wo = Wo.copier.copy(o);
cache.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
result.setData(wo);
return result;
......
......@@ -7,6 +7,7 @@ import java.io.InputStream;
import javax.imageio.ImageIO;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.codec.binary.Base64;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.imgscalr.Scalr;
......@@ -45,7 +46,7 @@ class ActionSetIcon extends BaseAction {
portal.setIcon(icon);
emc.commit();
Wo wo = new Wo();
ApplicationCache.notify(Portal.class);
CacheManager.notify(Portal.class);
wo.setId(portal.getId());
result.setData(wo);
return result;
......
......@@ -11,18 +11,16 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Portal_;
import net.sf.ehcache.Ehcache;
import com.x.base.core.project.cache.Cache.CacheCategory;
abstract class BaseAction extends StandardJaxrsAction {
static Ehcache cache = ApplicationCache.instance().getCache(Portal.class);
static CacheCategory cache = new CacheCategory(Portal.class);
void checkName(Business business, Portal portal) throws Exception {
if (StringUtils.isEmpty(portal.getName())) {
......
......@@ -9,7 +9,7 @@ import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -38,7 +38,7 @@ class ActionCreate extends BaseAction {
this.checkDepend(business, script);
emc.persist(script, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Script.class);
CacheManager.notify(Script.class);
Wo wo = new Wo();
wo.setId(script.getId());
result.setData(wo);
......
......@@ -8,12 +8,12 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
......@@ -44,7 +44,7 @@ class ActionDelete extends BaseAction {
this.checkDepended(business, script);
emc.remove(script, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(Script.class);
CacheManager.notify(Script.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
......@@ -9,7 +9,7 @@ import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -44,7 +44,7 @@ class ActionEdit extends BaseAction {
this.checkDepend(business, script);
emc.check(script, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Script.class);
CacheManager.notify(Script.class);
Wo wo = new Wo();
wo.setId(script.getId());
result.setData(wo);
......
......@@ -5,14 +5,14 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGet extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
......@@ -20,17 +20,17 @@ class ActionGet extends BaseAction {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = cache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(id);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
} else {
Script script = emc.find(id, Script.class);
if (null == script) {
throw new ScriptNotExistedException(id);
}
wo = Wo.copier.copy(script);
cache.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
Portal portal = emc.find(wo.getPortal(), Portal.class);
if (null == portal) {
......
......@@ -2,17 +2,15 @@ package com.x.portal.assemble.designer.jaxrs.script;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Script;
import net.sf.ehcache.Ehcache;
import com.x.base.core.project.cache.Cache.CacheCategory;
abstract class BaseAction extends StandardJaxrsAction {
static Ehcache cache = ApplicationCache.instance().getCache(Script.class);
static CacheCategory cache = new CacheCategory(Script.class);
void checkName(Business business, Script script) throws Exception {
if (StringUtils.isEmpty(script.getName())) {
......
......@@ -9,7 +9,7 @@ import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -35,7 +35,7 @@ class ActionCreate extends BaseAction {
emc.beginTransaction(TemplatePage.class);
emc.persist(o, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(TemplatePage.class);
CacheManager.notify(TemplatePage.class);
Wo wo = new Wo();
wo.setId(o.getId());
result.setData(wo);
......
......@@ -3,7 +3,7 @@ package com.x.portal.assemble.designer.jaxrs.templatepage;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
......@@ -26,7 +26,7 @@ class ActionDelete extends BaseAction {
emc.beginTransaction(TemplatePage.class);
emc.remove(o, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(TemplatePage.class);
CacheManager.notify(TemplatePage.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
......@@ -7,7 +7,7 @@ import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -33,8 +33,8 @@ class ActionCreate extends BaseAction {
this.checkAlias(business, widget);
emc.persist(widget, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Widget.class);
ApplicationCache.notify(Portal.class);
CacheManager.notify(Widget.class);
CacheManager.notify(Portal.class);
Wo wo = new Wo();
wo.setId(widget.getId());
result.setData(wo);
......
......@@ -3,7 +3,7 @@ package com.x.portal.assemble.designer.jaxrs.widget;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
......@@ -33,8 +33,8 @@ class ActionDelete extends BaseAction {
emc.beginTransaction(Widget.class);
emc.remove(widget, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(Widget.class);
ApplicationCache.notify(Portal.class);
CacheManager.notify(Widget.class);
CacheManager.notify(Portal.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
......@@ -7,7 +7,7 @@ import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
......@@ -40,8 +40,8 @@ class ActionEdit extends BaseAction {
this.checkAlias(business, widget);
emc.check(widget, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Widget.class);
ApplicationCache.notify(Portal.class);
CacheManager.notify(Widget.class);
CacheManager.notify(Portal.class);
Wo wo = new Wo();
wo.setId(widget.getId());
result.setData(wo);
......
......@@ -5,7 +5,6 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
......@@ -13,8 +12,9 @@ import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Widget;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGet extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
......@@ -22,17 +22,17 @@ class ActionGet extends BaseAction {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = cache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(id);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
} else {
Widget widget = emc.find(id, Widget.class);
if (null == widget) {
throw new ExceptionEntityNotExist(id, Widget.class);
}
wo = Wo.copier.copy(widget);
cache.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
Portal portal = emc.find(wo.getPortal(), Portal.class);
if (null == portal) {
......
......@@ -2,16 +2,14 @@ package com.x.portal.assemble.designer.jaxrs.widget;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Widget;
import net.sf.ehcache.Ehcache;
import com.x.base.core.project.cache.Cache.CacheCategory;
abstract class BaseAction extends StandardJaxrsAction {
static Ehcache cache = ApplicationCache.instance().getCache(Widget.class);
static CacheCategory cache = new CacheCategory(Widget.class);
void checkName(Business business, Widget widget) throws Exception {
if (StringUtils.isEmpty(widget.getName())) {
......
......@@ -10,33 +10,33 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.portal.assemble.surface.AbstractFactory;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.File_;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class FileFactory extends AbstractFactory {
static Ehcache fileCache = ApplicationCache.instance().getCache(File.class);
static CacheCategory cache = new CacheCategory(File.class);
public FileFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public File pick(String id) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = fileCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (File) element.getObjectValue();
CacheKey cacheKey = new CacheKey(id);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (File) optional.get();
} else {
File o = this.business().entityManagerContainer().find(id, File.class);
if (null != o) {
this.business().entityManagerContainer().get(File.class).detach(o);
fileCache.put(new Element(id, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
......
......@@ -8,19 +8,19 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.portal.assemble.surface.AbstractFactory;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Page_;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class PageFactory extends AbstractFactory {
static Ehcache pageCache = ApplicationCache.instance().getCache(Page.class);
static CacheCategory cache = new CacheCategory(Page.class);
public PageFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
......@@ -37,15 +37,15 @@ public class PageFactory extends AbstractFactory {
}
public Page pick(String id) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = pageCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (Page) element.getObjectValue();
CacheKey cacheKey = new CacheKey(id);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Page) optional.get();
} else {
Page o = this.business().entityManagerContainer().find(id, Page.class);
if (null != o) {
this.business().entityManagerContainer().get(Page.class).detach(o);
pageCache.put(new Element(id, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
......@@ -53,15 +53,15 @@ public class PageFactory extends AbstractFactory {
}
public Page pick(Portal portal, String flag) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey(portal.getId(), flag);
Element element = pageCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (Page) element.getObjectValue();
CacheKey cacheKey = new CacheKey(portal.getId(), flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Page) optional.get();
} else {
Page o = entityManagerContainer().restrictFlag(flag, Page.class, Page.portal_FIELDNAME, portal.getId());
if (null != o) {
this.business().entityManagerContainer().get(Page.class).detach(o);
pageCache.put(new Element(cacheKey, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
......
......@@ -8,7 +8,6 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.base.core.project.tools.ListTools;
......@@ -16,13 +15,14 @@ import com.x.portal.assemble.surface.AbstractFactory;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Portal_;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class PortalFactory extends AbstractFactory {
static Ehcache portalCache = ApplicationCache.instance().getCache(Portal.class);
static CacheCategory cache = new CacheCategory(Portal.class);
public PortalFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
......@@ -78,15 +78,15 @@ public class PortalFactory extends AbstractFactory {
}
public Portal pick(String flag) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey(flag);
Element element = portalCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (Portal) element.getObjectValue();
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Portal) optional.get();
} else {
Portal o = this.business().entityManagerContainer().flag(flag, Portal.class);
if (null != o) {
this.business().entityManagerContainer().get(Portal.class).detach(o);
portalCache.put(new Element(flag, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
......
......@@ -10,29 +10,29 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.portal.assemble.surface.AbstractFactory;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import com.x.portal.core.entity.Script_;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class ScriptFactory extends AbstractFactory {
static Ehcache scriptCache = ApplicationCache.instance().getCache(Script.class);
static CacheCategory cache = new CacheCategory(Script.class);
public ScriptFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public Script flagWithPortalObject(String flag, String portalId) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey("flagObject", flag);
Element element = scriptCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (Script) element.getObjectValue();
CacheKey cacheKey = new CacheKey("flagObject", flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Script) optional.get();
} else {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
......@@ -46,22 +46,22 @@ public class ScriptFactory extends AbstractFactory {
} else {
Script o = list.get(0);
em.detach(o);
scriptCache.put(new Element(cacheKey, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
}
}
public Script pick(String id) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = scriptCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (Script) element.getObjectValue();
CacheKey cacheKey = new CacheKey(id);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Script) optional.get();
} else {
Script o = this.business().entityManagerContainer().find(id, Script.class);
if (null != o) {
this.business().entityManagerContainer().get(Script.class).detach(o);
scriptCache.put(new Element(id, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
......@@ -81,10 +81,10 @@ public class ScriptFactory extends AbstractFactory {
@SuppressWarnings("unchecked")
public List<Script> listScriptNestedWithPortalWithFlag(Portal portal, String flag) throws Exception {
List<Script> list = new ArrayList<>();
String cacheKey = ApplicationCache.concreteCacheKey(flag, portal.getId(), "listScriptNestedWithPortalWithFlag");
Element element = scriptCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
list = (List<Script>) element.getObjectValue();
CacheKey cacheKey = new CacheKey(flag, portal.getId(), "listScriptNestedWithPortalWithFlag");
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
list = (List<Script>) optional.get();
} else {
List<String> names = new ArrayList<>();
names.add(flag);
......@@ -101,7 +101,7 @@ public class ScriptFactory extends AbstractFactory {
}
if (!list.isEmpty()) {
Collections.reverse(list);
scriptCache.put(new Element(cacheKey, list));
CacheManager.put(cache, cacheKey, list);
}
}
return list;
......
......@@ -8,33 +8,33 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.portal.assemble.surface.AbstractFactory;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Widget;
import com.x.portal.core.entity.Widget_;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class WidgetFactory extends AbstractFactory {
static Ehcache menuCache = ApplicationCache.instance().getCache(Widget.class);
static CacheCategory cache = new CacheCategory(Widget.class);
public WidgetFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public Widget pick(String id) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = menuCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (Widget) element.getObjectValue();
CacheKey cacheKey = new CacheKey(id);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Widget) optional.get();
} else {
Widget o = this.business().entityManagerContainer().find(id, Widget.class);
if (null != o) {
this.business().entityManagerContainer().get(Widget.class).detach(o);
menuCache.put(new Element(id, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
......
......@@ -23,22 +23,23 @@ import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.File_;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionContent extends StandardJaxrsAction {
private Ehcache cache = ApplicationCache.instance().getCache(File.class);
private CacheCategory cache = new CacheCategory(File.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, String portalFlag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalFlag);
Element element = cache.get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
wo = ((Wo) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalFlag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = ((Wo) optional.get());
} else {
Business business = new Business(emc);
Portal portal = business.portal().pick(portalFlag);
......@@ -56,7 +57,7 @@ class ActionContent extends StandardJaxrsAction {
}
wo = new Wo(bs, this.contentType(false, file.getFileName()),
this.contentDisposition(false, file.getFileName()));
cache.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
result.setData(wo);
return result;
......
......@@ -13,7 +13,6 @@ import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -23,22 +22,23 @@ import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.File_;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionDownload extends StandardJaxrsAction {
private Ehcache cache = ApplicationCache.instance().getCache(File.class);
private CacheCategory cache = new CacheCategory(File.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, String portalFlag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalFlag);
Element element = cache.get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
wo = ((Wo) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalFlag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = ((Wo) optional.get());
} else {
Business business = new Business(emc);
Portal portal = business.portal().pick(portalFlag);
......@@ -56,7 +56,7 @@ class ActionDownload extends StandardJaxrsAction {
}
wo = new Wo(bs, this.contentType(true, file.getFileName()),
this.contentDisposition(true, file.getFileName()));
cache.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
result.setData(wo);
return result;
......
......@@ -5,15 +5,15 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGetWithPortal extends BaseAction {
......@@ -22,10 +22,10 @@ class ActionGetWithPortal extends BaseAction {
Wo wo = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalFlag);
Element element = pageCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalFlag);
Optional<?> optional = CacheManager.get(pageCache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
Portal portal = business.portal().pick(wo.getPortal());
if (isNotLoginPage(flag) && (!business.portal().visible(effectivePerson, portal))) {
throw new ExceptionPortalAccessDenied(effectivePerson.getDistinguishedName(), portal.getName(),
......@@ -46,7 +46,7 @@ class ActionGetWithPortal extends BaseAction {
}
wo = Wo.copier.copy(page);
wo.setData(page.getDataOrMobileData());
pageCache.put(new Element(cacheKey, wo));
CacheManager.put(pageCache, cacheKey, wo);
}
result.setData(wo);
return result;
......
......@@ -5,15 +5,15 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGetWithPortalMobile extends BaseAction {
......@@ -22,10 +22,10 @@ class ActionGetWithPortalMobile extends BaseAction {
Wo wo = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalFlag);
Element element = pageCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalFlag);
Optional<?> optional = CacheManager.get(pageCache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
Portal portal = business.portal().pick(wo.getPortal());
if (isNotLoginPage(flag) && (!business.portal().visible(effectivePerson, portal))) {
throw new ExceptionPortalAccessDenied(effectivePerson.getDistinguishedName(), portal.getName(),
......@@ -43,7 +43,7 @@ class ActionGetWithPortalMobile extends BaseAction {
Page page = business.page().pick(portal, flag);
wo = Wo.copier.copy(page);
wo.setData(page.getMobileDataOrData());
pageCache.put(new Element(cacheKey, wo));
CacheManager.put(pageCache, cacheKey, wo);
}
result.setData(wo);
return result;
......
......@@ -2,16 +2,14 @@ package com.x.portal.assemble.surface.jaxrs.page;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.core.entity.Page;
import net.sf.ehcache.Ehcache;
import com.x.base.core.project.cache.Cache.CacheCategory;
abstract class BaseAction extends StandardJaxrsAction {
Ehcache pageCache = ApplicationCache.instance().getCache(Page.class);
CacheCategory pageCache = new CacheCategory(Page.class);
protected boolean isNotLoginPage(String id) throws Exception {
return !(Config.portal().getIndexPage().getEnable()
......
......@@ -10,15 +10,15 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGetImported extends BaseAction {
......@@ -26,10 +26,10 @@ class ActionGetImported extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalId);
Element element = CACHE.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalId);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
} else {
Business business = new Business(emc);
Portal portal = business.portal().pick(portalId);
......@@ -59,7 +59,7 @@ class ActionGetImported extends BaseAction {
}
wo.setImportedList(imported);
wo.setText(buffer.toString());
CACHE.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
result.setData(wo);
return result;
......
package com.x.portal.assemble.surface.jaxrs.script;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.core.entity.Script;
import net.sf.ehcache.Ehcache;
import com.x.base.core.project.cache.Cache.CacheCategory;
abstract class BaseAction extends StandardJaxrsAction {
protected Ehcache CACHE = ApplicationCache.instance().getCache(Script.class);
protected CacheCategory cache = new CacheCategory(Script.class);
}
......@@ -5,14 +5,14 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Widget;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGetWithPortal extends BaseAction {
......@@ -21,10 +21,10 @@ class ActionGetWithPortal extends BaseAction {
Wo wo = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalFlag);
Element element = widgetCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalFlag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
Portal portal = business.portal().pick(wo.getPortal());
if (!business.portal().visible(effectivePerson, portal)) {
throw new ExceptionPortalAccessDenied(effectivePerson.getDistinguishedName(), portal.getName(),
......@@ -45,7 +45,7 @@ class ActionGetWithPortal extends BaseAction {
}
wo = Wo.copier.copy(widget);
wo.setData(widget.getDataOrMobileData());
widgetCache.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
result.setData(wo);
return result;
......
......@@ -5,14 +5,14 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Widget;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGetWithPortalMobile extends BaseAction {
......@@ -21,10 +21,10 @@ class ActionGetWithPortalMobile extends BaseAction {
Wo wo = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalFlag);
Element element = widgetCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalFlag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
Portal portal = business.portal().pick(wo.getPortal());
if (!business.portal().visible(effectivePerson, portal)) {
throw new ExceptionPortalAccessDenied(effectivePerson.getDistinguishedName(), portal.getName(),
......@@ -45,7 +45,7 @@ class ActionGetWithPortalMobile extends BaseAction {
}
wo = Wo.copier.copy(widget);
wo.setData(widget.getMobileDataOrData());
widgetCache.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
result.setData(wo);
return result;
......
package com.x.portal.assemble.surface.jaxrs.widget;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.core.entity.Widget;
import net.sf.ehcache.Ehcache;
import com.x.base.core.project.cache.Cache.CacheCategory;
abstract class BaseAction extends StandardJaxrsAction {
Ehcache widgetCache = ApplicationCache.instance().getCache(Widget.class);
CacheCategory cache = new CacheCategory(Widget.class);
}
......@@ -10,33 +10,33 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.portal.assemble.surface.AbstractFactory;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.File_;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class FileFactory extends AbstractFactory {
static Ehcache fileCache = ApplicationCache.instance().getCache(File.class);
static CacheCategory cache = new CacheCategory(File.class);
public FileFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public File pick(String id) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = fileCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (File) element.getObjectValue();
CacheKey cacheKey = new CacheKey(id);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (File) optional.get();
} else {
File o = this.business().entityManagerContainer().find(id, File.class);
if (null != o) {
this.business().entityManagerContainer().get(File.class).detach(o);
fileCache.put(new Element(id, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
......
......@@ -8,19 +8,19 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.portal.assemble.surface.AbstractFactory;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Page_;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class PageFactory extends AbstractFactory {
static Ehcache pageCache = ApplicationCache.instance().getCache(Page.class);
static CacheCategory cache = new CacheCategory(Page.class);
public PageFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
......@@ -37,15 +37,15 @@ public class PageFactory extends AbstractFactory {
}
public Page pick(String id) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = pageCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (Page) element.getObjectValue();
CacheKey cacheKey = new CacheKey(id);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Page) optional.get();
} else {
Page o = this.business().entityManagerContainer().find(id, Page.class);
if (null != o) {
this.business().entityManagerContainer().get(Page.class).detach(o);
pageCache.put(new Element(id, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
......@@ -53,15 +53,15 @@ public class PageFactory extends AbstractFactory {
}
public Page pick(Portal portal, String flag) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey(portal.getId(), flag);
Element element = pageCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (Page) element.getObjectValue();
CacheKey cacheKey = new CacheKey(portal.getId(), flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Page) optional.get();
} else {
Page o = entityManagerContainer().restrictFlag(flag, Page.class, Page.portal_FIELDNAME, portal.getId());
if (null != o) {
this.business().entityManagerContainer().get(Page.class).detach(o);
pageCache.put(new Element(cacheKey, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
......
......@@ -8,7 +8,6 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.base.core.project.tools.ListTools;
......@@ -16,13 +15,14 @@ import com.x.portal.assemble.surface.AbstractFactory;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Portal_;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class PortalFactory extends AbstractFactory {
static Ehcache portalCache = ApplicationCache.instance().getCache(Portal.class);
static CacheCategory cache = new CacheCategory(Portal.class);
public PortalFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
......@@ -78,15 +78,15 @@ public class PortalFactory extends AbstractFactory {
}
public Portal pick(String flag) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey(flag);
Element element = portalCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (Portal) element.getObjectValue();
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Portal) optional.get();
} else {
Portal o = this.business().entityManagerContainer().flag(flag, Portal.class);
if (null != o) {
this.business().entityManagerContainer().get(Portal.class).detach(o);
portalCache.put(new Element(flag, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
......
......@@ -10,29 +10,29 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.portal.assemble.surface.AbstractFactory;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import com.x.portal.core.entity.Script_;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class ScriptFactory extends AbstractFactory {
static Ehcache scriptCache = ApplicationCache.instance().getCache(Script.class);
static CacheCategory cache = new CacheCategory(Script.class);
public ScriptFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public Script flagWithPortalObject(String flag, String portalId) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey("flagObject", flag);
Element element = scriptCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (Script) element.getObjectValue();
CacheKey cacheKey = new CacheKey("flagObject", flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Script) optional.get();
} else {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
......@@ -46,22 +46,22 @@ public class ScriptFactory extends AbstractFactory {
} else {
Script o = list.get(0);
em.detach(o);
scriptCache.put(new Element(cacheKey, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
}
}
public Script pick(String id) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = scriptCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (Script) element.getObjectValue();
CacheKey cacheKey = new CacheKey(id);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Script) optional.get();
} else {
Script o = this.business().entityManagerContainer().find(id, Script.class);
if (null != o) {
this.business().entityManagerContainer().get(Script.class).detach(o);
scriptCache.put(new Element(id, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
......@@ -81,10 +81,10 @@ public class ScriptFactory extends AbstractFactory {
@SuppressWarnings("unchecked")
public List<Script> listScriptNestedWithPortalWithFlag(Portal portal, String flag) throws Exception {
List<Script> list = new ArrayList<>();
String cacheKey = ApplicationCache.concreteCacheKey(flag, portal.getId(), "listScriptNestedWithPortalWithFlag");
Element element = scriptCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
list = (List<Script>) element.getObjectValue();
CacheKey cacheKey = new CacheKey(flag, portal.getId(), "listScriptNestedWithPortalWithFlag");
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
list = (List<Script>) optional.get();
} else {
List<String> names = new ArrayList<>();
names.add(flag);
......@@ -101,7 +101,7 @@ public class ScriptFactory extends AbstractFactory {
}
if (!list.isEmpty()) {
Collections.reverse(list);
scriptCache.put(new Element(cacheKey, list));
CacheManager.put(cache, cacheKey, list);
}
}
return list;
......
......@@ -8,33 +8,33 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.portal.assemble.surface.AbstractFactory;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Widget;
import com.x.portal.core.entity.Widget_;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
public class WidgetFactory extends AbstractFactory {
static Ehcache menuCache = ApplicationCache.instance().getCache(Widget.class);
static CacheCategory cache = new CacheCategory(Widget.class);
public WidgetFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public Widget pick(String id) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey(id);
Element element = menuCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (Widget) element.getObjectValue();
CacheKey cacheKey = new CacheKey(id);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Widget) optional.get();
} else {
Widget o = this.business().entityManagerContainer().find(id, Widget.class);
if (null != o) {
this.business().entityManagerContainer().get(Widget.class).detach(o);
menuCache.put(new Element(id, o));
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
......
......@@ -23,22 +23,23 @@ import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.File_;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionContent extends StandardJaxrsAction {
private Ehcache cache = ApplicationCache.instance().getCache(File.class);
private CacheCategory cache = new CacheCategory(File.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, String portalFlag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalFlag);
Element element = cache.get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
wo = ((Wo) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalFlag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = ((Wo) optional.get());
} else {
Business business = new Business(emc);
Portal portal = business.portal().pick(portalFlag);
......@@ -56,7 +57,7 @@ class ActionContent extends StandardJaxrsAction {
}
wo = new Wo(bs, this.contentType(false, file.getFileName()),
this.contentDisposition(false, file.getFileName()));
cache.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
result.setData(wo);
return result;
......
......@@ -13,7 +13,6 @@ import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -23,22 +22,23 @@ import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.File;
import com.x.portal.core.entity.File_;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionDownload extends StandardJaxrsAction {
private Ehcache cache = ApplicationCache.instance().getCache(File.class);
private CacheCategory cache = new CacheCategory(File.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, String portalFlag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalFlag);
Element element = cache.get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
wo = ((Wo) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalFlag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = ((Wo) optional.get());
} else {
Business business = new Business(emc);
Portal portal = business.portal().pick(portalFlag);
......@@ -56,7 +56,7 @@ class ActionDownload extends StandardJaxrsAction {
}
wo = new Wo(bs, this.contentType(true, file.getFileName()),
this.contentDisposition(true, file.getFileName()));
cache.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
result.setData(wo);
return result;
......
......@@ -5,15 +5,15 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGetWithPortal extends BaseAction {
......@@ -22,10 +22,10 @@ class ActionGetWithPortal extends BaseAction {
Wo wo = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalFlag);
Element element = pageCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalFlag);
Optional<?> optional = CacheManager.get(pageCache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
Portal portal = business.portal().pick(wo.getPortal());
if (isNotLoginPage(flag) && (!business.portal().visible(effectivePerson, portal))) {
throw new ExceptionPortalAccessDenied(effectivePerson.getDistinguishedName(), portal.getName(),
......@@ -46,7 +46,7 @@ class ActionGetWithPortal extends BaseAction {
}
wo = Wo.copier.copy(page);
wo.setData(page.getDataOrMobileData());
pageCache.put(new Element(cacheKey, wo));
CacheManager.put(pageCache, cacheKey, wo);
}
result.setData(wo);
return result;
......
......@@ -5,15 +5,15 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Page;
import com.x.portal.core.entity.Portal;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGetWithPortalMobile extends BaseAction {
......@@ -22,10 +22,10 @@ class ActionGetWithPortalMobile extends BaseAction {
Wo wo = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalFlag);
Element element = pageCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalFlag);
Optional<?> optional = CacheManager.get(pageCache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
Portal portal = business.portal().pick(wo.getPortal());
if (isNotLoginPage(flag) && (!business.portal().visible(effectivePerson, portal))) {
throw new ExceptionPortalAccessDenied(effectivePerson.getDistinguishedName(), portal.getName(),
......@@ -43,7 +43,7 @@ class ActionGetWithPortalMobile extends BaseAction {
Page page = business.page().pick(portal, flag);
wo = Wo.copier.copy(page);
wo.setData(page.getMobileDataOrData());
pageCache.put(new Element(cacheKey, wo));
CacheManager.put(pageCache, cacheKey, wo);
}
result.setData(wo);
return result;
......
......@@ -2,16 +2,14 @@ package com.x.portal.assemble.surface.jaxrs.page;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.core.entity.Page;
import net.sf.ehcache.Ehcache;
import com.x.base.core.project.cache.Cache.CacheCategory;
abstract class BaseAction extends StandardJaxrsAction {
Ehcache pageCache = ApplicationCache.instance().getCache(Page.class);
CacheCategory pageCache = new CacheCategory(Page.class);
protected boolean isNotLoginPage(String id) throws Exception {
return !(Config.portal().getIndexPage().getEnable()
......
......@@ -10,15 +10,15 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGetImported extends BaseAction {
......@@ -26,10 +26,10 @@ class ActionGetImported extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalId);
Element element = CACHE.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalId);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
} else {
Business business = new Business(emc);
Portal portal = business.portal().pick(portalId);
......@@ -59,7 +59,7 @@ class ActionGetImported extends BaseAction {
}
wo.setImportedList(imported);
wo.setText(buffer.toString());
CACHE.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
result.setData(wo);
return result;
......
package com.x.portal.assemble.surface.jaxrs.script;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.core.entity.Script;
import net.sf.ehcache.Ehcache;
import com.x.base.core.project.cache.Cache.CacheCategory;
abstract class BaseAction extends StandardJaxrsAction {
protected Ehcache CACHE = ApplicationCache.instance().getCache(Script.class);
protected CacheCategory cache = new CacheCategory(Script.class);
}
......@@ -5,14 +5,14 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Widget;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGetWithPortal extends BaseAction {
......@@ -21,10 +21,10 @@ class ActionGetWithPortal extends BaseAction {
Wo wo = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalFlag);
Element element = widgetCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalFlag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
Portal portal = business.portal().pick(wo.getPortal());
if (!business.portal().visible(effectivePerson, portal)) {
throw new ExceptionPortalAccessDenied(effectivePerson.getDistinguishedName(), portal.getName(),
......@@ -45,7 +45,7 @@ class ActionGetWithPortal extends BaseAction {
}
wo = Wo.copier.copy(widget);
wo.setData(widget.getDataOrMobileData());
widgetCache.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
result.setData(wo);
return result;
......
......@@ -5,14 +5,14 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.portal.assemble.surface.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Widget;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
class ActionGetWithPortalMobile extends BaseAction {
......@@ -21,10 +21,10 @@ class ActionGetWithPortalMobile extends BaseAction {
Wo wo = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, portalFlag);
Element element = widgetCache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
wo = (Wo) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, portalFlag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
Portal portal = business.portal().pick(wo.getPortal());
if (!business.portal().visible(effectivePerson, portal)) {
throw new ExceptionPortalAccessDenied(effectivePerson.getDistinguishedName(), portal.getName(),
......@@ -45,7 +45,7 @@ class ActionGetWithPortalMobile extends BaseAction {
}
wo = Wo.copier.copy(widget);
wo.setData(widget.getMobileDataOrData());
widgetCache.put(new Element(cacheKey, wo));
CacheManager.put(cache, cacheKey, wo);
}
result.setData(wo);
return result;
......
package com.x.portal.assemble.surface.jaxrs.widget;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.portal.core.entity.Widget;
import net.sf.ehcache.Ehcache;
import com.x.base.core.project.cache.Cache.CacheCategory;
abstract class BaseAction extends StandardJaxrsAction {
Ehcache widgetCache = ApplicationCache.instance().getCache(Widget.class);
CacheCategory cache = new CacheCategory(Widget.class);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册