/** * Gets prefix for titles of all pages * * @return prefix for titles of all pages */ public String getAllPagesTitlePrefix() { return allPagesTitlePrefixProperty.getValue(); }
/** * @param sessionTimeoutProperty property to read * @return time in seconds */ private int extractValueFromProperty(JCommuneProperty sessionTimeoutProperty) { int value = sessionTimeoutProperty != null ? sessionTimeoutProperty.intValue() : 0; return (int) TimeUnit.SECONDS.convert(value, TimeUnit.MINUTES); }
/** * {@inheritDoc} */ @Override @PreAuthorize("hasPermission(#componentId, 'COMPONENT', 'GeneralPermission.ADMIN')") public SapeConfiguration getSapeConfiguration(long componentId) { SapeConfiguration configuration = new SapeConfiguration(); configuration.setAccountId(sapeAccountId.getValue()); configuration.setTimeout(sapeTimeout.intValue()); configuration.setHostUrl(sapeHostUrl.getValue()); configuration.setNumberOfLinks(sapeNumberOrLinks.intValue()); configuration.setShowOnMainPage(sapeShowOnMainPage.booleanValue()); configuration.setShowDummyLinks(sapeShowDummyLinks.booleanValue()); configuration.setEnableSape(sapeEnableService.booleanValue()); return configuration; }
/** * Set properties of component to request parameters. * * @param request current HTTP request * @param response current HTTP response * @param handler chosen handler to execute, for type and/or instance examination * @param modelAndView the {@code ModelAndView} that the handler returned * (can also be {@code null}) */ @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) { //do not apply to the redirected requests and error pages if (modelAndView != null && (modelAndView.getViewName() == null || checkViewNameForErrorAndRedirection(modelAndView))) { modelAndView.addObject(PARAM_CMP_NAME, componentNameProperty.getValueOfComponent()); modelAndView.addObject(PARAM_CMP_DESCRIPTION, componentDescriptionProperty.getValueOfComponent()); modelAndView.addObject(PARAM_SHOW_DUMMY_LINKS, sapeShowDummyLinksProperty.booleanValue()); modelAndView.addObject(PARAM_LOGO_TOOLTIP, logoTooltipProperty.getValue()); modelAndView.addObject(PARAM_CMP_PREFIX, allPagesTitlePrefixProperty.getValue()); modelAndView.addObject(PARAM_ADMIN_INFO_CHANGE_DATE, adminInfoChangeDateProperty.getValue()); modelAndView.addObject(PARAM_COPYRIGHT_TEMPLATE, copyrightProperty.getValue()); modelAndView.addObject(PARAM_USER_DEFINED_COPYRIGHT, getCopyrightWithYear()); modelAndView.addObject(PARAM_SESSION_TIMEOUT, sessionTimeoutProperty.getValue()); modelAndView.addObject(PARAM_AVATAR_MAX_SIZE, avatarMaxSizeProperty.getValue()); modelAndView.addObject(PARAM_EMAIL_NOTIFICATION, emailNotificationProperty.booleanValue()); } }
/** * Check - sending notification is allow * * @param user User for which we check allow sending pm notification * @return flag with value (send or not) */ private boolean isSendNotificationMessage(JCUser user) { return (sendingNotificationsEnabledProperty.booleanValue() && user.isSendPmNotification()); }
/** * Returns a string value of the property. Property values * are stored as strings, so this method is main for retrieving * a value of property. * It is also worth noting that if the property has not been found, * it will return a default value. * * @return a string value of the property */ public String getValue() { if (propertyDao != null) { Property property = propertyDao.getByName(name); if (property != null) { return property.getValue(); } else { return getDefaultValue(); } } else { return getDefaultValue(); } }
/** * {@inheritDoc} */ @Override @PreAuthorize("hasPermission(#componentId, 'COMPONENT', 'GeneralPermission.ADMIN')") public void updateSapeConfiguration(SapeConfiguration configuration, long componentId) { sapeAccountId.setValue(configuration.getAccountId()); sapeTimeout.setValue(String.valueOf(configuration.getTimeout())); sapeHostUrl.setValue(configuration.getHostUrl()); sapeNumberOrLinks.setValue(String.valueOf(configuration.getNumberOfLinks())); sapeShowOnMainPage.setValue(String.valueOf(configuration.isShowOnMainPage())); sapeShowDummyLinks.setValue(String.valueOf(configuration.isShowDummyLinks())); sapeEnableService.setValue(String.valueOf(configuration.isEnableSape())); }
/** * Set sape content to request parameters. * * @param request current HTTP request * @param response current HTTP response * @param handler chosen handler to execute, for type and/or instance examination * @param modelAndView the {@code ModelAndView} that the handler returned (can also be {@code null}) */ @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { if (!componentSapeEnableServiceProperty.booleanValue() || modelAndView == null || modelAndView.getViewName() == null || //do not apply to the redirected requests: it's unnecessary and may cause error pages to work // incorrectly (!componentSapeOnMainPageEnableProperty.booleanValue() && modelAndView.getViewName().equals("sectionList")) || modelAndView.getViewName().contains("redirect:")) { return; } String sapeLinksAsString = ""; if (componentSapeShowDummyLinksProperty.booleanValue()) { sapeLinksAsString = dummyLinks; } else if (initSape()) { SapePageLinks pageLinks = sape.getPageLinks(request.getRequestURI(), request.getCookies()); sapeLinksAsString = pageLinks.render(); } modelAndView.addObject("sapeLinks", sapeLinksAsString); }
/** * Returns a string value of the component property. * It is also worth noting that if the property has not been found, * it will return a default value. * * @return a string value of component property */ public String getValueOfComponent() { try { if (componentDao != null) { Component cmp = componentDao.getComponent(); if (cmp != null) { return name.equals("cmp.name") ? cmp.getName() : cmp.getDescription(); } else { return getDefaultValue(); } } else { return getDefaultValue(); } } catch (Exception ex) { return getDefaultValue(); } }
/** * Converts a value of the property to boolean and returns it. * Keep in mind, if the property isn't boolean, the result will false. * * @return a boolean value of the property */ public boolean booleanValue() { return Boolean.valueOf(getValue()); }
if (!notificationsEnabledProperty.booleanValue()) { LOGGER.debug("Email notifications are turned off in Forum Settings, skip sending to [{}]" + " mail with subject [{}]. User with Admin Permissions can enter Poulpe (that should be changed" +
/** * Validate image size * * @param bytes array for validation * @throws org.jtalks.jcommune.service.exceptions.ImageSizeException * invalid size image processing error */ public void validateImageSize(byte[] bytes) throws ImageSizeException { Validate.notNull(bytes, "Incoming byte array cannot be null"); int maxSize = imageSizeProperty.intValue(); if (bytes.length > maxSize) { LOGGER.debug("File has too big size. Must be less than {} bytes", maxSize); throw new ImageSizeException(maxSize); } }
/** * Converts a value of the property to int and returns it. * Keep in mind, if the property isn't integer {@link NumberFormatException} * will be thrown * * @return a boolean value of the property */ public int intValue() { return Integer.valueOf(getValue()); }
private String getCopyrightWithYear() { return copyrightProperty.getValue().replace(CURRENT_YEAR_PLACEHOLDER, CURRENT_YEAR); } }
/** * Initializes {@link javasape.Sape} object. */ private boolean initSape() { if (sape != null) { return true; } String accountId = componentSapeAccountProperty.getValue(); String host = componentSapeHostProperty.getValue(); if (StringUtils.isBlank(accountId) || StringUtils.isBlank(host)) { return false; } sape = new Sape(componentSapeAccountProperty.getValue(), componentSapeHostProperty.getValue(), Integer.parseInt(componentSapeTimeoutProperty.getValue()), Integer.parseInt(componentSapeLinksCountProperty.getValue())); return true; }