public static Object invokeService(Object bean, String serviceName, Object... args) throws ApplicationServiceException { try { Constructor constructor = findConstructor(serviceName, args); Object object = constructor.newInstance(args); if (object instanceof ApplicationService) { ApplicationService service = (ApplicationService) object; // Prepare Context ApplicationServiceContext context = new ApplicationServiceContext(bean); service.setContext(context); service.process(); if (context.getResult() != null) { System.out.println("service:" + serviceName + " returns value:" + context.getResult()); return context.getResult(); } } } catch (ApplicationServiceException ex) { Logger.getLogger(ApplicationServiceBus.class.getName()).log(Level.SEVERE, null, ex); throw ex; } catch (Exception ex) { Logger.getLogger(ApplicationServiceBus.class.getName()).log(Level.SEVERE, null, ex); throw new ApplicationServiceException("", ex); } return null; }
public List search(String searchClassName, Object criterion) throws Exception { try { ApplicationService applicationService = ApplicationServiceProvider.getApplicationService(); List criterionList = applicationService.search(searchClassName, criterion); return criterionList; }catch(Exception e) { log.error("Error thrown from Generic Service " + e.getMessage()); throw new org.apache.axis.AxisFault("Error thrown from Generic Service "+e.getMessage() ); } }
@Override public List<ApplicationModel> searchApplications( String criteria, User user, ApplicationType deviceType) { List<Application> applications = new ArrayList<Application>(); if (criteria != null && !criteria.isEmpty()) { criteria = criteria.toLowerCase(); List<Application> userApplications = userService.getApplicationsForUser( user, deviceType, AppState.ORGANIZATION_PUBLISH, AppState.GROUP_PUBLISH, AppState.ORG_PUBLISH_REQUEST); for (Application application : userApplications) { if ((application.getName().toLowerCase().contains(criteria) || application.getDescription().toLowerCase().contains(criteria)) && !applications.contains(application)) { applications.add(application); } } ComparatorChain chain = new ComparatorChain(); chain.addComparator(new ApplicationNameComparator()); chain.addComparator(new ApplicationDescriptionComparator()); Collections.sort(applications, chain); } return applicationService.createApplicationModels(applications); }
// This method returns all of the vulnerabilities and tab numbers public Object tableMap(int orgId, int appId, TableSortBean bean) throws IOException { if (appId != -1) { Application application = applicationService.loadApplication(appId); if (application == null || !application.isActive()) { log.warn(ResourceNotFoundException.getLogMessage("Application", appId)); throw new ResourceNotFoundException(); } // we update vulns and application information but not scan vulnerabilityFilterService.updateVulnerabilities(application); } if (orgId != -1) { Organization organization = organizationService.loadById(orgId); if (organization == null || !organization.isActive()) { log.warn(ResourceNotFoundException.getLogMessage("Team", orgId)); throw new ResourceNotFoundException(); } // we update vulns and team information but not scan vulnerabilityFilterService.updateVulnerabilities( organization, organization.getActiveAppIds()); } if (!PermissionUtils.isAuthorized(Permission.READ_ACCESS, orgId, appId)) { return RestResponse.failure("You are not authorized to view this information."); } return RestResponse.success("Bulk Operation successfully ended."); }
@PostConstruct void init() { List<Application> applications = applicationService.findValidateApplication(); for (Application application : applications) { execute(application); } }
public List<UrlResponseTime> queryUrlResponseTimesFromCatch(String applicationId) { List<UrlResponseTime> urlResponseTimes = urlResponseTimeCache.get(applicationId); if (urlResponseTimes == null) { urlResponseTimes = queryUrlResponseTimes(applicationId); urlResponseTimeCache.put(applicationId, urlResponseTimes); execute(applicationService.findApplication(applicationId)); } return urlResponseTimes; }
/** * Binds a service. * * @param service The service to bind. */ public void use(ApplicationService service) { services.put(service.getClass(), service); }