|
@@ -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.http.EffectivePerson;
|
|
|
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
|
|
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
|
|
|
import com.x.base.core.project.jaxrs.WoFile;
|
|
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.assemble.control.ThisApplication;
|
|
|
import com.x.file.core.entity.open.OriginFile;
|
|
import com.x.file.core.entity.open.OriginFile;
|
|
|
import com.x.file.core.entity.personal.Attachment2;
|
|
import com.x.file.core.entity.personal.Attachment2;
|
|
@@ -15,10 +17,13 @@ import net.sf.ehcache.Ehcache;
|
|
|
import net.sf.ehcache.Element;
|
|
import net.sf.ehcache.Element;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
|
|
+import javax.persistence.EntityManager;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
|
|
|
class ActionDownload extends StandardJaxrsAction {
|
|
class ActionDownload extends StandardJaxrsAction {
|
|
|
|
|
|
|
|
|
|
+ private static Logger logger = LoggerFactory.getLogger( ActionDownload.class );
|
|
|
|
|
+
|
|
|
private Ehcache cache = ApplicationCache.instance().getCache(Attachment2.class);
|
|
private Ehcache cache = ApplicationCache.instance().getCache(Attachment2.class);
|
|
|
|
|
|
|
|
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
|
|
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
|
|
@@ -58,6 +63,14 @@ class ActionDownload extends StandardJaxrsAction {
|
|
|
if (bs.length < (1024 * 1024 * 10)) {
|
|
if (bs.length < (1024 * 1024 * 10)) {
|
|
|
cache.put(new Element(cacheKey, wo));
|
|
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);
|
|
result.setData(wo);
|