提交 65a0b9fa 编写于 作者: O o2sword

修复附件下载权限校验

上级 64ad2063
......@@ -7,6 +7,7 @@ import java.util.Set;
import com.x.cms.core.entity.CategoryInfo;
import com.x.cms.core.entity.Document;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
......@@ -499,6 +500,34 @@ public class Business {
return publishFlag;
}
/**
* 是否是文档的读者
* @param person
* @return
* @throws Exception
*/
public boolean isDocumentReader(EffectivePerson person, Document document) throws Exception {
if (isManager(person)) {
return true;
}
String documentType = "数据";
if(documentType.equals(document.getDocumentType())){
return true;
}
if(BooleanUtils.isTrue(document.getIsAllRead())){
return true;
}
Long count = this.reviewFactory().countByDocumentAndPerson(document.getId(), person.getDistinguishedName());
if(count > 0){
return true;
}
count = this.reviewFactory().countByDocumentAndPerson(document.getId(), "*");
if(count > 0){
return true;
}
return false;
}
/**
* TODO (uncomplete)判断用户是否有权限进行:[表单模板管理]操作
*
......
......@@ -26,7 +26,7 @@ import com.x.cms.core.express.tools.filter.QueryFilter;
* 文档权限控制信息服务类
*/
public class ReviewFactory extends AbstractFactory {
public ReviewFactory( Business business) throws Exception {
super(business);
}
......@@ -34,7 +34,18 @@ public class ReviewFactory extends AbstractFactory {
public Review get( String id ) throws Exception {
return this.entityManagerContainer().find(id, Review.class, ExceptionWhen.none);
}
public Long countByDocumentAndPerson(String docId, String person) throws Exception {
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Review> root = cq.from(Review.class);
Predicate p = cb.equal( root.get(Review_.docId), docId );
p = cb.and( p, cb.equal( root.get( Review_.permissionObj ), person));
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
public List<String> listByAppId( String appId, Integer maxCount ) throws Exception {
if( maxCount == null ) {
maxCount = 1000;
......@@ -47,7 +58,7 @@ public class ReviewFactory extends AbstractFactory {
cq.select( root.get( Review_.id) ).where(p);
return em.createQuery( cq ).setMaxResults(maxCount).getResultList();
}
public List<String> listByCategoryId( String categoryId, Integer maxCount ) throws Exception {
if( maxCount == null ) {
maxCount = 1000;
......@@ -60,7 +71,7 @@ public class ReviewFactory extends AbstractFactory {
cq.select(root.get( Review_.id)).where(p);
return em.createQuery( cq ).setMaxResults(maxCount).getResultList();
}
public List<String> listByDocument( String docId, Integer maxCount ) throws Exception {
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
......@@ -69,8 +80,8 @@ public class ReviewFactory extends AbstractFactory {
Predicate p = cb.equal(root.get( Review_.docId ), docId );
cq.select(root.get( Review_.id)).where(p);
return em.createQuery( cq ).setMaxResults(maxCount).getResultList();
}
}
public List<String> listByDocumentAndPerson(String docId, String person) throws Exception {
if( StringUtils.isEmpty( docId ) ) {
throw new Exception("doc id can not be empty!");
......@@ -87,7 +98,7 @@ public class ReviewFactory extends AbstractFactory {
cq.select(root.get( Review_.id)).where(p);
return em.createQuery( cq ).getResultList();
}
public Long countByCategoryId( String categoryId ) throws Exception {
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
......@@ -97,7 +108,7 @@ public class ReviewFactory extends AbstractFactory {
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
public Long countByDocuemnt( String docId ) throws Exception {
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
......@@ -107,7 +118,7 @@ public class ReviewFactory extends AbstractFactory {
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
public Long countByAppId( String appId ) throws Exception {
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
......@@ -117,7 +128,7 @@ public class ReviewFactory extends AbstractFactory {
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
/**
* 根据条件查询符合条件的文档信息数量
* @param personName
......@@ -138,7 +149,7 @@ public class ReviewFactory extends AbstractFactory {
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
/**
* 根据条件查询符合条件的文档信息ID
* @param maxCount
......@@ -159,7 +170,7 @@ public class ReviewFactory extends AbstractFactory {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.equal( root.get( Review_.permissionObj ), personName ) );
}
Predicate p = CriteriaBuilderTools.composePredicateWithQueryFilter( Review_.class, cb, p_permission, root, queryFilter );
List<Order> orders = new ArrayList<>();
if( !Review.isTop_FIELDNAME.equals( orderField )) {
Order isTopOrder = CriteriaBuilderTools.getOrder( cb, root, Review_.class, Review.isTop_FIELDNAME, "desc" );
......@@ -176,9 +187,9 @@ public class ReviewFactory extends AbstractFactory {
}
return em.createQuery(cq.where(p)).setMaxResults( maxCount).getResultList();
}
/**
* 根据条件查询符合条件的文档信息ID,根据上一条的sequnce查询指定数量的信息
* @param maxCount
......@@ -209,7 +220,7 @@ public class ReviewFactory extends AbstractFactory {
}
p = cb.and( p, p_seq);
}
List<Order> orders = new ArrayList<>();
if( !Document.isTop_FIELDNAME.equals( orderField )) {
Order isTopOrder = CriteriaBuilderTools.getOrder( cb, root, Document_.class, Document.isTop_FIELDNAME, "desc" );
......@@ -217,12 +228,12 @@ public class ReviewFactory extends AbstractFactory {
orders.add( isTopOrder );
}
}
Order orderWithField = CriteriaBuilderTools.getOrder( cb, root, Review_.class, orderField, orderType );
if( orderWithField != null ){
orders.add( orderWithField );
}
if( ListTools.isNotEmpty( orders )) {
cq.orderBy( orders );
}
......@@ -299,27 +310,27 @@ public class ReviewFactory extends AbstractFactory {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.equal( root.get( Review_.permissionObj ), personName ) );
}
Predicate p = CriteriaBuilderTools.composePredicateWithQueryFilter( Review_.class, cb, p_permission, root, queryFilter );
//排序,添加排序列,默认使用sequence
List<Order> orders = new ArrayList<>();
Order orderWithField = CriteriaBuilderTools.getOrder( cb, root, Review_.class, orderField, orderType );
if( orderWithField != null ){
orders.add( orderWithField );
}
if( !Document.isFieldInSequence(orderField)) {
//如果是其他的列,很可能排序值不唯一,所以使用多一列排序列来确定每次查询的顺序
orderWithField = CriteriaBuilderTools.getOrder( cb, root, Review_.class, Review.id_FIELDNAME, orderType );
if( orderWithField != null ){
orders.add( orderWithField );
}
}
}
if( ListTools.isNotEmpty( orders )){
cq.orderBy( orders );
}
return em.createQuery(cq.where(p)).setMaxResults( maxCount).getResultList();
}
public List<String> listDocIdsWithConditionInReview(String personName, QueryFilter queryFilter, Integer maxCount) throws Exception {
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
......@@ -331,10 +342,10 @@ public class ReviewFactory extends AbstractFactory {
}
Predicate p = CriteriaBuilderTools.composePredicateWithQueryFilter( Review_.class, cb, p_permission, root, queryFilter );
cq.select(root.get( Review_.docId )).where(p);
return em.createQuery(cq.where(p)).setMaxResults( maxCount).getResultList();
}
public List<String> listDocIdsWithConditionInReview(String personName, String orderField, String orderType, QueryFilter queryFilter, Integer maxCount) throws Exception {
List<String> docIds = new ArrayList<>();
EntityManager em = this.entityManagerContainer().get( Review.class );
......@@ -361,4 +372,4 @@ public class ReviewFactory extends AbstractFactory {
}
return docIds;
}
}
\ No newline at end of file
}
......@@ -121,10 +121,6 @@ public class ActionQueryViewDocument extends BaseAction {
List<String> groupNames = null;
Boolean isAnonymous = effectivePerson.isAnonymous();
String personName = effectivePerson.getDistinguishedName();
Business business = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
}
if( !isAnonymous ) {
try {
......@@ -301,39 +297,32 @@ public class ActionQueryViewDocument extends BaseAction {
if ( isManager || isAppAdmin || isCategoryAdmin || isCreator ) {
isEditor = true;
} else {
// 判断当前登录者是不是该文档的可编辑者
try {
if( !isAnonymous ) {
if( ListTools.isNotEmpty( document.getAuthorPersonList() )) {
if( document.getAuthorPersonList().contains( getShortTargetFlag(personName) ) ) {
isEditor = true;
}
if( !isAnonymous ) {
if( ListTools.isNotEmpty( document.getAuthorPersonList() )) {
if( document.getAuthorPersonList().contains( getShortTargetFlag(personName) ) ) {
isEditor = true;
}
if( ListTools.isNotEmpty( document.getAuthorUnitList() )) {
if( ListTools.containsAny( getShortTargetFlag(unitNames), document.getAuthorUnitList())) {
isEditor = true;
}
}
if( ListTools.isNotEmpty( document.getAuthorUnitList() )) {
if( ListTools.containsAny( getShortTargetFlag(unitNames), document.getAuthorUnitList())) {
isEditor = true;
}
if( ListTools.isNotEmpty( document.getAuthorGroupList() )) {
if( ListTools.containsAny( getShortTargetFlag(groupNames), document.getAuthorGroupList())) {
isEditor = true;
}
}
if( ListTools.isNotEmpty( document.getAuthorGroupList() )) {
if( ListTools.containsAny( getShortTargetFlag(groupNames), document.getAuthorGroupList())) {
isEditor = true;
}
}
} catch (Exception e) {
check = false;
Exception exception = new ExceptionDocumentInfoProcess(e, "判断用户是否可编辑文档时发生异常!user:" + personName);
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
}
if(!isEditor) {
check = this.hasReadPermission(business, document, unitNames, groupNames, effectivePerson, null);
if (!check) {
throw new ExceptionAccessDenied(effectivePerson, document);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
if(!business.isDocumentReader(effectivePerson, document)){
throw new ExceptionAccessDenied(effectivePerson, document);
}
}
}
......
package com.x.cms.assemble.control.jaxrs.fileinfo;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.annotation.AuditLog;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.config.StorageMapping;
import com.x.base.core.project.exception.ExceptionAccessDenied;
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.cms.assemble.control.Business;
import com.x.cms.assemble.control.ThisApplication;
import com.x.cms.core.entity.Document;
import com.x.cms.core.entity.FileInfo;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
/**
* 下载附件
* @author sword
*/
public class ActionFileDownload extends BaseAction {
@AuditLog(operation = "下载附件")
protected ActionResult<Wo> execute( HttpServletRequest request, EffectivePerson effectivePerson, String id, String fileName) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
FileInfo attachment = fileInfoServiceAdv.get(id);
if ( null == attachment ) {
throw new Exception("附件不存在。id:" + id ) ;
}else {
StorageMapping mapping = ThisApplication.context().storageMappings().get(FileInfo.class, attachment.getStorage());
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
FileInfo fileInfo = emc.find(id, FileInfo.class);
if (null == fileInfo) {
throw new ExceptionFileInfoNotExists(id);
}
if (StringUtils.isBlank(fileName)) {
fileName = attachment.getName();
fileName = fileInfo.getName();
} else {
String extension = FilenameUtils.getExtension(fileName);
if (StringUtils.isEmpty(extension)) {
fileName = fileName + "." + attachment.getExtension();
fileName = fileName + "." + fileInfo.getExtension();
}
}
Wo wo = new Wo(attachment.readContent(mapping),
Document document = emc.find(fileInfo.getDocumentId(), Document.class);
if (null == document) {
throw new ExceptionDocumentNotExists(fileInfo.getDocumentId());
}
Business business = new Business(emc);
if (!business.isDocumentReader(effectivePerson, document)) {
throw new ExceptionAccessDenied(effectivePerson);
}
StorageMapping mapping = ThisApplication.context().storageMappings().get(FileInfo.class, fileInfo.getStorage());
Wo wo = new Wo(fileInfo.readContent(mapping),
this.contentType(false, fileName),
this.contentDisposition(false, fileName));
result.setData(wo);
......
package com.x.cms.assemble.control.jaxrs.fileinfo;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.annotation.AuditLog;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.config.StorageMapping;
import com.x.base.core.project.exception.ExceptionAccessDenied;
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.cms.assemble.control.Business;
import com.x.cms.assemble.control.ThisApplication;
import com.x.cms.core.entity.Document;
import com.x.cms.core.entity.FileInfo;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
/**
* 下载附件
* @author sword
*/
public class ActionFileDownloadStream extends BaseAction {
@AuditLog(operation = "下载附件")
protected ActionResult<Wo> execute( HttpServletRequest request, EffectivePerson effectivePerson, String id, String fileName) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
FileInfo attachment = fileInfoServiceAdv.get(id);
if ( null == attachment ) {
throw new Exception("附件不存在。id:" + id ) ;
}else {
StorageMapping mapping = ThisApplication.context().storageMappings().get(FileInfo.class, attachment.getStorage());
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
FileInfo fileInfo = emc.find(id, FileInfo.class);
if (null == fileInfo) {
throw new ExceptionFileInfoNotExists(id);
}
if (StringUtils.isBlank(fileName)) {
fileName = attachment.getName();
fileName = fileInfo.getName();
} else {
String extension = FilenameUtils.getExtension(fileName);
if (StringUtils.isEmpty(extension)) {
fileName = fileName + "." + attachment.getExtension();
fileName = fileName + "." + fileInfo.getExtension();
}
}
Wo wo = new Wo(attachment.readContent(mapping),
this.contentType( true, fileName),
this.contentDisposition( true, fileName));
Document document = emc.find(fileInfo.getDocumentId(), Document.class);
if (null == document) {
throw new ExceptionDocumentNotExists(fileInfo.getDocumentId());
}
Business business = new Business(emc);
if (!business.isDocumentReader(effectivePerson, document)) {
throw new ExceptionAccessDenied(effectivePerson);
}
StorageMapping mapping = ThisApplication.context().storageMappings().get(FileInfo.class, fileInfo.getStorage());
Wo wo = new Wo(fileInfo.readContent(mapping),
this.contentType(true, fileName),
this.contentDisposition(true, fileName));
result.setData(wo);
}
return result;
......
......@@ -13,8 +13,10 @@ import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.Cache;
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;
import com.x.cms.assemble.control.Business;
import com.x.cms.core.entity.Document;
import com.x.cms.core.entity.FileInfo;
......@@ -23,8 +25,6 @@ public class ActionGet extends BaseAction {
protected ActionResult<Wo> execute( HttpServletRequest request, EffectivePerson effectivePerson, String id, String documentId ) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Wo wrap = null;
List<String> attachmentIds = null;
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), id );
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey );
......@@ -33,20 +33,19 @@ public class ActionGet extends BaseAction {
result.setData(wrap);
} else {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
//先查询附件是否该文档里的附件,从属关系是否正常
Document document = emc.find( documentId, Document.class);
if (null == document) {
throw new Exception("document{id:" + documentId + "} not existed.");
}
attachmentIds = fileInfoServiceAdv.listIdsWithDocId(documentId);
if ( attachmentIds == null || !attachmentIds.contains(id)) {
throw new Exception("document{id" + documentId + "} not contian attachment{id:" + id + "}.");
}
FileInfo fileInfo = emc.find(id, FileInfo.class);
if ( null == fileInfo ) {
throw new Exception("需要查询的附件或者文件信息不存在,请联系管理员。ID:" + id );
throw new ExceptionFileInfoNotExists(id);
}
Document document = emc.find( fileInfo.getDocumentId(), Document.class);
if (null == document) {
throw new ExceptionDocumentNotExists(fileInfo.getDocumentId());
}
Business business = new Business(emc);
if(!business.isDocumentReader(effectivePerson, document)){
throw new ExceptionAccessDenied(effectivePerson);
}
//如果信息存在,则需要向客户端返回信息,先将查询出来的JPA对象COPY到一个普通JAVA对象里,再进行返回
wrap = Wo.copier.copy( fileInfo );
CacheManager.put(cacheCategory, cacheKey, wrap );
result.setData(wrap);
......
package com.x.cms.assemble.control.service;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
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.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.organization.Identity;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.base.core.project.organization.Person;
import com.x.base.core.project.organization.Unit;
import com.x.base.core.project.tools.ListTools;
......@@ -19,6 +14,12 @@ import com.x.cms.assemble.control.Business;
import com.x.cms.assemble.control.ThisApplication;
import com.x.cms.core.entity.AppInfo;
import com.x.organization.core.entity.PersistenceProperties;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
/**
* 组织人员角色相关信息的服务类
......@@ -37,17 +38,14 @@ public class UserManagerService {
* @throws Exception
*/
public Person getPerson(String personName) throws Exception {
Person person = null;
try {
Business business = new Business(null);
if(personName.split("@").length == 2){
personName = personName.split("@")[0];
}
person = business.organization().person().getObject(personName);
} catch (Exception e) {
throw e;
if(StringUtils.isNotBlank(personName)){
return null;
}
Business business = new Business(null);
if(personName.split("@").length == 2){
personName = personName.split("@")[0];
}
return person;
return business.organization().person().getObject(personName);
}
/**
......@@ -65,12 +63,10 @@ public class UserManagerService {
Unit unit = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
unitNames = business.organization().unit().listWithPerson(personName);
if ( ListTools.isEmpty( unitNames )) {
if (personName.endsWith("@P") && personName.split("@P").length == 2) {
unitNames = business.organization().unit().listWithPerson( personName.split("@")[0] );
}
if(StringUtils.isNotBlank(personName) && personName.split("@").length == 2){
personName = personName.split("@")[0];
}
unitNames = business.organization().unit().listWithPerson(personName);
if ( ListTools.isNotEmpty( unitNames )) {
for (String unitName : unitNames) {
unit = business.organization().unit().getObject(unitName);
......@@ -94,17 +90,8 @@ public class UserManagerService {
* @throws Exception
*/
public String getUnitNameByIdentity(String identity) throws Exception {
Business business = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
return business.organization().unit().getWithIdentity(identity);
} catch (NullPointerException e) {
System.out.println("根据身份获取所属组织名称时发生NullPointerException异常。identity:" + identity);
return null;
} catch (Exception e) {
System.out.println("根据身份获取所属组织名称时发生异常。identity:" + identity);
throw e;
}
Business business = new Business(null);
return business.organization().unit().getWithIdentity(identity);
}
/**
......@@ -120,16 +107,14 @@ public class UserManagerService {
Business business = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
// 兼容一下传过来的perosnName有可能是个人,有可能是身份
if( StringUtils.isNotEmpty( personName )){
if (personName.endsWith("@P") && personName.split("@P").length == 2) {
personName = business.organization().person().get(personName.split("@")[0]);
}else{
personName = business.organization().person().get(personName);
if(!OrganizationDefinition.isPersonDistinguishedName(personName)){
if(personName.split("@").length == 2){
personName = personName.split("@")[0];
}
personName = business.organization().person().get(personName);
}
identity = getMajorIdentityWithPerson(personName);
if (identity != null && !identity.isEmpty()) {
if (StringUtils.isNotBlank(identity)) {
topUnitName = business.organization().unit().getWithIdentityWithLevel(identity, 1);
}
return topUnitName;
......@@ -168,8 +153,8 @@ public class UserManagerService {
Business business = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
if( StringUtils.isNotEmpty( personName )){
if (personName.endsWith("@P") && personName.split("@P").length == 2) {
if(!OrganizationDefinition.isPersonDistinguishedName(personName)){
if (personName.endsWith("@P") && personName.split("@").length == 2) {
personName = business.organization().person().get(personName.split("@")[0]);
}else{
personName = business.organization().person().get(personName);
......@@ -182,7 +167,7 @@ public class UserManagerService {
}else{
for (String identity : identities) {
Identity obj = business.organization().identity().getObject(identity);
if (obj.getMajor()) {
if (BooleanUtils.isTrue(obj.getMajor())) {
return identity;
}
}
......@@ -229,12 +214,8 @@ public class UserManagerService {
Business business = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
if( StringUtils.isNotEmpty( personName )){
if (personName.endsWith("@P") && personName.split("@P").length == 2) {
personName = business.organization().person().get(personName.split("@")[0]);
}else{
personName = business.organization().person().get(personName);
}
if( StringUtils.isNotEmpty( personName ) && personName.split("@").length == 2){
personName = personName.split("@")[0];
}
unitNames = business.organization().unit().listWithPersonSupNested(personName);
return unitNames == null ? new ArrayList<>() : unitNames;
......@@ -259,12 +240,8 @@ public class UserManagerService {
Business business = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
if( StringUtils.isNotEmpty( personName )){
if (personName.endsWith("@P") && personName.split("@P").length == 2) {
personName = business.organization().person().get(personName.split("@")[0]);
}else{
personName = business.organization().person().get(personName);
}
if( StringUtils.isNotEmpty( personName ) && personName.split("@").length == 2){
personName = personName.split("@")[0];
}
return business.organization().identity().listWithPerson(personName);
} catch (NullPointerException e) {
......@@ -288,7 +265,7 @@ public class UserManagerService {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
if( StringUtils.isNotEmpty( personName )){
if (personName.endsWith("@P") && personName.split("@P").length == 2) {
if (personName.endsWith("@P") && personName.split("@").length == 2) {
personName = business.organization().person().get(personName.split("@")[0]);
}else{
personName = business.organization().person().get(personName);
......@@ -319,12 +296,8 @@ public class UserManagerService {
List<String> nameList = new ArrayList<String>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
if( StringUtils.isNotEmpty( personName )){
if (personName.endsWith("@P") && personName.split("@P").length == 2) {
personName = business.organization().person().get(personName.split("@")[0]);
}else{
personName = business.organization().person().get(personName);
}
if( StringUtils.isNotEmpty( personName ) && personName.split("@").length == 2){
personName = personName.split("@")[0];
}
groupList = business.organization().group().listWithPerson(personName);
if (groupList != null && groupList.size() > 0) {
......@@ -357,12 +330,8 @@ public class UserManagerService {
Business business = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
if( StringUtils.isNotEmpty( personName )){
if (personName.endsWith("@P") && personName.split("@P").length == 2) {
personName = business.organization().person().get(personName.split("@")[0]);
}else{
personName = business.organization().person().get(personName);
}
if( StringUtils.isNotEmpty( personName ) && personName.split("@").length == 2){
personName = personName.split("@")[0];
}
roleList = business.organization().role().listWithPerson(personName);
if (roleList != null && !roleList.isEmpty()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册