當前位置: 首頁>>代碼示例>>Java>>正文


Java DataHandler.getInputStream方法代碼示例

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

			}
		}
	}

}
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:72,代碼來源:ServiceInfoManagementImpl.java


注:本文中的javax.activation.DataHandler.getInputStream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。