Java Code Examples for org.apache.commons.collections4.set.ListOrderedSet#asList()

The following examples show how to use org.apache.commons.collections4.set.ListOrderedSet#asList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
public List<String> listSupNestedWithPerson(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<>();
	List<String> list = new ArrayList<>();
	for (String o : this.listSupDirectWithPerson(id)) {
		if (!set.contains(o)) {
			list.add(o);
		}
	}
	if (!list.isEmpty()) {
		set.addAll(list);
		for (String str : list) {
			this.supNested(str, set);
		}
	}
	return set.asList();
}
 
Example 2
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
public List<String> listSupNestedWithPerson(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<>();
	List<String> list = new ArrayList<>();
	for (String o : this.listSupDirectWithPerson(id)) {
		if (!set.contains(o)) {
			list.add(o);
		}
	}
	if (!list.isEmpty()) {
		set.addAll(list);
		for (String str : list) {
			this.supNested(str, set);
		}
	}
	return set.asList();
}
 
Example 3
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
public List<String> listSupNestedWithPerson(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<>();
	List<String> list = new ArrayList<>();
	for (String o : this.listSupDirectWithPerson(id)) {
		if (!set.contains(o)) {
			list.add(o);
		}
	}
	if (!list.isEmpty()) {
		set.addAll(list);
		for (String str : list) {
			this.supNested(str, set);
		}
	}
	return set.asList();
}
 
Example 4
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
public List<String> listSupNestedWithPerson(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<>();
	List<String> list = new ArrayList<>();
	for (String o : this.listSupDirectWithPerson(id)) {
		if (!set.contains(o)) {
			list.add(o);
		}
	}
	if (!list.isEmpty()) {
		set.addAll(list);
		for (String str : list) {
			this.supNested(str, set);
		}
	}
	return set.asList();
}
 
Example 5
Source File: Folder2Factory.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public List<String> listSubNested(String id, String status) throws Exception {
	ListOrderedSet<String> list = new ListOrderedSet<>();
	List<String> subs = this.listSubDirect(id, status);
	for (String str : subs) {
		if (!list.contains(str)) {
			list.add(str);
			list.addAll(this.listSubNested(str, status));
		}
	}
	return list.asList();
}
 
Example 6
Source File: FolderFactory.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public List<String> listSubNested(String id) throws Exception {
	ListOrderedSet<String> list = new ListOrderedSet<>();
	List<String> subs = this.listSubDirect(id);
	for (String str : subs) {
		if (!list.contains(str)) {
			list.add(str);
			list.addAll(this.listSubNested(str));
		}
	}
	return list.asList();
}
 
Example 7
Source File: ActionDelete.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<Wo> result = new ActionResult<>();
		Business business = new Business(emc);
		Share share = emc.find(id, Share.class);
		if (null == share) {
			throw new ExceptionAttachmentNotExist(id);
		}
		/* 判断文件的所有者是否是当前用户 */
		if (!StringUtils.equals(effectivePerson.getDistinguishedName(), share.getPerson())) {
			throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
		}
		EntityManager em = emc.beginTransaction(Share.class);
		emc.delete(Share.class, share.getId());
		em.getTransaction().commit();
		if(!"password".equals(share.getShareType())){
			List<String> shareCancels = new ArrayList<>();
			shareCancels.addAll(share.getShareUserList());
			if(!share.getShareOrgList().isEmpty()){
				shareCancels.addAll(business.organization().person().listWithUnitSubNested( share.getShareOrgList() ));
			}
			ListOrderedSet<String> set = new ListOrderedSet<>();
			set.addAll(shareCancels);
			shareCancels = set.asList();
			/* 发送取消共享通知 */
			for (String str : shareCancels) {
				this.message_send_attachment_shareCancel(share, str);
			}
		}
		Wo wo = new Wo();
		wo.setValue(true);
		result.setData(wo);
		return result;
	}
}
 
Example 8
Source File: Folder2Factory.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public List<String> listSubNested(String id, String status) throws Exception {
	ListOrderedSet<String> list = new ListOrderedSet<>();
	List<String> subs = this.listSubDirect(id, status);
	for (String str : subs) {
		if (!list.contains(str)) {
			list.add(str);
			list.addAll(this.listSubNested(str, status));
		}
	}
	return list.asList();
}
 
Example 9
Source File: FolderFactory.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public List<String> listSubNested(String id) throws Exception {
	ListOrderedSet<String> list = new ListOrderedSet<>();
	List<String> subs = this.listSubDirect(id);
	for (String str : subs) {
		if (!list.contains(str)) {
			list.add(str);
			list.addAll(this.listSubNested(str));
		}
	}
	return list.asList();
}
 
Example 10
Source File: ActionDelete.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<Wo> result = new ActionResult<>();
		Business business = new Business(emc);
		Share share = emc.find(id, Share.class);
		if (null == share) {
			throw new ExceptionAttachmentNotExist(id);
		}
		/* 判断文件的所有者是否是当前用户 */
		if (!StringUtils.equals(effectivePerson.getDistinguishedName(), share.getPerson())) {
			throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
		}
		EntityManager em = emc.beginTransaction(Share.class);
		emc.delete(Share.class, share.getId());
		em.getTransaction().commit();
		if(!"password".equals(share.getShareType())){
			List<String> shareCancels = new ArrayList<>();
			shareCancels.addAll(share.getShareUserList());
			if(!share.getShareOrgList().isEmpty()){
				shareCancels.addAll(business.organization().person().listWithUnitSubNested( share.getShareOrgList() ));
			}
			ListOrderedSet<String> set = new ListOrderedSet<>();
			set.addAll(shareCancels);
			shareCancels = set.asList();
			/* 发送取消共享通知 */
			for (String str : shareCancels) {
				this.message_send_attachment_shareCancel(share, str);
			}
		}
		Wo wo = new Wo();
		wo.setValue(true);
		result.setData(wo);
		return result;
	}
}
 
Example 11
Source File: StringTools.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public static List<String> trimUnique(List<String> list) {
	ListOrderedSet<String> set = new ListOrderedSet<>();
	if ((null != list) && (!list.isEmpty())) {
		for (String str : list) {
			if (StringUtils.isNotBlank(str)) {
				set.add(str);
			}
		}
	}
	return new ArrayList<String>(set.asList());
}
 
Example 12
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public List<String> listSubNested(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<String>();
	this.subNested(id, set);
	return set.asList();
}
 
Example 13
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public List<String> listSupNested(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<>();
	this.supNested(id, set);
	return set.asList();
}
 
Example 14
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public List<String> listSupNested(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<>();
	this.supNested(id, set);
	return set.asList();
}
 
Example 15
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public List<String> listSubNested(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<String>();
	this.subNested(id, set);
	return set.asList();
}
 
Example 16
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public List<String> listSupNested(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<>();
	this.supNested(id, set);
	return set.asList();
}
 
Example 17
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public List<String> listSubNested(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<String>();
	this.subNested(id, set);
	return set.asList();
}
 
Example 18
Source File: ActionCreate.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<Wo> result = new ActionResult<>();
		Business business = new Business(emc);
		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
		if (StringUtils.isEmpty(wi.getFileId())) {
			throw new ExceptionShareNameEmpty();
		}
		if (StringUtils.isEmpty(wi.getShareType())) {
			throw new Exception("shareType can not be empty.");
		}
		Share share = business.share().getShareByFileId(wi.getFileId(),effectivePerson.getDistinguishedName());
		boolean isExist = true;
		List<String> oldUserList = new ArrayList<>();
		List<String> oldOrgList = new ArrayList<>();
		if(share == null) {
			share = Wi.copier.copy(wi);
			isExist = false;
		}else{
			oldUserList.addAll(share.getShareUserList());
			oldOrgList.addAll(share.getShareOrgList());
			share.setPassword(wi.getPassword());
			share.setShareUserList(wi.getShareUserList());
			share.setShareOrgList(wi.getShareOrgList());
			share.setShareType(wi.getShareType());
		}
		if("password".equals(wi.getShareType())){
			if(StringUtils.isBlank(share.getPassword())){
				throw new Exception("password can not be empty.");
			}
		}else{
			if((wi.getShareUserList()==null || wi.getShareUserList().isEmpty()) &&
					(wi.getShareOrgList()==null || wi.getShareOrgList().isEmpty())){
				throw new Exception("shareUserList or shareOrgList can not be empty.");
			}
		}
		Attachment2 attachment = emc.find(wi.getFileId(), Attachment2.class);
		if(attachment == null) {
			Folder2 folder = emc.find(wi.getFileId(), Folder2.class);
			if(folder==null){
				throw new ExceptionShareNotExist(wi.getFileId());
			}else{
				if (!effectivePerson.isManager() && !StringUtils.equals(folder.getPerson(), effectivePerson.getDistinguishedName())) {
					throw new Exception("person{name:" + effectivePerson.getDistinguishedName() + "} access folder{id:" + wi.getFileId()
							+ "} denied.");
				}
				share.setFileType("folder");
				share.setName(folder.getName());
				share.setPerson(folder.getPerson());
			}
		}else{
			if (!effectivePerson.isManager() && !StringUtils.equals(attachment.getPerson(), effectivePerson.getDistinguishedName())) {
				throw new Exception("person{name:" + effectivePerson.getDistinguishedName() + "} access att{id:" + wi.getFileId()
						+ "} denied.");
			}
			share.setFileType("attachment");
			share.setName(attachment.getName());
			share.setLength(attachment.getLength());
			share.setExtension(attachment.getExtension());
			share.setPerson(attachment.getPerson());
		}
		share.setLastUpdateTime(new Date());
		if(share.getValidTime()==null){
			share.setValidTime(DateTools.getDateAfterYearAdjust(new Date(),100,null,null));
		}

		emc.beginTransaction(Share.class);
		if(isExist){
			emc.check(share, CheckPersistType.all);
		}else {
			emc.persist(share, CheckPersistType.all);
		}
		emc.commit();
		if(!"password".equals(wi.getShareType())){
			if(!oldOrgList.isEmpty()){
				oldUserList.addAll(business.organization().person().listWithUnitSubNested( oldOrgList ));
			}
			List<String> newUserList = new ArrayList<>();
			newUserList.addAll(share.getShareUserList());
			if(!share.getShareOrgList().isEmpty()){
				newUserList.addAll(business.organization().person().listWithUnitSubNested( share.getShareOrgList() ));
			}
			List<String> shareAdds = ListUtils.subtract(newUserList, oldOrgList);
			ListOrderedSet<String> set = new ListOrderedSet<>();
			set.addAll(shareAdds);
			shareAdds = set.asList();
			/* 发送共享通知 */
			for (String str : shareAdds) {
				this.message_send_attachment_share(share, str);
			}
		}
		Wo wo = new Wo();
		wo.setId(share.getId());
		result.setData(wo);
		return result;
	}
}
 
Example 19
Source File: ActionCreate.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<Wo> result = new ActionResult<>();
		Business business = new Business(emc);
		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
		if (StringUtils.isEmpty(wi.getFileId())) {
			throw new ExceptionShareNameEmpty();
		}
		if (StringUtils.isEmpty(wi.getShareType())) {
			throw new Exception("shareType can not be empty.");
		}
		Share share = business.share().getShareByFileId(wi.getFileId(),effectivePerson.getDistinguishedName());
		boolean isExist = true;
		List<String> oldUserList = new ArrayList<>();
		List<String> oldOrgList = new ArrayList<>();
		if(share == null) {
			share = Wi.copier.copy(wi);
			isExist = false;
		}else{
			oldUserList.addAll(share.getShareUserList());
			oldOrgList.addAll(share.getShareOrgList());
			share.setPassword(wi.getPassword());
			share.setShareUserList(wi.getShareUserList());
			share.setShareOrgList(wi.getShareOrgList());
			share.setShareType(wi.getShareType());
		}
		if("password".equals(wi.getShareType())){
			if(StringUtils.isBlank(share.getPassword())){
				throw new Exception("password can not be empty.");
			}
		}else{
			if((wi.getShareUserList()==null || wi.getShareUserList().isEmpty()) &&
					(wi.getShareOrgList()==null || wi.getShareOrgList().isEmpty())){
				throw new Exception("shareUserList or shareOrgList can not be empty.");
			}
		}
		Attachment2 attachment = emc.find(wi.getFileId(), Attachment2.class);
		if(attachment == null) {
			Folder2 folder = emc.find(wi.getFileId(), Folder2.class);
			if(folder==null){
				throw new ExceptionShareNotExist(wi.getFileId());
			}else{
				if (!effectivePerson.isManager() && !StringUtils.equals(folder.getPerson(), effectivePerson.getDistinguishedName())) {
					throw new Exception("person{name:" + effectivePerson.getDistinguishedName() + "} access folder{id:" + wi.getFileId()
							+ "} denied.");
				}
				share.setFileType("folder");
				share.setName(folder.getName());
				share.setPerson(folder.getPerson());
			}
		}else{
			if (!effectivePerson.isManager() && !StringUtils.equals(attachment.getPerson(), effectivePerson.getDistinguishedName())) {
				throw new Exception("person{name:" + effectivePerson.getDistinguishedName() + "} access att{id:" + wi.getFileId()
						+ "} denied.");
			}
			share.setFileType("attachment");
			share.setName(attachment.getName());
			share.setLength(attachment.getLength());
			share.setExtension(attachment.getExtension());
			share.setPerson(attachment.getPerson());
		}
		share.setLastUpdateTime(new Date());
		if(share.getValidTime()==null){
			share.setValidTime(DateTools.getDateAfterYearAdjust(new Date(),100,null,null));
		}

		emc.beginTransaction(Share.class);
		if(isExist){
			emc.check(share, CheckPersistType.all);
		}else {
			emc.persist(share, CheckPersistType.all);
		}
		emc.commit();
		if(!"password".equals(wi.getShareType())){
			if(!oldOrgList.isEmpty()){
				oldUserList.addAll(business.organization().person().listWithUnitSubNested( oldOrgList ));
			}
			List<String> newUserList = new ArrayList<>();
			newUserList.addAll(share.getShareUserList());
			if(!share.getShareOrgList().isEmpty()){
				newUserList.addAll(business.organization().person().listWithUnitSubNested( share.getShareOrgList() ));
			}
			List<String> shareAdds = ListUtils.subtract(newUserList, oldOrgList);
			ListOrderedSet<String> set = new ListOrderedSet<>();
			set.addAll(shareAdds);
			shareAdds = set.asList();
			/* 发送共享通知 */
			for (String str : shareAdds) {
				this.message_send_attachment_share(share, str);
			}
		}
		Wo wo = new Wo();
		wo.setId(share.getId());
		result.setData(wo);
		return result;
	}
}
 
Example 20
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public List<String> listSubNested(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<String>();
	this.subNested(id, set);
	return set.asList();
}