提交 183cd14c 编写于 作者: NoSubject's avatar NoSubject

Merge branch 'fix/云文件bug修复' into 'develop'

Merge of fix/云文件bug修复 to develop

See merge request o2oa/o2oa!662
......@@ -8,6 +8,8 @@ import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.jaxrs.WoFile;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.file.assemble.control.ThisApplication;
import com.x.file.core.entity.open.OriginFile;
import com.x.file.core.entity.personal.Attachment2;
......@@ -15,10 +17,13 @@ import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import org.apache.commons.lang3.StringUtils;
import javax.persistence.EntityManager;
import java.io.ByteArrayOutputStream;
class ActionDownload extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger( ActionDownload.class );
private Ehcache cache = ApplicationCache.instance().getCache(Attachment2.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
......@@ -58,6 +63,14 @@ class ActionDownload extends StandardJaxrsAction {
if (bs.length < (1024 * 1024 * 10)) {
cache.put(new Element(cacheKey, wo));
}
}catch (Exception e){
if(e.getMessage().indexOf("existed") > -1){
logger.warn("原始附件{}-{}不存在,删除记录!", originFile.getId(), originFile.getName());
emc.beginTransaction(OriginFile.class);
emc.delete(OriginFile.class, originFile.getId());
emc.commit();
}
throw e;
}
}
result.setData(wo);
......
......@@ -8,6 +8,8 @@ import com.x.base.core.project.exception.ExceptionWhen;
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.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.file.assemble.control.ThisApplication;
import com.x.file.core.entity.open.OriginFile;
import com.x.file.core.entity.personal.Attachment2;
......@@ -24,6 +26,8 @@ import java.io.ByteArrayInputStream;
class ActionDownloadImageWidthHeight extends BaseAction {
private static Logger logger = LoggerFactory.getLogger( ActionDownloadImageWidthHeight.class );
private Ehcache cache = ApplicationCache.instance().getCache(ActionDownloadImageWidthHeight.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, Integer width, Integer height)
......@@ -81,6 +85,14 @@ class ActionDownloadImageWidthHeight extends BaseAction {
result.setData(wo);
}
}
}catch (Exception e){
if(e.getMessage().indexOf("existed") > -1){
logger.warn("原始附件{}-{}不存在,删除记录!", originFile.getId(), originFile.getName());
emc.beginTransaction(OriginFile.class);
emc.delete(OriginFile.class, originFile.getId());
emc.commit();
}
throw e;
}
}
......
......@@ -8,6 +8,8 @@ import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.jaxrs.WoFile;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.file.assemble.control.ThisApplication;
import com.x.file.core.entity.open.OriginFile;
import com.x.file.core.entity.personal.Attachment2;
......@@ -19,6 +21,8 @@ import java.io.ByteArrayOutputStream;
class ActionDownloadStream extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger( ActionDownloadStream.class );
private Ehcache cache = ApplicationCache.instance().getCache(Attachment2.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
......@@ -58,6 +62,14 @@ class ActionDownloadStream extends StandardJaxrsAction {
if (bs.length < (1024 * 1024 * 10)) {
cache.put(new Element(cacheKey, wo));
}
}catch (Exception e){
if(e.getMessage().indexOf("existed") > -1){
logger.warn("原始附件{}-{}不存在,删除记录!", originFile.getId(), originFile.getName());
emc.beginTransaction(OriginFile.class);
emc.delete(OriginFile.class, originFile.getId());
emc.commit();
}
throw e;
}
}
result.setData(wo);
......
......@@ -33,6 +33,9 @@ class ActionUpdate extends BaseAction {
}
emc.beginTransaction(Attachment2.class);
Wi.copier.copy(wi, attachment);
if (StringUtils.isEmpty(attachment.getFolder())) {
attachment.setFolder(Business.TOP_FOLD);
}
emc.check(attachment, CheckPersistType.all);
emc.commit();
Wo wo = new Wo();
......
......@@ -47,14 +47,16 @@ class ActionUpdate extends BaseAction {
List<String> ids = new ArrayList<>();
ids.add(folder.getId());
ids.addAll(business.folder2().listSubNested(folder.getId(), FileStatus.VALID.getName()));
if(ids.contains(folder.getSuperior())){
throw new Exception("superior can not be sub folder.");
if(ids.contains(wi.getSuperior())){
throw new Exception("无效父目录:"+wi.getSuperior()+",父目录不能为本目录及子目录.");
}
}else{
wi.setSuperior(Business.TOP_FOLD);
}
this.exist(business, effectivePerson, wi.getName(), wi.getSuperior(), folder.getId());
if(this.exist(business, effectivePerson, wi.getName(), wi.getSuperior(), folder.getId())){
throw new ExceptionFolderNameExist(effectivePerson.getName(), wi.getName(), wi.getSuperior());
}
emc.beginTransaction(Folder2.class);
folder.setName(wi.getName());
folder.setSuperior(wi.getSuperior());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册