/** * Instantiates a new razor server, its services, and starts the scheduler. This can be replaced * by a dynamic handler manager but has the benefit of simplicity. */ public RazorServer() { super(); SERVICES.put(Service.ACCOUNT, AccountService.getInstance()); SERVICES.put(Service.ALERT, AlertService.getInstance()); SERVICES.put(Service.ASSET, AssetService.getInstance()); SERVICES.put(Service.ATTRIBUTE, AttributeService.getInstance()); SERVICES.put(Service.AUDIT, AuditService.getInstance()); SERVICES.put(Service.CONTRACT, ContractService.getInstance()); SERVICES.put(Service.FINANCE, FinanceService.getInstance()); SERVICES.put(Service.JOURNAL, JournalService.getInstance()); SERVICES.put(Service.IMAGE, ImageService.getInstance()); SERVICES.put(Service.IMAGETEXT, ImageTextService.getInstance()); SERVICES.put(Service.LICENSE, LicenseService.getInstance()); SERVICES.put(Service.LOCATION, LocationService.getInstance()); SERVICES.put(Service.MAIL, MailService.getInstance()); SERVICES.put(Service.MONITOR, MonitorService.getInstance()); SERVICES.put(Service.PARTNER, PartnerService.getInstance()); SERVICES.put(Service.PARTY, PartyService.getInstance()); SERVICES.put(Service.PRICE, PriceService.getInstance()); SERVICES.put(Service.PRODUCT, ProductService.getInstance()); SERVICES.put(Service.RATE, RateService.getInstance()); SERVICES.put(Service.REPORT, ReportService.getInstance()); SERVICES.put(Service.RESERVATION, ReservationService.getInstance()); SERVICES.put(Service.SESSION, SessionService.getInstance()); SERVICES.put(Service.SMS, SmsService.getInstance()); SERVICES.put(Service.TASK, TaskService.getInstance()); SERVICES.put(Service.TAX, TaxService.getInstance()); SERVICES.put(Service.TEXT, TextService.getInstance()); SERVICES.put(Service.WORKFLOW, WorkflowService.getInstance()); // startScheduler(); // PartnerService.startSchedulers(); }
@Transactional @Test public void testAuditPLUpdateObject() throws SQLException { ParameterGroup parameterGroup = parameterGroupDao.findOne(25L); parameterGroup.setParamGroup("TEST_AUDIT_PL_edit3"); parameterGroup.setDescription("Audit Desc_PL_edit4"); Long auditId = auditDetailDao.getNextSequence(); auditDetailDao.beforeUpdateAuditDetailByPL( auditService.getTableName(parameterGroup), parameterGroup.getParamGroupId().toString()); parameterGroupDao.merge(parameterGroup); parameterGroupDao.flush(); auditDetailDao.afterUpdateAuditDetailByPL( auditService.getTableName(parameterGroup), parameterGroup.getParamGroupId().toString(), auditId, "TEST_PL2"); }
@Test public void testAduitInsertObject() throws Exception { ParameterGroup parameterGroup = new ParameterGroup(); parameterGroup.setParamGroup("TEST_AUDIT"); parameterGroup.setDescription("Audit Desc"); parameterGroupDao.persist(parameterGroup); parameterGroupDao.flush(); // oldObject will send null in case INSERT auditService.callAuditing(null, parameterGroup, "TEST_USER"); }
@Test public void testAduditUpdateObject() throws Exception { ParameterGroup parameterGroup = parameterGroupDao.findOne(24L); ParameterGroup oldParameterGroup = AuditUtil.getStateObject(parameterGroup); parameterGroup.setParamGroup("TEST_AUDIT_edit"); parameterGroup.setDescription("Audit Desc_edit"); parameterGroupDao.merge(parameterGroup); parameterGroupDao.flush(); // Send oldObject and newObject for compare auditService.callAuditing(oldParameterGroup, parameterGroup, "TEST_USER2"); }
@Test public void testAuditPLInsertObject() throws SQLException { ParameterGroup parameterGroup = new ParameterGroup(); parameterGroup.setParamGroup("TEST_AUDIT_PL"); parameterGroup.setDescription("Audit Desc PL"); parameterGroupDao.persist(parameterGroup); parameterGroupDao.flush(); Long auditId = auditDetailDao.getNextSequence(); auditDetailDao.insertAuditDetailByPL( auditService.getTableName(parameterGroup), parameterGroup.getParamGroupId().toString(), "TEST_PL", auditId); }
@Override @RequestMapping(value = "/admin/suspendAccount", method = RequestMethod.POST) public ResponseEntity suspendAccount( @RequestBody AccountSuspensionInfo suspendInfo, @RequestHeader(value = "token") String token) { String actionName = "AdminControllerImpl.suspendAccount"; try { if (!sessionService.isSessionActive(token)) { return new ResponseEntity<>(HttpStatus.FORBIDDEN); } String userRoleForToken = sessionService.getUserRoleByToken(token); String usernameForToken = sessionService.getUsernameByToken(token); try { if (permissionService.isOperationAvailable(actionName, userRoleForToken)) { adminService.suspendAccount(suspendInfo); auditService.addEvent( new AuditItem( usernameForToken, actionName, suspendInfo.toString(), Constants.ADMIN_SUSPEND, true)); return new ResponseEntity<>(HttpStatus.OK); } else { auditService.addEvent( new AuditItem( usernameForToken, actionName, suspendInfo.toString(), Constants.NO_PERMISSION, false)); return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); } } catch (ServiceException serviceException) { auditService.addEvent( new AuditItem( usernameForToken, actionName, suspendInfo.toString(), serviceException.getMessage(), false)); return new ResponseEntity<>(serviceException.getMessage(), HttpStatus.UNPROCESSABLE_ENTITY); } catch (NotFoundException notFoundException) { auditService.addEvent( new AuditItem( usernameForToken, actionName, suspendInfo.toString(), notFoundException.getMessage(), false)); return new ResponseEntity<>(notFoundException.getMessage(), HttpStatus.NOT_FOUND); } } catch (ServiceException serviceException) { return new ResponseEntity<>(serviceException.getMessage(), HttpStatus.UNPROCESSABLE_ENTITY); } }