本文整理汇总了Java中javax.activation.DataHandler.getInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java DataHandler.getInputStream方法的具体用法?Java DataHandler.getInputStream怎么用?Java DataHandler.getInputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.activation.DataHandler
的用法示例。
在下文中一共展示了DataHandler.getInputStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFileTemplateToServiceInfo
import javax.activation.DataHandler; //导入方法依赖的package包/类
@Override
public Response addFileTemplateToServiceInfo(HttpServletRequest request, HttpHeaders header, Company company,
Locale locale, User user, ServiceContext serviceContext, Attachment file, String id, String fileTemplateNo,
String templateName, String fileType, int fileSize, String fileName) {
long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
long userId = serviceContext.getUserId();
ServiceFileTemplate serviceFileTemplate = null;
BackendAuth auth = new BackendAuthImpl();
ServiceInfoActions actions = new ServiceInfoActionsImpl();
DataHandler dataHandler = file.getDataHandler();
InputStream inputStream = null;
try {
if (!auth.isAuth(serviceContext)) {
throw new UnauthenticationException();
}
if (!auth.hasResource(serviceContext, ServiceInfo.class.getName(), ActionKeys.ADD_ENTRY)) {
throw new UnauthorizationException();
}
inputStream = dataHandler.getInputStream();
serviceFileTemplate = actions.addServiceFileTemplate(userId, groupId, GetterUtil.getLong(id),
fileTemplateNo, templateName, fileName,
inputStream, fileType, fileSize, serviceContext);
FileTemplateModel result = ServiceInfoUtils.mappingToFileTemplateModel(serviceFileTemplate);
return Response.status(200).entity(result).build();
} catch (Exception e) {
ErrorMsg error = new ErrorMsg();
if (e instanceof UnauthenticationException) {
error.setMessage("Non-Authoritative Information.");
error.setCode(HttpURLConnection.HTTP_NOT_AUTHORITATIVE);
error.setDescription("Non-Authoritative Information.");
return Response.status(HttpURLConnection.HTTP_NOT_AUTHORITATIVE).entity(error).build();
} else {
if (e instanceof UnauthorizationException) {
error.setMessage("Unauthorized.");
error.setCode(HttpURLConnection.HTTP_NOT_AUTHORITATIVE);
error.setDescription("Unauthorized.");
return Response.status(HttpURLConnection.HTTP_UNAUTHORIZED).entity(error).build();
} else {
error.setMessage("No Content.");
error.setCode(HttpURLConnection.HTTP_FORBIDDEN);
error.setDescription("No Content.");
return Response.status(HttpURLConnection.HTTP_FORBIDDEN).entity(error).build();
}
}
}
}