private int getSkippedNumber() { SettingValue settingValue = settingService.get(Context.GLOBAL, Scope.GLOBAL, SOFTWARE_REGISTRATION_SKIPPED); if (settingValue != null) { return Integer.parseInt(settingValue.getValue().toString()); } settingService.set( Context.GLOBAL, Scope.GLOBAL, SOFTWARE_REGISTRATION_SKIPPED, new SettingValue<Object>("0")); return 0; }
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { SettingService settingService = PortalContainer.getInstance().getComponentInstanceOfType(SettingService.class); SoftwareRegistrationService softwareRegistrationService = PortalContainer.getInstance().getComponentInstanceOfType(SoftwareRegistrationService.class); if (softwareRegistrationService.isSoftwareRegistered()) { response.sendRedirect("/"); return; } String code = request.getParameter("code"); if (StringUtils.isEmpty(code)) { try { getServletContext().getRequestDispatcher(SR_JSP_RESOURCE).forward(request, response); } catch (Exception se) { if (LOG.isErrorEnabled()) { LOG.error(se); } response.sendRedirect("/"); } return; } SoftwareRegistration softwareRegistration = softwareRegistrationService.registrationPLF(code, getRegistrationURL(request)); if (softwareRegistration.isPushInfo()) { settingService.set( Context.GLOBAL, Scope.GLOBAL, SoftwareRegistrationService.SOFTWARE_REGISTRATION_NODE, SettingValue.create("Software registered:" + "true")); softwareRegistrationService.checkSoftwareRegistration(); getServletContext().setAttribute("status", "success"); } else if (softwareRegistration.isNotReachable()) { request.getSession().setAttribute("notReachable", "true"); getServletContext().getRequestDispatcher(SR_JSP_RESOURCE).forward(request, response); return; } else { getServletContext().setAttribute("status", "failed"); request.getSession().setAttribute("notReachable", "true"); response.sendRedirect("/"); return; } getServletContext().getRequestDispatcher(SR_JSP_RESOURCE_SUCCESS).forward(request, response); return; }
/** {@inheritDoc} */ @Override public void updateSkippedNumber() { int skippedNumber = getSkippedNumber(); settingService.set( Context.GLOBAL, Scope.GLOBAL, SOFTWARE_REGISTRATION_SKIPPED, new SettingValue<Object>(String.valueOf(++skippedNumber))); }