|
@@ -9,6 +9,7 @@ import com.bosshand.virgo.file.model.FileNodeProject;
|
|
import com.bosshand.virgo.file.model.FileNodeUserSetPermissions;
|
|
import com.bosshand.virgo.file.model.FileNodeUserSetPermissions;
|
|
import com.bosshand.virgo.file.service.FileNodeManagerService;
|
|
import com.bosshand.virgo.file.service.FileNodeManagerService;
|
|
import com.bosshand.virgo.file.util.AliyunOSSUtil;
|
|
import com.bosshand.virgo.file.util.AliyunOSSUtil;
|
|
|
|
+import com.bosshand.virgo.file.util.Doc2Pdf;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -137,6 +138,54 @@ public class FileNodeManagerController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @RequestMapping(value = "/fileNodeOrganization/{id}/type/{xx}", method = RequestMethod.GET)
|
|
|
|
+ public void getFileNodeOrganizationTo(@PathVariable int id, @PathVariable String xx, final HttpServletResponse response) {
|
|
|
|
+ logger.info("Ready to get file byte on parentId:" + id);
|
|
|
|
+ byte[] data = null;
|
|
|
|
+ OutputStream outputStream = null;
|
|
|
|
+ try {
|
|
|
|
+ data = fileNodeManagerService.getFileNodeOrganizationNode(id);
|
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
|
+ response.setContentType("application/x-msdownload");
|
|
|
|
+ response.setHeader("Content-Disposition","attachment; filename=" + URLEncoder.encode(xx, "UTF-8"));
|
|
|
|
+ OutputStream outputSream = response.getOutputStream();
|
|
|
|
+ outputSream.write(data);
|
|
|
|
+ outputSream.flush();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new BadRequestException("Fail to write stream", Constant.RET_DOCUMENT_ERROR, e);
|
|
|
|
+ } finally {
|
|
|
|
+ if (outputStream != null) {
|
|
|
|
+ try {
|
|
|
|
+ outputStream.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @RequestMapping(value = "/fileNodeOrganization/{id}/renderPdf", method = RequestMethod.GET)
|
|
|
|
+ public Response fileNodeOrganizationRenderPdf( @PathVariable int id , final HttpServletResponse response) {
|
|
|
|
+ byte[] data = null;
|
|
|
|
+ OutputStream outputStream = null;
|
|
|
|
+ try {
|
|
|
|
+ data = fileNodeManagerService.getFileNodeOrganizationNode(id);
|
|
|
|
+ outputStream = response.getOutputStream();
|
|
|
|
+ outputStream.write(Doc2Pdf.doc2pdf(data));
|
|
|
|
+ outputStream.flush();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new BadRequestException("Incorrect file kannode",Constant.RET_DOCUMENT_ERROR, e);
|
|
|
|
+ }finally {
|
|
|
|
+ if(outputStream != null) {
|
|
|
|
+ try {
|
|
|
|
+ outputStream.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return Response.ok();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
//*****************************************************************
|
|
//*****************************************************************
|
|
// FileNodeProject
|
|
// FileNodeProject
|
|
//*****************************************************************
|
|
//*****************************************************************
|
|
@@ -200,6 +249,54 @@ public class FileNodeManagerController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @RequestMapping(value = "/fileNodeProject/{id}/type/{xx}", method = RequestMethod.GET)
|
|
|
|
+ public void getFileTo(@PathVariable int id, @PathVariable String xx, final HttpServletResponse response) {
|
|
|
|
+ logger.info("Ready to get file byte on parentId:" + id);
|
|
|
|
+ byte[] data = null;
|
|
|
|
+ OutputStream outputStream = null;
|
|
|
|
+ try {
|
|
|
|
+ data = fileNodeManagerService.getFileNodeProjectNode(id);
|
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
|
+ response.setContentType("application/x-msdownload");
|
|
|
|
+ response.setHeader("Content-Disposition","attachment; filename=" + URLEncoder.encode(xx, "UTF-8"));
|
|
|
|
+ OutputStream outputSream = response.getOutputStream();
|
|
|
|
+ outputSream.write(data);
|
|
|
|
+ outputSream.flush();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new BadRequestException("Fail to write stream", Constant.RET_DOCUMENT_ERROR, e);
|
|
|
|
+ } finally {
|
|
|
|
+ if (outputStream != null) {
|
|
|
|
+ try {
|
|
|
|
+ outputStream.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @RequestMapping(value = "/fileNodeProject/{id}/renderPdf", method = RequestMethod.GET)
|
|
|
|
+ public Response renderPdf( @PathVariable int id , final HttpServletResponse response) {
|
|
|
|
+ byte[] data = null;
|
|
|
|
+ OutputStream outputStream = null;
|
|
|
|
+ try {
|
|
|
|
+ data = fileNodeManagerService.getFileNodeProjectNode(id);
|
|
|
|
+ outputStream = response.getOutputStream();
|
|
|
|
+ outputStream.write(Doc2Pdf.doc2pdf(data));
|
|
|
|
+ outputStream.flush();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new BadRequestException("Incorrect file kannode",Constant.RET_DOCUMENT_ERROR, e);
|
|
|
|
+ }finally {
|
|
|
|
+ if(outputStream != null) {
|
|
|
|
+ try {
|
|
|
|
+ outputStream.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return Response.ok();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
//*****************************************************************
|
|
//*****************************************************************
|
|
// SetPermissions
|
|
// SetPermissions
|