gluu
限定公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.gluu.oxtrust.servlet.FaviconImageServlet クラス
org.gluu.oxtrust.servlet.FaviconImageServlet の継承関係図
Inheritance graph
org.gluu.oxtrust.servlet.FaviconImageServlet 連携図
Collaboration graph

限定公開メンバ関数

void doGet (HttpServletRequest httpServletRequest, HttpServletResponse response) throws ServletException, IOException
 

非公開変数類

OrganizationService organizationService
 
ImageService imageService
 

静的非公開変数類

static final long serialVersionUID = 5445488800130871634L
 
static final Logger log = LoggerFactory.getLogger(FaviconImageServlet.class)
 

詳解

関数詳解

◆ doGet()

void org.gluu.oxtrust.servlet.FaviconImageServlet.doGet ( HttpServletRequest  httpServletRequest,
HttpServletResponse  response 
) throws ServletException, IOException
inlineprotected
48  {
49  log.debug("Starting organization favicon upload");
50  String preview = httpServletRequest.getParameter("preview");
51  GluuOrganization organization = null;
52  try {
53  organization = organizationService.getOrganization();
54  } catch (Exception ex) {
55  log.error("an Error Occured", ex);
56  }
57 
58  GluuImage image = null;
59  if ("true".equals(preview)) {
60  image = imageService.getGluuImageFromXML(organization.getTempFaviconImage());
61  if (image != null) {
62  image.setStoreTemporary(true);
63  }
64 
65  }
66 
67  if (!"true".equals(preview) || image == null) {
68  image = imageService.getGluuImageFromXML(organization.getFaviconImage());
69  }
70 
71  if (image != null) {
72  image.setLogo(false);
73  }
74  OutputStream os = null;
75  InputStream is = null;
76  try {
77  DownloadWrapper downloadWrapper = null;
78 
79  // Send customized organization logo
80  if (image != null) {
81  File file = null;
82  try {
83  file = imageService.getSourceFile(image);
84  } catch (Exception ex) {
85  log.error("an Error Occured", ex);
86 
87  }
88  try {
89  is = FileUtils.openInputStream(file);
90  if (is != null && file != null) {
91  downloadWrapper = new DownloadWrapper(is, image.getSourceName(), image.getSourceContentType(),
92  image.getCreationDate(), (int) file.length());
93  }
94  } catch (IOException ex) {
95  log.error("Organization favicon image doesn't exist", ex);
96  FileDownloader.sendError(response);
97  return;
98  }
99  } else {
100  // If customized logo doesn't exist then send default
101  // organization logo
102  String defaultFaviconFileName = "/WEB-INF/static/images/favicon_icosahedron.ico";
103  is = getServletContext().getResourceAsStream(defaultFaviconFileName);
104  if (is == null) {
105  log.error("Default organization favicon image doesn't exist");
106  FileDownloader.sendError(response);
107  return;
108  }
109 
110  // Calculate default logo size
111  long contentLength;
112  try {
113  contentLength = is.skip(Long.MAX_VALUE);
114  } catch (IOException ex) {
115  log.error("Failed to calculate default organization favicon image size", ex);
116  FileDownloader.sendError(response);
117  return;
118  } finally {
119  IOUtils.closeQuietly(is);
120  }
121 
122  is = getServletContext().getResourceAsStream(defaultFaviconFileName);
123  downloadWrapper = new DownloadWrapper(is, "favicon_ic.ico", "image/x-icon", new Date(), (int) contentLength);
124  }
125 
126  try {
127  int logoSize = FileDownloader.writeOutput(downloadWrapper, ContentDisposition.INLINE, response);
128  response.getOutputStream().flush();
129  log.debug("Successfully send organization favicon with size", logoSize);
130  } catch (IOException ex) {
131  log.error("Failed to send organization favicon", ex);
132  FileDownloader.sendError(response);
133  }
134  } finally {
135  IOUtils.closeQuietly(is);
136  IOUtils.closeQuietly(os);
137  }
138  }
GluuImage getGluuImageFromXML(String xml)
Definition: ImageService.java:54
static final Logger log
Definition: FaviconImageServlet.java:45
File getSourceFile(GluuImage image)
Definition: ImageService.java:214
GluuOrganization getOrganization()
Definition: OrganizationService.java:84
OrganizationService organizationService
Definition: FaviconImageServlet.java:38
ImageService imageService
Definition: FaviconImageServlet.java:41

メンバ詳解

◆ imageService

ImageService org.gluu.oxtrust.servlet.FaviconImageServlet.imageService
private

◆ log

final Logger org.gluu.oxtrust.servlet.FaviconImageServlet.log = LoggerFactory.getLogger(FaviconImageServlet.class)
staticprivate

◆ organizationService

OrganizationService org.gluu.oxtrust.servlet.FaviconImageServlet.organizationService
private

◆ serialVersionUID

final long org.gluu.oxtrust.servlet.FaviconImageServlet.serialVersionUID = 5445488800130871634L
staticprivate

このクラス詳解は次のファイルから抽出されました: