|
|
@@ -27,7 +27,7 @@ import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
|
|
|
-class ActionUploadCallback extends StandardJaxrsAction {
|
|
|
+class ActionUploadCallback extends BaseAction {
|
|
|
|
|
|
// @HttpMethodDescribe(value = "创建Attachment对象,如果没有上级目录用(0)替代.", response =
|
|
|
// WrapOutId.class)
|
|
|
@@ -67,7 +67,7 @@ class ActionUploadCallback extends StandardJaxrsAction {
|
|
|
throw new ExceptionEmptyExtensionCallback(callback, fileName);
|
|
|
}
|
|
|
/** 同一目录下文件名唯一 */
|
|
|
- if (this.exist(business, fileName, folderId)) {
|
|
|
+ if (this.exist(business, fileName, folderId, effectivePerson.getDistinguishedName())) {
|
|
|
throw new ExceptionSameNameFileExistCallback(callback, fileName);
|
|
|
}
|
|
|
if(StringUtils.isEmpty(fileMd5)){
|
|
|
@@ -109,20 +109,6 @@ class ActionUploadCallback extends StandardJaxrsAction {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private Boolean exist(Business business, String fileName, String folderId) throws Exception {
|
|
|
- EntityManager em = business.entityManagerContainer().get(Attachment2.class);
|
|
|
- CriteriaBuilder cb = em.getCriteriaBuilder();
|
|
|
- CriteriaQuery<Long> cq = cb.createQuery(Long.class);
|
|
|
- Root<Attachment2> root = cq.from(Attachment2.class);
|
|
|
- Predicate p = cb.equal(root.get(Attachment2_.name), fileName);
|
|
|
- if (StringUtils.isNotEmpty(folderId)) {
|
|
|
- p = cb.and(p, cb.equal(root.get(Attachment2_.folder), folderId));
|
|
|
- } else {
|
|
|
- p = cb.and(p, cb.or(cb.isNull(root.get(Attachment2_.folder)), cb.equal(root.get(Attachment2_.folder), "")));
|
|
|
- }
|
|
|
- return em.createQuery(cq.select(cb.count(root)).where(p)).getSingleResult() > 0;
|
|
|
- }
|
|
|
-
|
|
|
public static class Wo<T> extends WoCallback<T> {
|
|
|
public Wo(String callbackName, T t) {
|
|
|
super(callbackName, t);
|