@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); PrintWriter writer = response.getWriter(); writer.println("<!doctype html><html><head>"); writer.println("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">"); writer.println("<title>" + APP_NAME + "</title>"); writer.println("</head><body>"); final Credential v1credential = this.getCredential(); HttpRequestFactory requestFactory = Utils.HTTP_TRANSPORT.createRequestFactory( new HttpRequestInitializer() { public void initialize(HttpRequest request) throws IOException { v1credential.initialize(request); } }); GenericUrl v1url = new GenericUrl(secrets.getServerBaseUri()); // Add the OAuth API end-point v1url.getPathParts().add("rest-1.oauth.v1"); // Add a simple data query for the currently logged in member v1url.getPathParts().add("Data"); v1url.getPathParts().add("Member"); v1url.set("where", "IsSelf=\'true\'"); // Send request to VersionOne and print the results. HttpRequest v1request = requestFactory.buildGetRequest(v1url); HttpResponse v1response = v1request.execute(); printMemberDetails(writer, v1response); writer.println("</body></html>"); }
/** * Searching places * * @param latitude - latitude of place * @params longitude - longitude of place * @param radius - radius of searchable area * @param types - type of place to search * @return list of places */ public PlacesList search(double latitude, double longitude, double radius, String types) throws Exception { this._latitude = latitude; this._longitude = longitude; this._radius = radius; try { HttpRequestFactory httpRequestFactory = createRequestFactory(HTTP_TRANSPORT); HttpRequest request = httpRequestFactory.buildGetRequest(new GenericUrl(PLACES_SEARCH_URL)); request.getUrl().put("key", API_KEY); request.getUrl().put("location", _latitude + "," + _longitude); request.getUrl().put("radius", _radius); // in meters request.getUrl().put("sensor", "false"); if (types != null) request.getUrl().put("types", types); PlacesList list = request.execute().parseAs(PlacesList.class); // Check log cat for places response status Log.d("Places Status", "" + list.status); return list; } catch (HttpResponseException e) { Log.e("Error:", e.getMessage()); return null; } }
public static UserInfo build(String accessToken, String refreshToken) throws IOException { GoogleAccessProtectedResource access = new GoogleAccessProtectedResource( accessToken, ConstFunc.TRANSPORT, ConstFunc.JSON_FACTORY, ConstFunc.CLIENT_ID, ConstFunc.CLIENT_SECRET, refreshToken); HttpRequestFactory rf = ConstFunc.TRANSPORT.createRequestFactory(access); GenericUrl userInfoUrl = new GenericUrl("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + accessToken); HttpRequest request = rf.buildGetRequest(userInfoUrl); HttpResponse response = request.execute(); InputStream is = response.getContent(); Reader isr = new InputStreamReader(is, "UTF-8"); Gson gson = new Gson(); UserInfo ui = gson.fromJson(isr, UserInfo.class); ui.setAccess_token(accessToken); ui.setRefresh_token(refreshToken); return ui; }
/** * Expects an Authentication Code, and makes an authenticated request for the user's profile * information * * @return JSON formatted user profile information * @param authCode authentication code provided by google */ public String getUserInfoJson(final String authCode, final String userName) throws IOException { final GoogleTokenResponse response = flow.newTokenRequest(authCode).setRedirectUri(CALLBACK_URI).execute(); System.out.println("resp=" + response); Credential credential = flow.createAndStoreCredential(response, userName); final HttpRequestFactory requestFactory = HTTP_TRANSPORT.createRequestFactory(credential); // Make an authenticated request final GenericUrl url = new GenericUrl(USER_INFO_URL); final HttpRequest request = requestFactory.buildGetRequest(url); request.getHeaders().setContentType("application/json"); final String jsonIdentity = request.execute().parseAsString(); return jsonIdentity; }
public WorksheetEntry addWorksheet(WorksheetEntry worksheetEntry, SpreadsheetUrl worksheetfeedUrl) throws IOException { AtomContent content = AtomContent.forEntry(DICTIONARY, worksheetEntry); HttpRequest request = requestFactory.buildPostRequest(worksheetfeedUrl, content); // request.getHeaders().setIfNoneMatch(worksheetEntry.etag); return request.execute().parseAs(worksheetEntry.getClass()); }
public String call() throws IOException, IllegalArgumentException { if (urlToFetch == null) { throw new IllegalArgumentException("Need a URL to fetch"); } log.info("urlToFetch: " + urlToFetch); String[] filenameParts = urlToFetch.split("/"); String basename = filenameParts[filenameParts.length - 1]; String absoluteFilePath = outputDir + File.separator + basename; File finalMP3 = new File(absoluteFilePath); Path pathFinalMP3 = finalMP3.toPath(); if (finalMP3.exists()) { log.info("Looks like " + basename + " is already there.. Skipping"); } else { GenericUrl url = new GenericUrl(urlToFetch); HttpRequest request = requestFactory.buildGetRequest(url); File f = downloadToTempFile(request); Path pathTempMP3 = f.toPath(); moveToFile(pathTempMP3, pathFinalMP3); } return pathFinalMP3.toString(); }
public static DocumentListEntry executePost( HttpRequestFactory requestFactory, DocsUrl url, AtomContent content) throws IOException { HttpRequest request = requestFactory.buildPostRequest(url, content); HttpResponse response = requestExecutor.executeSensitive(request); return response.parseAs(DocumentListEntry.class); }
public static InputStream executeGetContent(HttpRequestFactory requestFactory, DocsUrl url) throws IOException { HttpRequest request = requestFactory.buildGetRequest(url); HttpResponse response = requestExecutor.executeNonSensitive(request); return response.getContent(); }
public static Entry executeGet( HttpRequestFactory requestFactory, DocsUrl url, Class<Entry> feedClass) throws IOException { HttpRequest request = requestFactory.buildGetRequest(url); HttpResponse response = requestExecutor.executeNonSensitive(request); return response.parseAs(feedClass); }
public CellEntry addCellEntry(CellEntry cellEntry, SpreadsheetUrl cellfeedUrl) throws IOException { AtomContent content = AtomContent.forEntry(DICTIONARY, cellEntry); HttpRequest request = requestFactory.buildPostRequest(cellfeedUrl, content); request.getHeaders().setIfNoneMatch(((CellEntry) cellEntry).etag); return request.execute().parseAs(cellEntry.getClass()); }
private HttpResponse putRequest( byte[] bytes, int position, int length, String fileType, HttpRequestFactory requestFactory, long size, String location) throws HttpResponseException { try { InputStreamContent inputStreamContent = new InputStreamContent(fileType, new ByteArrayInputStream(bytes)); HttpRequest chunkRequest = requestFactory.buildPutRequest(new DocsUrl(location), inputStreamContent); chunkRequest.getHeaders().setContentRange(range(position, length, size)); chunkRequest.getHeaders().setContentLength((long) length); return requestExecutor.executeNonSensitive(chunkRequest); } catch (HttpResponseException e) { throw e; } catch (Exception e) { String message = "unable to upload chunk number " + position + ", " + e.getMessage(); logger.error(message); throw new CoreException(message, e); } }
public static void executeDelete( HttpRequestFactory requestFactory, DocsUrl url, String etag, boolean matchAll) throws IOException { HttpRequest request = requestFactory.buildDeleteRequest(url); if (matchAll) request.getHeaders().setIfMatch("*"); else request.getHeaders().setIfMatch(etag); HttpResponse response = requestExecutor.executeNonSensitive(request); response.ignore(); }
/** * Searching single place full details * * @param reference - reference id of place - which you will get in search api request */ public PlaceDetails getPlaceDetails(String reference) throws Exception { try { HttpRequestFactory httpRequestFactory = createRequestFactory(HTTP_TRANSPORT); HttpRequest request = httpRequestFactory.buildGetRequest(new GenericUrl(PLACES_DETAILS_URL)); request.getUrl().put("key", API_KEY); request.getUrl().put("reference", reference); request.getUrl().put("sensor", "false"); PlaceDetails place = request.execute().parseAs(PlaceDetails.class); return place; } catch (HttpResponseException e) { Log.e("Error in Perform Details", e.getMessage()); throw e; } }
public boolean updateMobileDevice( String serialNumber, String deviceName, String assetTag, String building, String room, String department) { boolean success = false; MobileDeviceMatch match = findMobileDevice(serialNumber); if (match != null) { // TODO: urlencode string String id = match.id; MobileDevice device = getMobileDevice(id); if (device != null) { String updateUrlString = jssServerUrl + MOBILE_DEVICES_API_PATH + "/id/" + id; GenericUrl updateUrl = new GenericUrl(updateUrlString); int status = 500; try { device.general.deviceName = deviceName; device.general.assetTag = assetTag; if (building != null && !building.isEmpty()) { device.location.building = building; } if (room != null && !room.isEmpty()) { device.location.room = room; } if (department != null && !department.isEmpty()) { device.location.department = department; } XmlHttpContent content = new XmlHttpContent(nsdict, "mobile_device", device); if (debug) { OutputStream out = new ByteArrayOutputStream(); content.writeTo(out); System.out.println("content " + out.toString()); } // JSS REST API - use PUT method to update existing object HttpRequest updateRequest = factory.buildPutRequest(updateUrl, content); HttpResponse updateResponse = updateRequest.execute(); status = updateResponse.getStatusCode(); if (status < 400) { success = true; } } catch (Exception ex1) { System.out.println("Exception! " + ex1.getMessage()); } if (debug) { System.out.println("update " + id + ", status " + String.valueOf(status)); } } } return success; }
@Override public GameState call() throws Exception { HttpContent content; HttpRequest request; HttpResponse response; GameState gameState = null; AdvancedGameState advancedGameState; try { // Initial request logger.info("Sending initial request..."); content = new UrlEncodedContent(apiKey); request = REQUEST_FACTORY.buildPostRequest(gameUrl, content); request.setReadTimeout(0); // Wait forever to be assigned to a game response = request.execute(); gameState = response.parseAs(GameState.class); logger.info("Game URL: {}", gameState.getViewUrl()); advancedGameState = new AdvancedGameState(gameState); // Game loop while (!gameState.getGame().isFinished() && !gameState.getHero().isCrashed()) { logger.info("Taking turn " + gameState.getGame().getTurn()); BotMove direction = bot.move(advancedGameState); Move move = new Move(apiKey.getKey(), direction.toString()); HttpContent turn = new UrlEncodedContent(move); HttpRequest turnRequest = REQUEST_FACTORY.buildPostRequest(new GenericUrl(gameState.getPlayUrl()), turn); HttpResponse turnResponse = turnRequest.execute(); gameState = turnResponse.parseAs(GameState.class); advancedGameState = new AdvancedGameState(advancedGameState, gameState); } } catch (Exception e) { logger.error("Error during game play", e); } logger.info("Game over"); return gameState; }
@Test public void test() throws IOException { HttpTransport transport = injector.getInstance(HttpTransport.class); JsonFactory jsonFactory = injector.getInstance(JsonFactory.class); DriveManager drive = new DriveManager( transport, jsonFactory, GoogleOAuth2.getGlobalCredential(transport, jsonFactory)); Drive service = drive.getClient(); File file = service.files().get("1HyyFJfqms_ZII3kNHr9smIXFadMYNRQvXsOhLOsUhLg").execute(); // IOUtils.toString(downloadFile(service, file)); String downloadUrl = file.getExportLinks().get("text/html"); System.out.println(downloadUrl); HttpRequestFactory factory = transport.createRequestFactory(); HttpRequest request = factory.buildGetRequest(new GenericUrl(downloadUrl)); HttpResponse response = request.execute(); System.out.println(IOUtils.toString(response.getContent())); }
public CellEntry executeInsert(CellEntry entry, boolean matchTag) throws IOException { AtomContent content = AtomContent.forEntry(DICTIONARY, entry); HttpRequest request = requestFactory.buildPutRequest(new SpreadsheetUrl(entry.getEditLink()), content); if (matchTag) { // this will only insert if there has been no modification. request.getHeaders().setIfMatch(((CellEntry) entry).etag); } else { // this will only insert if there has been a modification request.getHeaders().setIfNoneMatch(((CellEntry) entry).etag); } return request.execute().parseAs(entry.getClass()); }
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { try { AppIdentityCredential credential = new AppIdentityCredential(Arrays.asList(STORAGE_SCOPE)); // Set up and execute Google Cloud Storage request. String bucketName = req.getRequestURI(); if (bucketName.equals("/")) { resp.sendError( HTTP_NOT_FOUND, "No bucket specified - append /bucket-name to the URL and retry."); return; } // Remove any trailing slashes, if found. // [START snippet] String cleanBucketName = bucketName.replaceAll("/$", ""); String uri = GCS_URI + cleanBucketName; HttpRequestFactory requestFactory = HTTP_TRANSPORT.createRequestFactory(credential); GenericUrl url = new GenericUrl(uri); HttpRequest request = requestFactory.buildGetRequest(url); HttpResponse response = request.execute(); String content = response.parseAsString(); // [END snippet] // Display the output XML. resp.setContentType("text/xml"); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(resp.getOutputStream())); String formattedContent = content.replaceAll("(<ListBucketResult)", XSL + "$1"); writer.append(formattedContent); writer.flush(); resp.setStatus(HTTP_OK); } catch (Throwable e) { resp.sendError(HTTP_NOT_FOUND, e.getMessage()); } }
protected InputStream getContentStream(String downloadURL) throws PortalException { if (Validator.isNull(downloadURL)) { return null; } Drive drive = getDrive(); HttpRequestFactory httpRequestFactory = drive.getRequestFactory(); GenericUrl genericUrl = new GenericUrl(downloadURL); try { HttpRequest httpRequest = httpRequestFactory.buildGetRequest(genericUrl); HttpResponse httpResponse = httpRequest.execute(); return httpResponse.getContent(); } catch (IOException ioe) { _log.error(ioe, ioe); throw new SystemException(ioe); } }
public CellFeed batchUpdate(CellFeed feed) throws IOException { List<CellEntry> updatedCells = Lists.newArrayList(); for (CellEntry ce : feed.cells) { if (ce.batchId != null) { updatedCells.add(ce); } } feed.cells = updatedCells; SpreadsheetUrl url = new SpreadsheetUrl(feed.getBatchLink()); // AtomFeedContent content = new AtomFeedContent(); AtomContent content = AtomContent.forFeed(DICTIONARY, feed); // content.namespaceDictionary = DICTIONARY; // content.feed = feed; HttpRequest request = requestFactory.buildPostRequest(url, content); request.getHeaders().setIfNoneMatch("whatever"); return request.execute().parseAs(CellFeed.class); }
public MobileDeviceMatch findMobileDevice(String serialNumber) { // TODO: urlencode string String matchUrlString = jssServerUrl + MOBILE_DEVICES_API_PATH + "/match/" + serialNumber; GenericUrl matchUrl = new GenericUrl(matchUrlString); int status = 500; try { // JSS REST API - use GET method to query existing objects // (read-only) HttpRequest matchRequest = factory.buildGetRequest(matchUrl); HttpResponse matchResponse = matchRequest.execute(); status = matchResponse.getStatusCode(); if (status < 400) { MobileDeviceList mobileDevices = matchResponse.parseAs(MobileDeviceList.class); if (mobileDevices.size == 1) { MobileDeviceMatch device = mobileDevices.first(); if (debug) { System.out.println( "match " + serialNumber + ", status " + String.valueOf(status) + ", id " + device.id); } if (device.id != null && !device.id.isEmpty()) { return device; } } else if (debug) { System.out.println( "match " + serialNumber + ", got " + String.valueOf(mobileDevices.size) + " devices"); } } } catch (IndexOutOfBoundsException ex0) { System.out.println("Didn't parse any devices. "); } catch (Exception ex1) { System.out.println("Exception! " + ex1.getMessage()); } if (debug) { // Not found or internal error System.out.println("match " + serialNumber + ", status " + String.valueOf(status)); } return null; }
public MobileDevice getMobileDevice(String id) { String getUrlString = jssServerUrl + MOBILE_DEVICES_API_PATH + "/id/" + id; GenericUrl getUrl = new GenericUrl(getUrlString); int status = 500; try { // JSS REST API - use GET method to query existing objects // (read-only) HttpRequest getRequest = factory.buildGetRequest(getUrl); HttpResponse getResponse = getRequest.execute(); status = getResponse.getStatusCode(); if (status < 400) { MobileDevice device = getResponse.parseAs(MobileDevice.class); if (device != null) { return device; } } } catch (Exception ex1) { System.out.println("Exception! " + ex1.getMessage()); } return null; }
private String initUpload( HttpRequestFactory requestFactory, DocsUrl url, long size, String fileType, AtomContent fileContent) throws IOException { HttpRequest request = requestFactory.buildPostRequest(url, fileContent); request.getHeaders().set("X-Upload-Content-Type", fileType); request.getHeaders().set("X-Upload-Content-Length", size); HttpResponse response = requestExecutor.executeNonSensitive(request); if (!response.isSuccessStatusCode()) { throw new CoreException( "unable to initiate upload, " + response.getStatusCode() + ": " + response.getStatusMessage()); } response.ignore(); return response.getHeaders().getLocation(); }
public List<BeanUsuarioDirectorio> BuscarUsuario() { String resultado = null; List<BeanUsuarioDirectorio> empleadosNuevos = new ArrayList<BeanUsuarioDirectorio>(); BeanUsuarioDirectorio empleadoNuevo = null; try { List<String> SCOPES = Arrays.asList("email"); String emailAddressDev = "*****@*****.**"; JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); NetHttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); GoogleCredential credential; credential = new GoogleCredential.Builder() .setTransport(httpTransport) .setJsonFactory(JSON_FACTORY) .setServiceAccountId(emailAddressDev) .setServiceAccountPrivateKey(key) .setServiceAccountScopes(SCOPES) .setServiceAccountUser("*****@*****.**") .build(); if (listaRegistrosCyge != null) { for (BeanCyge registroCyge : listaRegistrosCyge) { if ((registroCyge.getEmail() != null) && (!registroCyge.getEmail().isEmpty()) && !registroCyge.getEmail().trim().isEmpty()) { /*PRUEBA OFFLINE*/ try { String URI = "https://bbva-gapis.appspot.com/gprofile/users/" + registroCyge.getEmail(); HttpRequestFactory requestFactory = httpTransport.createRequestFactory(credential); GenericUrl url = new GenericUrl(URI); HttpRequest request = requestFactory.buildGetRequest(url); HttpResponse response = request.execute(); String content = response.parseAsString(); resultado = content; /*END PRUEBA OFFLINE*/ // resultado = // "{\"code\":\"OK\",\"message\":\"successful\",\"data\":{\"userDefinedFields\":[{\"key\":\"uid\",\"value\":\"MB58756\"},{\"key\":\"descOUPadre\",\"value\":\"SISTEMAS Y OPERACIONES\"},{\"key\":\"codCorporativo\",\"value\":\"00003719381\"},{\"key\":\"descEmpresaExterno\",\"value\":\" \"},{\"key\":\"codCargo\",\"value\":\"IHJ\"},{\"key\":\"descEmpresa\",\"value\":\"BBVA BANCOMER SERVICIO ADMINIS\"},{\"key\":\"codCSB\",\"value\":\"9016\"},{\"key\":\"descOUBase\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descOUNivel10\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descCentroCoste\",\"value\":\"D Y D CANALES\"},{\"key\":\"uidJefe\",\"value\":\"M901737\"},{\"key\":\"codEstado\",\"value\":\"DF\"},{\"key\":\"codOUNivel10\",\"value\":\"00012899\"},{\"key\":\"codOUPadre\",\"value\":\"00005833\"},{\"key\":\"descpais\",\"value\":\"MÉXICO\"},{\"key\":\"c\",\"value\":\"MEX\"},{\"key\":\"telephoneNumber\",\"value\":\" \"},{\"key\":\"rangoGlobal\",\"value\":\" \"},{\"key\":\"codPostalCentroTrabajo\",\"value\":\"03339\"},{\"key\":\"codBancoOficinaPers\",\"value\":\"01853307\"},{\"key\":\"descCentroTrabajo\",\"value\":\"CENTRO BANCOMER D.F. (CON COME\"},{\"key\":\"descEstado\",\"value\":\"DISTRITO FEDERAL\"},{\"key\":\"mobile\",\"value\":\" \"},{\"key\":\"descLargaPlanta\",\"value\":\"N-6 C-A C-E M-7 E-24\"},{\"key\":\"esEmpleado\",\"value\":\"E\"},{\"key\":\"title\",\"value\":\"LIDER DE PROYECTO DYD A\"},{\"key\":\"o\",\"value\":\"0185\"},{\"key\":\"codCentroCoste\",\"value\":\"0000\"},{\"key\":\"posicion\",\"value\":\"00238344\"},{\"key\":\"pager\",\"value\":\" \"},{\"key\":\"apellido2\",\"value\":\"RAMIREZ\"},{\"key\":\"codCentroTrabajo\",\"value\":\"25001\"},{\"key\":\"descOUNivel2\",\"value\":\"MEXICO\"},{\"key\":\"descOUNivel1\",\"value\":\"MEXICO\"},{\"key\":\"mail\",\"value\":\"[email protected]\"},{\"key\":\"codOficina\",\"value\":\"01853307\"},{\"key\":\"codOUNivel1\",\"value\":\"00000141\"},{\"key\":\"codOUNivel2\",\"value\":\"00000141\"},{\"key\":\"apellido1\",\"value\":\"ROSAS\"},{\"key\":\"codOUNivel3\",\"value\":\"00005833\"},{\"key\":\"descCodPostalCentroTrabajo\",\"value\":\"DF\"},{\"key\":\"descOUNivel9\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descOUNivel8\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descOUNivel7\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descOUNivel6\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descOUNivel5\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descOUNivel4\",\"value\":\"TECNOLOGIA MULTICANAL\"},{\"key\":\"descOUNivel3\",\"value\":\"SISTEMAS Y OPERACIONES\"},{\"key\":\"descBancoOficinaPers\",\"value\":\"3307\"},{\"key\":\"corporateNumber\",\"value\":\" \"},{\"key\":\"codOUNivel5\",\"value\":\"00012899\"},{\"key\":\"codOUNivel4\",\"value\":\"00010142\"},{\"key\":\"codOUNivel7\",\"value\":\"00012899\"},{\"key\":\"codOUNivel6\",\"value\":\"00012899\"},{\"key\":\"codOUNivel9\",\"value\":\"00012899\"},{\"key\":\"codOUNivel8\",\"value\":\"00012899\"}],\"id\":\"102286709937216158038\",\"addresses\":[{\"country\":\"MÉXICO\",\"countryCode\":\"ES\",\"formatted\":\"DISTRITO FEDERAL\\n03339\\nMÉXICO\",\"locality\":\"DF\",\"poBox\":\"03339\",\"postalCode\":\"03339\",\"streetAddress\":\"N-6 C-A C-E M-7 E-24\",\"type\":\"work\"}],\"updateTime\":1449889391185,\"customSchemas\":{\"ldapUserData\":{\"uid\":\"MB58756\",\"descOUPadre\":\"SISTEMAS Y OPERACIONES\",\"codCorporativo\":\"00003719381\",\"descEmpresaExterno\":\" \",\"codCargo\":\"IHJ\",\"descEmpresa\":\"BBVA BANCOMER SERVICIO ADMINIS\",\"codCSB\":\"9016\",\"descOUBase\":\"CANALES ATENDIDOS\",\"descOUNivel10\":\"CANALES ATENDIDOS\",\"descCentroCoste\":\"D Y D CANALES\",\"uidJefe\":\"M901737\",\"codEstado\":\"DF\",\"codOUNivel10\":\"00012899\",\"codOUPadre\":\"00005833\",\"descpais\":\"MÉXICO\",\"codPais\":\"MEX\",\"telephoneNumber\":\" \",\"rangoGlobal\":\" \",\"codPostalCentroTrabajo\":\"03339\",\"codBancoOficinaPers\":\"01853307\",\"descCentroTrabajo\":\"CENTRO BANCOMER D.F. (CON COME\",\"descEstado\":\"DISTRITO FEDERAL\",\"mobile\":\" \",\"descLargaPlanta\":\"N-6 C-A C-E M-7 E-24\",\"esEmpleado\":\"E\",\"title\":\"LIDER DE PROYECTO DYD A\",\"organization\":\"0185\",\"codCentroCoste\":\"0000\",\"posicion\":\"00238344\",\"pager\":\" \",\"apellido2\":\"RAMIREZ\",\"codCentroTrabajo\":\"25001\",\"descOUNivel2\":\"MEXICO\",\"descOUNivel1\":\"MEXICO\",\"mail\":\"[email protected]\",\"codOficina\":\"01853307\",\"codOUNivel1\":\"00000141\",\"codOUNivel2\":\"00000141\",\"apellido1\":\"ROSAS\",\"codOUNivel3\":\"00005833\",\"descCodPostalCentroTrabajo\":\"DF\",\"descOUNivel9\":\"CANALES ATENDIDOS\",\"descOUNivel8\":\"CANALES ATENDIDOS\",\"descOUNivel7\":\"CANALES ATENDIDOS\",\"descOUNivel6\":\"CANALES ATENDIDOS\",\"descOUNivel5\":\"CANALES ATENDIDOS\",\"descOUNivel4\":\"TECNOLOGIA MULTICANAL\",\"descOUNivel3\":\"SISTEMAS Y OPERACIONES\",\"descBancoOficinaPers\":\"3307\",\"corporateNumber\":\" \",\"codOUNivel5\":\"00012899\",\"codOUNivel4\":\"00010142\",\"codOUNivel7\":\"00012899\",\"codOUNivel6\":\"00012899\",\"codOUNivel9\":\"00012899\",\"codOUNivel8\":\"00012899\"}},\"emails\":[{\"address\":\"[email protected]\",\"primary\":true}],\"etag\":\"\\\"KuAr0EK1uUI7oJNfO_dWOREN2ro/dbE6bs1euQMov6wc4Dmi3rfnjUc\\\"\",\"externalIds\":[{\"customType\":\"Employee ID\",\"type\":\"custom\",\"value\":\"MB58756\"}],\"kind\":\"admin#directory#user\",\"name\":{\"familyName\":\"ROSAS RAMIREZ\",\"fullName\":\"PEDRO ROSAS RAMIREZ\",\"givenName\":\"PEDRO\"},\"nonEditableAliases\":[\"[email protected]\"],\"organizations\":[{\"customType\":\"Work\",\"department\":\"CANALES ATENDIDOS\",\"location\":\"018533073307\",\"name\":\"BBVA BANCOMER SERVICIO ADMINIS\",\"primary\":true,\"title\":\"LIDER DE PROYECTO DYD A\"}],\"primaryEmail\":\"[email protected]\",\"suspended\":false,\"status\":\"ACTIVE\",\"ouResponsible\":{\"id\":\"00012899\",\"name\":\"CANALES ATENDIDOS\",\"responsibleEmployeeId\":\"M62139\",\"updateDate\":1450243038394}}}"; ParsearJson parser = new ParsearJson(); empleadoNuevo = parser.ConvertirAUsuario(resultado); System.out.println(resultado); empleadosNuevos.add(empleadoNuevo); } catch (Exception e) { e.printStackTrace(); } } } } else { for (String strEmailUsuario : listaEmailsUsuarios) { /*PRUEBA OFFLINE*/ String URI = "https://bbva-gapis.appspot.com/gprofile/users/" + strEmailUsuario; HttpRequestFactory requestFactory = httpTransport.createRequestFactory(credential); GenericUrl url = new GenericUrl(URI); HttpRequest request = requestFactory.buildGetRequest(url); HttpResponse response = request.execute(); String content = response.parseAsString(); resultado = content; /*END PRUEBA OFFLINE*/ // resultado = // "{\"code\":\"OK\",\"message\":\"successful\",\"data\":{\"userDefinedFields\":[{\"key\":\"uid\",\"value\":\"MB58756\"},{\"key\":\"descOUPadre\",\"value\":\"SISTEMAS Y OPERACIONES\"},{\"key\":\"codCorporativo\",\"value\":\"00003719381\"},{\"key\":\"descEmpresaExterno\",\"value\":\" \"},{\"key\":\"codCargo\",\"value\":\"IHJ\"},{\"key\":\"descEmpresa\",\"value\":\"BBVA BANCOMER SERVICIO ADMINIS\"},{\"key\":\"codCSB\",\"value\":\"9016\"},{\"key\":\"descOUBase\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descOUNivel10\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descCentroCoste\",\"value\":\"D Y D CANALES\"},{\"key\":\"uidJefe\",\"value\":\"M901737\"},{\"key\":\"codEstado\",\"value\":\"DF\"},{\"key\":\"codOUNivel10\",\"value\":\"00012899\"},{\"key\":\"codOUPadre\",\"value\":\"00005833\"},{\"key\":\"descpais\",\"value\":\"MÉXICO\"},{\"key\":\"c\",\"value\":\"MEX\"},{\"key\":\"telephoneNumber\",\"value\":\" \"},{\"key\":\"rangoGlobal\",\"value\":\" \"},{\"key\":\"codPostalCentroTrabajo\",\"value\":\"03339\"},{\"key\":\"codBancoOficinaPers\",\"value\":\"01853307\"},{\"key\":\"descCentroTrabajo\",\"value\":\"CENTRO BANCOMER D.F. (CON COME\"},{\"key\":\"descEstado\",\"value\":\"DISTRITO FEDERAL\"},{\"key\":\"mobile\",\"value\":\" \"},{\"key\":\"descLargaPlanta\",\"value\":\"N-6 C-A C-E M-7 E-24\"},{\"key\":\"esEmpleado\",\"value\":\"E\"},{\"key\":\"title\",\"value\":\"LIDER DE PROYECTO DYD A\"},{\"key\":\"o\",\"value\":\"0185\"},{\"key\":\"codCentroCoste\",\"value\":\"0000\"},{\"key\":\"posicion\",\"value\":\"00238344\"},{\"key\":\"pager\",\"value\":\" \"},{\"key\":\"apellido2\",\"value\":\"RAMIREZ\"},{\"key\":\"codCentroTrabajo\",\"value\":\"25001\"},{\"key\":\"descOUNivel2\",\"value\":\"MEXICO\"},{\"key\":\"descOUNivel1\",\"value\":\"MEXICO\"},{\"key\":\"mail\",\"value\":\"[email protected]\"},{\"key\":\"codOficina\",\"value\":\"01853307\"},{\"key\":\"codOUNivel1\",\"value\":\"00000141\"},{\"key\":\"codOUNivel2\",\"value\":\"00000141\"},{\"key\":\"apellido1\",\"value\":\"ROSAS\"},{\"key\":\"codOUNivel3\",\"value\":\"00005833\"},{\"key\":\"descCodPostalCentroTrabajo\",\"value\":\"DF\"},{\"key\":\"descOUNivel9\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descOUNivel8\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descOUNivel7\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descOUNivel6\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descOUNivel5\",\"value\":\"CANALES ATENDIDOS\"},{\"key\":\"descOUNivel4\",\"value\":\"TECNOLOGIA MULTICANAL\"},{\"key\":\"descOUNivel3\",\"value\":\"SISTEMAS Y OPERACIONES\"},{\"key\":\"descBancoOficinaPers\",\"value\":\"3307\"},{\"key\":\"corporateNumber\",\"value\":\" \"},{\"key\":\"codOUNivel5\",\"value\":\"00012899\"},{\"key\":\"codOUNivel4\",\"value\":\"00010142\"},{\"key\":\"codOUNivel7\",\"value\":\"00012899\"},{\"key\":\"codOUNivel6\",\"value\":\"00012899\"},{\"key\":\"codOUNivel9\",\"value\":\"00012899\"},{\"key\":\"codOUNivel8\",\"value\":\"00012899\"}],\"id\":\"102286709937216158038\",\"addresses\":[{\"country\":\"MÉXICO\",\"countryCode\":\"ES\",\"formatted\":\"DISTRITO FEDERAL\\n03339\\nMÉXICO\",\"locality\":\"DF\",\"poBox\":\"03339\",\"postalCode\":\"03339\",\"streetAddress\":\"N-6 C-A C-E M-7 E-24\",\"type\":\"work\"}],\"updateTime\":1449889391185,\"customSchemas\":{\"ldapUserData\":{\"uid\":\"MB58756\",\"descOUPadre\":\"SISTEMAS Y OPERACIONES\",\"codCorporativo\":\"00003719381\",\"descEmpresaExterno\":\" \",\"codCargo\":\"IHJ\",\"descEmpresa\":\"BBVA BANCOMER SERVICIO ADMINIS\",\"codCSB\":\"9016\",\"descOUBase\":\"CANALES ATENDIDOS\",\"descOUNivel10\":\"CANALES ATENDIDOS\",\"descCentroCoste\":\"D Y D CANALES\",\"uidJefe\":\"M901737\",\"codEstado\":\"DF\",\"codOUNivel10\":\"00012899\",\"codOUPadre\":\"00005833\",\"descpais\":\"MÉXICO\",\"codPais\":\"MEX\",\"telephoneNumber\":\" \",\"rangoGlobal\":\" \",\"codPostalCentroTrabajo\":\"03339\",\"codBancoOficinaPers\":\"01853307\",\"descCentroTrabajo\":\"CENTRO BANCOMER D.F. (CON COME\",\"descEstado\":\"DISTRITO FEDERAL\",\"mobile\":\" \",\"descLargaPlanta\":\"N-6 C-A C-E M-7 E-24\",\"esEmpleado\":\"E\",\"title\":\"LIDER DE PROYECTO DYD A\",\"organization\":\"0185\",\"codCentroCoste\":\"0000\",\"posicion\":\"00238344\",\"pager\":\" \",\"apellido2\":\"RAMIREZ\",\"codCentroTrabajo\":\"25001\",\"descOUNivel2\":\"MEXICO\",\"descOUNivel1\":\"MEXICO\",\"mail\":\"[email protected]\",\"codOficina\":\"01853307\",\"codOUNivel1\":\"00000141\",\"codOUNivel2\":\"00000141\",\"apellido1\":\"ROSAS\",\"codOUNivel3\":\"00005833\",\"descCodPostalCentroTrabajo\":\"DF\",\"descOUNivel9\":\"CANALES ATENDIDOS\",\"descOUNivel8\":\"CANALES ATENDIDOS\",\"descOUNivel7\":\"CANALES ATENDIDOS\",\"descOUNivel6\":\"CANALES ATENDIDOS\",\"descOUNivel5\":\"CANALES ATENDIDOS\",\"descOUNivel4\":\"TECNOLOGIA MULTICANAL\",\"descOUNivel3\":\"SISTEMAS Y OPERACIONES\",\"descBancoOficinaPers\":\"3307\",\"corporateNumber\":\" \",\"codOUNivel5\":\"00012899\",\"codOUNivel4\":\"00010142\",\"codOUNivel7\":\"00012899\",\"codOUNivel6\":\"00012899\",\"codOUNivel9\":\"00012899\",\"codOUNivel8\":\"00012899\"}},\"emails\":[{\"address\":\"[email protected]\",\"primary\":true}],\"etag\":\"\\\"KuAr0EK1uUI7oJNfO_dWOREN2ro/dbE6bs1euQMov6wc4Dmi3rfnjUc\\\"\",\"externalIds\":[{\"customType\":\"Employee ID\",\"type\":\"custom\",\"value\":\"MB58756\"}],\"kind\":\"admin#directory#user\",\"name\":{\"familyName\":\"ROSAS RAMIREZ\",\"fullName\":\"PEDRO ROSAS RAMIREZ\",\"givenName\":\"PEDRO\"},\"nonEditableAliases\":[\"[email protected]\"],\"organizations\":[{\"customType\":\"Work\",\"department\":\"CANALES ATENDIDOS\",\"location\":\"018533073307\",\"name\":\"BBVA BANCOMER SERVICIO ADMINIS\",\"primary\":true,\"title\":\"LIDER DE PROYECTO DYD A\"}],\"primaryEmail\":\"[email protected]\",\"suspended\":false,\"status\":\"ACTIVE\",\"ouResponsible\":{\"id\":\"00012899\",\"name\":\"CANALES ATENDIDOS\",\"responsibleEmployeeId\":\"M62139\",\"updateDate\":1450243038394}}}"; ParsearJson parser = new ParsearJson(); empleadoNuevo = parser.ConvertirAUsuario(resultado); System.out.println(resultado); empleadosNuevos.add(empleadoNuevo); } } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return empleadosNuevos; }
public static Feed first100Entries(HttpRequestFactory requestFactory, DocsUrl url) throws IOException { HttpRequest request = requestFactory.buildGetRequest(url); HttpResponse response = requestExecutor.executeNonSensitive(request); return response.parseAs(Feed.class); }
public void executeDelete(CellEntry cellEntry) throws IOException { HttpRequest request = requestFactory.buildDeleteRequest(new GenericUrl(cellEntry.getEditLink())); request.getHeaders().setIfMatch(cellEntry.etag); request.execute().ignore(); }
public HttpResponse execute(SpreadsheetUrl url) throws IOException { HttpRequest request = requestFactory.buildGetRequest(url); return request.execute(); }
<F extends Feed> F executeGetFeed(SpreadsheetUrl url, final Class<F> feedClass) throws IOException { final HttpRequest request = requestFactory.buildGetRequest(url); return request.execute().parseAs(feedClass); }