本文整理匯總了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();
}
}
}
}