53 log.debug(
"Starting organization logo upload");
61 OutputStream os = null;
62 InputStream is = null;
64 DownloadWrapper downloadWrapper = null;
70 is = FileUtils.openInputStream(file);
71 downloadWrapper =
new DownloadWrapper(is, image.getSourceName(), image.getSourceContentType(),
72 image.getCreationDate(), (int) file.length());
73 }
catch (IOException ex) {
74 log.error(
"Organization logo image doesn't exist", ex);
75 FileDownloader.sendError(response);
81 String defaultLogoFileName =
"/WEB-INF/static/images/default_logo.png";
82 is = getServletContext().getResourceAsStream(defaultLogoFileName);
84 log.error(
"Default organization logo image doesn't exist");
85 FileDownloader.sendError(response);
92 contentLength = is.skip(Long.MAX_VALUE);
93 }
catch (IOException ex) {
94 log.error(
"Failed to calculate default organization logo image size", ex);
95 FileDownloader.sendError(response);
98 IOUtils.closeQuietly(is);
101 is = getServletContext().getResourceAsStream(defaultLogoFileName);
102 downloadWrapper =
new DownloadWrapper(is,
"default_logo.png",
"image/png",
new Date(), (
int) contentLength);
106 int logoSize = FileDownloader.writeOutput(downloadWrapper, ContentDisposition.INLINE, response);
107 response.getOutputStream().flush();
108 log.debug(
"Successfully send organization logo with size", logoSize);
109 }
catch (IOException ex) {
110 log.error(
"Failed to send organization logo", ex);
111 FileDownloader.sendError(response);
114 IOUtils.closeQuietly(is);
115 IOUtils.closeQuietly(os);
117 }
catch (Exception ex) {
118 log.error(
"Failed to send organization logo", ex);
GluuImage getGluuImageFromXML(String xml)
Definition: ImageService.java:54
static final Logger log
Definition: LogoImageServlet.java:43
File getSourceFile(GluuImage image)
Definition: ImageService.java:214
GluuOrganization getOrganization()
Definition: OrganizationService.java:84
ImageService imageService
Definition: LogoImageServlet.java:49
OrganizationService organizationService
Definition: LogoImageServlet.java:46