@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
throws ServletException, IOException {
Optional<AddOnKeyAndModuleKey> keys = keysFromPathMatcher.getAddOnKeyAndModuleKey(req.getPathInfo());
if (!keys.isPresent()) {
resp.sendError(SC_NOT_FOUND);
return;
}
final AddOnKeyAndModuleKey addOnKeyAndModuleKey = keys.get();
String classifier = req.getParameter(CLASSIFIER_PARAMETER);
Optional<String> lookupClassifier = StringUtils.isBlank(classifier) || JSON_CLASSIFIER.equals(classifier) ? Optional.empty() : Optional.of(classifier);
Optional<ConnectIFrame> maybeIFrame = iFrameAccessor.fetchConnectIFrame(addOnKeyAndModuleKey.getAddOnKey(), addOnKeyAndModuleKey.getModuleKey(), lookupClassifier);
if (maybeIFrame.isPresent()) {
ConnectIFrame iFrame = maybeIFrame.get();
if (JSON_CLASSIFIER.equals(classifier)) {
iFrame = iFrame.toJsonIFrame();
}
resp.setContentType(iFrame.getContentType());
ModuleContextParameters moduleContextParameters = moduleContextParser.parseContextParameters(req);
if (iFrame.shouldShow(moduleContextParameters)) {
Optional<String> moduleUiParameters = moduleUiParamParser.parseUiParameters(req);
iFrame.render(moduleContextParameters, resp.getWriter(), moduleUiParameters);
eventPublisher.publish(new IFrameRenderedEvent(addOnKeyAndModuleKey.getAddOnKey(), addOnKeyAndModuleKey.getModuleKey(), moduleContextParameters));
} else {
iFrame.renderAccessDenied(resp.getWriter());
}
} else {
resp.sendError(SC_NOT_FOUND);
}
}