com.lorne.core.framework.exception.ServiceException Java Examples
The following examples show how to use
com.lorne.core.framework.exception.ServiceException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImgServiceImpl.java From fileServer with Apache License 2.0 | 6 votes |
private void uploadCutImages(List<ImageWH> whs,File sourceFile) throws ServiceException { //上传裁剪的图片 try { for (ImageWH wh : whs) { String fileName = sourceFile.getName(); String baseName = FilenameUtils.getBaseName(fileName); String ext = FilenameUtils.getExtension(fileName); String newFileName = baseName+"_"+wh.getW()+"x"+wh.getH()+"."+ext; File imgFile = new File(sourceFile.getParent()+"/"+newFileName); Thumbnails.of(sourceFile).size(wh.getW(), wh.getH()).toFile(imgFile); } }catch (Exception e){ throw new ServiceException(e); } }
Example #2
Source File: UploadServiceImpl.java From fileServer with Apache License 2.0 | 6 votes |
@Override public String uploadFile(String groupName, MultipartFile file) throws ServiceException { if (file.getSize() <= 0) { throw new ParamException("file is null."); } fileValidateService.validateFile(file); try { String ext = FilenameUtils.getExtension(file.getOriginalFilename()); StorePath path = storageClient.uploadFile(groupName, file.getInputStream(), file.getSize(), ext); if(path==null) { throw new ServiceException("upload error."); } return path.getFullPath(); } catch (Exception e) { throw new ServiceException(e); } }
Example #3
Source File: UploadServiceImpl.java From fileServer with Apache License 2.0 | 6 votes |
private void uploadCutImages(List<ImageWH> whs,File sourceFile,StorePath path,String ext) throws ServiceException { //上传裁剪的图片 try { for (ImageWH wh : whs) { ByteArrayOutputStream out = new ByteArrayOutputStream(); Thumbnails.of(sourceFile).size(wh.getW(), wh.getH()).toOutputStream(out); InputStream newInput = new ByteArrayInputStream(out.toByteArray()); int newSize = out.size(); String prefixName = String.format("%dx%d", wh.getW(), wh.getH()); StorePath slaveFile = storageClient.uploadSlaveFile(path.getGroup(), path.getPath(), newInput, newSize, prefixName, ext); if (slaveFile == null) { throw new ServiceException("cutImage upload error."); } } }catch (Exception e){ throw new ServiceException(e); } }
Example #4
Source File: TestServiceImpl.java From pay with Apache License 2.0 | 5 votes |
@Override public Map<String, Object> getOpenId(String code) { try { return accountPay.getOpendIdAndSessionKey(code); } catch (ServiceException e) { e.printStackTrace(); return null; } }
Example #5
Source File: ImageFileController.java From fileServer with Apache License 2.0 | 5 votes |
@ApiOperation(value="上传图片", notes="上传图片") @RequestMapping(value = "/upload", method = RequestMethod.POST) public String uploadImage( @ApiParam(value = "文件流,name=file") @RequestParam("file") MultipartFile file, @ApiParam(value = "模块名称") @RequestParam("groupName") String groupName, @ApiParam(value = "裁剪尺寸(数组类型)如:20x20,30x30,100x100") @RequestParam("cutSize") String cutSize) throws ServiceException { return uploadService.uploadImage(groupName,cutSize,file); }
Example #6
Source File: OnLineServiceImpl.java From sds with Apache License 2.0 | 5 votes |
@Override public SocketModel getModelByKey(String key) throws ServiceException { String val = redisService.getModelByKey(key); if(StringUtils.isEmpty(val)){ throw new ServiceException("data not exist."); } String mv[] = val.split("#"); SocketModel model = new SocketModel(); model.setModelName(mv[0]); model.setUniqueKey(mv[1]); return model; }
Example #7
Source File: FileController.java From fileServer with Apache License 2.0 | 5 votes |
@ApiOperation(value="上传文件", notes="上传文件") @RequestMapping(value = "/upload", method = RequestMethod.POST) public String uploadFile( @ApiParam(value = "文件流,name=file") @RequestParam("file") MultipartFile file, @ApiParam(value = "模块名称") @RequestParam("groupName") String groupName) throws ServiceException { return uploadService.uploadFile(groupName,file); }
Example #8
Source File: ImageFileController.java From fileServer with Apache License 2.0 | 5 votes |
@ApiOperation(value="裁剪图片", notes="裁剪图片") @RequestMapping(value = "/cut", method = RequestMethod.POST) public boolean cutImage( @ApiParam(value = "主文件名称") @RequestParam("fileName") String fileName, @ApiParam(value = "裁剪尺寸(数组类型)如:20x20,30x30,100x100") @RequestParam("cutSize") String cutSize) throws ServiceException { return uploadService.cutImage(fileName,cutSize); }
Example #9
Source File: FileController.java From fileServer with Apache License 2.0 | 5 votes |
@ApiOperation(value="上传从文件", notes="上传从文件") @RequestMapping(value = "/uploadSlave", method = RequestMethod.POST) public String uploadSlaveFile( @ApiParam(value = "从文件流,name=file") @RequestParam("file") MultipartFile file, @ApiParam(value = "主文件名称") @RequestParam("fileName") String fileName, @ApiParam(value = "前缀名称") @RequestParam("prefixName") String prefixName ) throws ServiceException { return uploadService.uploadSlaveFile(fileName,prefixName,file); }
Example #10
Source File: FileController.java From fileServer with Apache License 2.0 | 5 votes |
@ApiOperation(value="删除文件", notes="删除文件") @RequestMapping(value = "/removeFile", method = RequestMethod.POST) public boolean removeFile( @ApiParam(value = "模块名称") @RequestParam("fileName") String fileName) throws ServiceException { return uploadService.removeFile(fileName); }
Example #11
Source File: FileController.java From fileServer with Apache License 2.0 | 5 votes |
@ApiOperation(value="删除文件以及从文件", notes="删除文件以及从文件") @RequestMapping(value = "/removeFiles", method = RequestMethod.POST) public boolean removeFiles( @ApiParam(value = "模块名称") @RequestParam("fileName") String fileName) throws ServiceException { return uploadService.removeFiles(fileName); }
Example #12
Source File: FileValidateServiceImpl.java From fileServer with Apache License 2.0 | 5 votes |
@Override public void validateFile(MultipartFile file) throws ServiceException { init(); String ext = FilenameUtils.getExtension(file.getOriginalFilename()); if(!types.contains(ext)){ throw new ParamException("file type error."); } }
Example #13
Source File: TxStartTransactionServerImpl.java From tx-lcn with Apache License 2.0 | 5 votes |
@Override public Object execute(ProceedingJoinPoint point, TxTransactionInfo info) throws Throwable { //分布式事务开始执行 logger.info("tx-start"); //创建事务组 TxGroup txGroup = txManagerService.createTransactionGroup(); //获取不到模块信息重新连接,本次事务异常返回数据. if (txGroup == null) { throw new ServiceException("创建事务组异常."); } final String groupId = txGroup.getGroupId(); int state = 0; try { TxTransactionLocal txTransactionLocal = new TxTransactionLocal(); txTransactionLocal.setGroupId(groupId); txTransactionLocal.setHasStart(true); txTransactionLocal.setTransactional(info.getTransactional()); txTransactionLocal.setMaxTimeOut(Constants.maxOutTime); TxTransactionLocal.setCurrent(txTransactionLocal); Object obj = point.proceed(); state = 1; return obj; } catch (Throwable e) { throw e; } finally { txManagerService.closeTransactionGroup(groupId, state); TxTransactionLocal.setCurrent(null); logger.info("tx-end-"+txGroup.getGroupId()+">"+state); } }
Example #14
Source File: UploadServiceImpl.java From fileServer with Apache License 2.0 | 5 votes |
@Override public String uploadSlaveFile(String fileName, String prefixName, MultipartFile file) throws ServiceException { if (file.getSize() <= 0) { throw new ParamException("file is null."); } if(StringUtils.isEmpty(fileName)){ throw new ParamException("fileName is null"); } if(StringUtils.isEmpty(prefixName)){ throw new ParamException("prefixName is null"); } fileValidateService.validateFile(file); StorePath storePath = StorePath.praseFromUrl(fileName); try { String ext = FilenameUtils.getExtension(file.getOriginalFilename()); StorePath slaveFile = storageClient.uploadSlaveFile(storePath.getGroup(),storePath.getPath(), file.getInputStream(), file.getSize(),prefixName, ext); if(slaveFile==null) { throw new ServiceException("upload error."); } return slaveFile.getFullPath(); }catch (Exception e){ throw new ServiceException(e); } }
Example #15
Source File: UploadServiceImpl.java From fileServer with Apache License 2.0 | 5 votes |
@Override public boolean cutImage(String fileName, String cutSize) throws ServiceException { if(StringUtils.isEmpty(fileName)){ throw new ParamException("fileName is null"); } List<ImageWH> whs =loadCutSize(cutSize); StorePath path = StorePath.praseFromUrl(fileName); String ext = FilenameUtils.getExtension(fileName); InputStream sourceStream =storageClient.downloadFile(path.getGroup(), path.getPath(), new DownloadCallback<InputStream>() { @Override public InputStream recv(InputStream inputStream) throws IOException { return inputStream; } }); if(sourceStream==null){ throw new ServiceException("download error"); } File file = new File(KidUtils.getUUID()); try { FileUtils.copyInputStreamToFile(sourceStream,file); uploadCutImages(whs,file,path,ext); } catch (IOException e) { throw new ServiceException(e); }finally { file.delete(); } return true; }
Example #16
Source File: ImgController.java From fileServer with Apache License 2.0 | 5 votes |
@ApiOperation(value="上传图片", notes="上传并裁剪图片") @RequestMapping(value = "/upload", method = RequestMethod.POST) public FileServerModel uploadImage( @ApiParam(value = "文件流,name=file") @RequestParam("file") MultipartFile file) throws ServiceException { return imgService.uploadImage(file,null); }
Example #17
Source File: ImgController.java From fileServer with Apache License 2.0 | 5 votes |
@ApiOperation(value="上传并裁剪图片", notes="上传并裁剪图片") @RequestMapping(value = "/uploadCutImg", method = RequestMethod.POST) public FileServerModel uploadImage( @ApiParam(value = "文件流,name=file") @RequestParam("file") MultipartFile file, @ApiParam(value = "裁剪尺寸(数组类型)如:20x20,30x30,100x100") @RequestParam("cutSize") String cutSize) throws ServiceException { return imgService.uploadImage(file,cutSize); }
Example #18
Source File: ImgController.java From fileServer with Apache License 2.0 | 5 votes |
@ApiOperation(value="裁剪图片", notes="裁剪图片") @RequestMapping(value = "/cut", method = RequestMethod.POST) public boolean cutImage( @ApiParam(value = "文件服务器存放路径") @RequestParam("filePath") String filePath, @ApiParam(value = "裁剪尺寸(数组类型)如:20x20,30x30,100x100") @RequestParam("cutSize") String cutSize) throws ServiceException { return imgService.cutImage(filePath,cutSize); }
Example #19
Source File: UploadController.java From fileServer with Apache License 2.0 | 5 votes |
@ApiOperation(value="上传文件", notes="上传文件") @RequestMapping(value = "/upload", method = RequestMethod.POST) public FileServerModel uploadFile( @ApiParam(value = "文件流,name=file") @RequestParam("file") MultipartFile file) throws ServiceException { return uploadService.uploadFile(file); }
Example #20
Source File: RemoveController.java From fileServer with Apache License 2.0 | 5 votes |
@ApiOperation(value="删除文件", notes="删除文件") @RequestMapping(value = "/file", method = RequestMethod.POST) public boolean removeFile( @ApiParam(value = "文件服务器存放路径") @RequestParam("filePath") String filePath, @ApiParam(value = "删除标示,0:本文件,1:整个文件目录") @RequestParam("flag") int flag ) throws ServiceException { return removeService.removeFile(filePath,flag); }
Example #21
Source File: FileValidateServiceImpl.java From fileServer with Apache License 2.0 | 5 votes |
@Override public void validateFile(MultipartFile file) throws ServiceException { init(); String ext = FilenameUtils.getExtension(file.getOriginalFilename()); if(!types.contains(ext)){ throw new ParamException("file type error."); } }
Example #22
Source File: AbstractWxPay.java From pay with Apache License 2.0 | 5 votes |
/** * 通过jscode赋值openid * * @param jsCode 小程序的openid * @return openId * @throws ServiceException 业务异常 */ public String getOpendIdByJsCode(String jsCode) throws ServiceException { Map<String, Object> map = getOpendIdAndSessionKey(jsCode); if (map != null) { return (String)map.get("openid"); } throw new ServiceException("获取openId 失败."); }
Example #23
Source File: WeixinApiUtils.java From pay with Apache License 2.0 | 5 votes |
public static Map<String, Object> getOpendIdAndSessionKey(WxConfig config, String jsCode)throws ServiceException { Map<String, Object> map = WeixinUtils.jscode2session(config, jsCode); System.out.println(map); if (map.containsKey("errcode")) { throw new ServiceException("jscode失效"); } return map; }
Example #24
Source File: WeixinApiUtils.java From pay with Apache License 2.0 | 5 votes |
public static Map<String, Object> getAccessToken(WxConfig config)throws ServiceException { Map<String, Object> map = WeixinUtils.getAccessToken(config); if (!map.containsKey("access_token")) { throw new ServiceException("获取access_token失败"); } return map; }
Example #25
Source File: AbstractWxPay.java From pay with Apache License 2.0 | 5 votes |
/** * 通过jscode赋值openid * * @param jsCode 小程序的openid * @return openId * @throws ServiceException 业务异常 */ public String getOpendIdByJsCode(String jsCode) throws ServiceException { Map<String, Object> map = getOpendIdAndSessionKey(jsCode); if (map != null) { return (String)map.get("openid"); } throw new ServiceException("获取openid 失败"); }
Example #26
Source File: WeixinApiUtils.java From pay with Apache License 2.0 | 5 votes |
public static Map<String, Object> getOpendIdAndSessionKey(WxConfig config, String jsCode)throws ServiceException { Map<String, Object> map = WeixinUtils.jscode2session(config, jsCode); System.out.println(map); if (map.containsKey("errcode")) { throw new ServiceException("jscode失效"); } return map; }
Example #27
Source File: WeixinApiUtils.java From pay with Apache License 2.0 | 5 votes |
public static Map<String, Object> getAccessToken(WxConfig config)throws ServiceException { Map<String, Object> map = WeixinUtils.getAccessToken(config); if (!map.containsKey("access_token")) { throw new ServiceException("获取access_token失败"); } return map; }
Example #28
Source File: UploadServiceImpl.java From fileServer with Apache License 2.0 | 5 votes |
@Override public boolean removeFile(String fileName) throws ServiceException { if(StringUtils.isEmpty(fileName)){ throw new ParamException("fileName is null"); } StorePath storePath = StorePath.praseFromUrl(fileName); storageClient.deleteFile(storePath.getGroup(),storePath.getPath()); return true; }
Example #29
Source File: SocketServiceImpl.java From sds with Apache License 2.0 | 4 votes |
@Override public boolean sendBase64Cmd(String modelName, String uniqueKey, String cmd) throws ServiceException { String url = "http://"+modelName+"/socket/sendBase64Cmd"; return restTemplate.postForObject(url+"?uniqueKey={uniqueKey}&cmd={cmd}",null,Boolean.class,uniqueKey,cmd); }
Example #30
Source File: ImgServiceImpl.java From fileServer with Apache License 2.0 | 4 votes |
@Override public boolean cutImage(String filePath, String cutSize) throws ServiceException { if(StringUtils.isEmpty(filePath)){ throw new ParamException("filePath is null"); } List<ImageWH> whs = FileServerUtils.loadCutSize(cutSize); String serverPath = localFileConfig.getFileServerPath(); File uploadFile = new File(serverPath+"/"+filePath); if(!uploadFile.exists()){ throw new ParamException("file not exist"); } uploadCutImages(whs,uploadFile); return true; }