private void initializeUserAccount(RestOperations client) { if (this.user == null) { UaaUser user = testAccounts.getUser(); @SuppressWarnings("rawtypes") ResponseEntity<Map> results = client.getForEntity( serverRunning.getUserUri() + "?filter=userName eq '" + user.getUsername() + "'", Map.class); assertEquals(HttpStatus.OK, results.getStatusCode()); @SuppressWarnings("unchecked") List<Map<String, ?>> resources = (List<Map<String, ?>>) results.getBody().get("resources"); Map<String, ?> map; if (!resources.isEmpty()) { map = resources.get(0); } else { map = getUserAsMap(user); @SuppressWarnings("rawtypes") ResponseEntity<Map> response = client.postForEntity(serverRunning.getUserUri(), map, Map.class); Assert.state( response.getStatusCode() == HttpStatus.CREATED, "User account not created: status was " + response.getStatusCode()); @SuppressWarnings("unchecked") Map<String, ?> value = response.getBody(); map = value; } this.user = getUserFromMap(map); } }
public void resolveSiteType( ModelAndView modelAndView, String viewName, HttpServletRequest request) { SitePreference sitePreference = SitePreferenceUtils.getCurrentSitePreference(request); StringBuffer resultViewName = new StringBuffer(viewName); if (sitePreference.isMobile()) { resultViewName = resultViewName.insert(0, MOBILE_SITE_PREFIX); } modelAndView.setViewName(resultViewName.toString()); String url = UrlHelper.constructCurrentPageUrl(request); request.setAttribute("currentPageUrl", url); }
@Override public Representation find(String path) { path = path.replace(getServerUrl(), ""); if (!UrlHelper.hasExtension(path)) path = path + ".xml"; LocalReference ref = LocalReference.createClapReference(path); try { return new ClientResource(ref).get(); } catch (ResourceException e) { File file = new File("src/main/webapp" + path); if (file.exists() && !file.isDirectory()) return new FileRepresentation(file, MediaType.TEXT_PLAIN); throw new ResourceException(404); } }
private boolean clientExists(RestOperations client, OAuth2ProtectedResourceDetails resource) { ResponseEntity<String> response = client.getForEntity( serverRunning.getClientsUri() + "/" + resource.getClientId(), String.class); return response != null && response.getStatusCode() == HttpStatus.OK; }
private void createClient(RestOperations client, ClientDetails clientDetails) { ResponseEntity<String> response = client.postForEntity(serverRunning.getClientsUri(), clientDetails, String.class); assertEquals(HttpStatus.CREATED, response.getStatusCode()); }
@Override public void execute() throws MojoExecutionException, MojoFailureException { try { URL url = new URL(war); String targetFile = url.getFile().substring(url.getFile().lastIndexOf('/') + 1); File tempWarFile = new File(tempWar.getAbsolutePath() + File.separator + targetFile); if (!tempWarFile.exists()) { getLog().info("Dowloading = " + war + " -> " + tempWarFile.getAbsolutePath()); UrlHelper.getFile(war, tempWarFile); } File previous = new File(tempWar.getAbsolutePath() + File.separator + "extracted"); if (previous.exists()) { previous.delete(); } previous = new File(tempWar.getAbsolutePath() + File.separator + "extracted"); Resource res = new Resource(); res.setDirectory(filteredWar.getAbsolutePath()); project.getResources().add(res); String[] names = new String[0]; if (filtered != null) { names = filtered.split(","); for (String name : Arrays.asList(names)) { System.out.println("Filter=" + name); } } ZipHelper.unzipToTempDir(tempWarFile, previous, Arrays.asList(names)); if (!filteredWar.exists()) { filteredWar.mkdirs(); } ZipHelper.zipFolder( previous.getAbsolutePath(), filteredWar.getAbsolutePath() + File.separator + targetFile); /* ZipHelper.unzipToTempDir(tempWarFile, outputClasses) BundlerHelper.copyWebInf(outputClasses); String sjars = singletonJars; if(sjars == null){ sjars = ""; } String[] lsjars = sjars.split(","); BundlerHelper.generateManifest(project, outputClasses,lsjars); Resource resource = new Resource(); resource.setDirectory(outputClasses.getPath()); project.getResources().add(resource); Resource resource2 = new Resource(); resource2.setDirectory(sourceOutputDirectory.getPath()+File.separator+"KEV-INF"); resource2.setTargetPath("KEV-INF"); project.getResources().add(resource2); */ // GENERATE KEVOREE COMPONENT WRAPPER /* Dependency dep = new Dependency(); dep.setArtifactId("org.kevoree.library.javase.webserver.servlet"); dep.setGroupId("org.kevoree.library.javase"); dep.setVersion(KevoreeFactory.getVersion()); dep.setType("bundle"); dep.setScope("compile"); project.getCompileDependencies().add(dep); Dependency dep2 = new Dependency(); dep2.setArtifactId("org.kevoree.library.javase.webserver"); dep2.setGroupId("org.kevoree.library.javase"); dep2.setVersion(KevoreeFactory.getVersion()); dep2.setType("bundle"); dep2.setScope("compile"); project.getCompileDependencies().add(dep2); */ /* Dependency dep3 = new Dependency(); dep3.setArtifactId("org.kevoree.extra.jetty"); dep3.setGroupId("org.kevoree.extra"); dep3.setVersion("8.1.0.RC2"); dep3.setType("bundle"); dep3.setScope("compile"); project.getCompileDependencies().add(dep3);*/ // WrapperGenerator.generate(sourceOutputDirectory,project,BundlerHelper.getWebInfParams(outputClasses),lsjars); // project.getBuild().setSourceDirectory(sourceOutputDirectory.getAbsolutePath()); } catch (Exception e) { e.printStackTrace(); getLog().error(e); } }
public List<Route> retrieveRoutes(String stopNumber) { String jsonResult = UrlHelper.readTextFromUrl(STOPS_URL + stopNumber); return processJSON(jsonResult); }