Search in sources :

Example 1 with SysUploadVO

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;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) IOException(java.io.IOException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Example 2 with SysUploadVO

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;
}
Also used : OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Example 3 with SysUploadVO

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;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult)

Example 4 with SysUploadVO

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();
    }
}
Also used : SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO)

Example 5 with SysUploadVO

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);
    }
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) KpiAttacVO(com.netsteadfast.greenstep.vo.KpiAttacVO)

Aggregations

SysUploadVO (com.netsteadfast.greenstep.vo.SysUploadVO)20 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)14 File (java.io.File)6 IOException (java.io.IOException)6 HashMap (java.util.HashMap)5 ControllerException (com.netsteadfast.greenstep.base.exception.ControllerException)3 KpiAttacVO (com.netsteadfast.greenstep.vo.KpiAttacVO)3 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)3 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)2 OrganizationVO (com.netsteadfast.greenstep.vo.OrganizationVO)2 PdcaDocVO (com.netsteadfast.greenstep.vo.PdcaDocVO)2 PdcaItemDocVO (com.netsteadfast.greenstep.vo.PdcaItemDocVO)2 PdcaItemVO (com.netsteadfast.greenstep.vo.PdcaItemVO)2 PdcaMeasureFreqVO (com.netsteadfast.greenstep.vo.PdcaMeasureFreqVO)2 AuthorityException (com.netsteadfast.greenstep.base.exception.AuthorityException)1 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)1 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)1 BbPdcaDoc (com.netsteadfast.greenstep.po.hbm.BbPdcaDoc)1 BbPdcaItem (com.netsteadfast.greenstep.po.hbm.BbPdcaItem)1 BbPdcaItemDoc (com.netsteadfast.greenstep.po.hbm.BbPdcaItemDoc)1