use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.
the class UploadSupportUtils method findUpload.
public static SysUploadVO findUpload(String uploadOid) throws ServiceException, Exception {
if (StringUtils.isBlank(uploadOid)) {
throw new Exception("Upload OID parameter is blank!");
}
SysUploadVO uploadObj = new SysUploadVO();
uploadObj.setOid(uploadOid);
DefaultResult<SysUploadVO> result = sysUploadService.findObjectByOid(uploadObj);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
uploadObj = result.getValue();
return uploadObj;
}
use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.
the class UploadSupportUtils method getRealFile.
public static File getRealFile(String uploadOid) throws ServiceException, IOException, Exception {
if (StringUtils.isBlank(uploadOid)) {
throw new Exception("parameter is blank!");
}
SysUploadVO uploadObj = findUpload(uploadOid);
File packageFile = null;
if (!YesNo.YES.equals(uploadObj.getIsFile())) {
File dir = new File(Constants.getWorkTmpDir() + "/" + UploadSupportUtils.class.getSimpleName());
if (!dir.exists() || !dir.isDirectory()) {
FileUtils.forceMkdir(dir);
}
String tmpFileName = dir.getPath() + "/" + SimpleUtils.getUUIDStr() + "." + getFileExtensionName(uploadObj.getShowName());
dir = null;
OutputStream fos = null;
try {
packageFile = new File(tmpFileName);
fos = new FileOutputStream(packageFile);
IOUtils.write(uploadObj.getContent(), fos);
fos.flush();
} catch (IOException e) {
throw e;
} finally {
if (fos != null) {
fos.close();
}
fos = null;
}
} else {
String uploadDir = getUploadFileDir(uploadObj.getSystem(), uploadObj.getSubDir(), uploadObj.getType());
packageFile = new File(uploadDir + "/" + uploadObj.getFileName());
}
if (!packageFile.exists()) {
throw new Exception("File is missing: " + uploadObj.getFileName());
}
return packageFile;
}
use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.
the class SysUploadServiceImpl method findForNoByteContent.
@Override
public DefaultResult<SysUploadVO> findForNoByteContent(String oid) throws ServiceException, Exception {
if (StringUtils.isBlank(oid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
SysUploadVO upload = this.sysUploadDAO.findForNoByteContent(oid);
DefaultResult<SysUploadVO> result = new DefaultResult<SysUploadVO>();
if (upload != null && !StringUtils.isBlank(upload.getOid())) {
result.setValue(upload);
} else {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_NO_EXIST)));
}
return result;
}
use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.
the class CommonSignatureSaveAction method saveData.
private void saveData() throws ServiceException, Exception {
String system = super.defaultString(this.getFields().get("system"));
String signatureData = super.defaultString(this.getFields().get("signatureData"));
signatureData = SimpleUtils.deHex(signatureData);
if (!SimpleUtils.isPNGBase64Content(signatureData)) {
super.throwMessage("Signature data error!");
}
SysUploadVO upload = new SysUploadVO();
upload.setContent(this.getImageBytes(signatureData));
upload.setIsFile(YesNo.NO);
upload.setFileName(SimpleUtils.getUUIDStr() + ".png");
upload.setShowName("signature" + "-" + System.currentTimeMillis() + ".png");
upload.setSystem(system);
upload.setSubDir(UploadSupportUtils.getSubDir());
upload.setType(UploadTypes.IS_TEMP);
DefaultResult<SysUploadVO> result = this.sysUploadService.saveObject(upload);
this.message = result.getSystemMessage().getValue();
if (result.getValue() != null) {
this.success = IS_YES;
this.uploadOid = result.getValue().getOid();
}
}
use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.
the class KpiLogicServiceImpl method createKpiAttachment.
private void createKpiAttachment(KpiVO kpi, List<String> attachment) throws ServiceException, Exception {
if (kpi == null || attachment == null || attachment.size() < 1) {
return;
}
for (String uploadOid : attachment) {
SysUploadVO upload = this.findUploadDataForNoByteContent(uploadOid);
if (!(upload.getSystem().equals(Constants.getSystem()) && upload.getType().equals(UploadTypes.IS_TEMP))) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
}
KpiAttacVO attac = new KpiAttacVO();
attac.setKpiId(kpi.getId());
attac.setUploadOid(uploadOid);
attac.setViewMode(UploadSupportUtils.getViewMode(upload.getShowName()));
DefaultResult<KpiAttacVO> result = this.kpiAttacService.saveObject(attac);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
//this.sysUploadService.updateTypeOnly(uploadOid, UploadTypes.IS_KPI_DOCUMENT);
UploadSupportUtils.updateType(uploadOid, UploadTypes.IS_KPI_DOCUMENT);
}
}
Aggregations