/** * Decodes data from Base64 notation, automatically detecting gzip-compressed data and * decompressing it. * * @param s the string to decode * @return the decoded data * @since 1.4 */ public static byte[] decode(String s) { byte[] bytes; try { bytes = s.getBytes(PREFERRED_ENCODING); } catch (java.io.UnsupportedEncodingException uee) { bytes = s.getBytes(); } // </change> // Decode bytes = decode(bytes, 0, bytes.length); return bytes; } // end decode
/** * Decodes data from Base64 notation, automatically * detecting gzip-compressed data and decompressing it. * * @param s the string to decode * @return the decoded data * @since 1.4 */ public static byte[] decode( String s ) { byte[] bytes; try { bytes = s.getBytes( PREFERRED_ENCODING ); } // end try catch( java.io.UnsupportedEncodingException uee ) { bytes = s.getBytes(); } // end catch //</change> // Decode bytes = decode( bytes, 0, bytes.length ); return bytes; } // end decode
/** * @return recovered xid, or null if s does not represent a valid xid encoded by the driver. */ static Xid stringToXid(String s) { RecoveredXid xid = new RecoveredXid(); int a = s.indexOf("_"); int b = s.lastIndexOf("_"); if (a == b) { // this also catches the case a == b == -1. return null; } try { xid.formatId = Integer.parseInt(s.substring(0, a)); xid.globalTransactionId = Base64.decode(s.substring(a + 1, b)); xid.branchQualifier = Base64.decode(s.substring(b + 1)); if (xid.globalTransactionId == null || xid.branchQualifier == null) { return null; } } catch (Exception ex) { return null; // Doesn't seem to be an xid generated by this driver. } return xid; } }
/** * Decodes data from Base64 notation, automatically * detecting gzip-compressed data and decompressing it. * * @param s the string to decode * @return the decoded data * @since 1.4 */ public static byte[] decode( String s ) { byte[] bytes; try { bytes = s.getBytes( PREFERRED_ENCODING ); } // end try catch( java.io.UnsupportedEncodingException uee ) { bytes = s.getBytes(); } // end catch //</change> // Decode bytes = decode( bytes, 0, bytes.length ); return bytes; } // end decode
/** * Decodes data from Base64 notation, automatically * detecting gzip-compressed data and decompressing it. * * @param s the string to decode * @return the decoded data * @since 1.4 */ public static byte[] decode( String s ) { byte[] bytes; try { bytes = s.getBytes( PREFERRED_ENCODING ); } // end try catch( java.io.UnsupportedEncodingException uee ) { bytes = s.getBytes(); } // end catch //</change> // Decode bytes = decode( bytes, 0, bytes.length ); return bytes; } // end decode
/** * Create or update a project's landing page registration. * * @param entry landing's data * @return */ @POST @javax.ws.rs.Path("/{orgName}/landing_page") @ApiOperation("Create or update a project's landing page registration") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public CreateLandingResponse createOrUpdate(@ApiParam @PathParam("orgName") @ConcordKey String orgName, @ApiParam @Valid LandingEntry entry) { OrganizationEntry org = orgManager.assertAccess(orgName, true); ProjectEntry project = assertProject(org.getId(), entry.getProjectName(), ResourceAccessLevel.WRITER, true); RepositoryEntry repository = assertRepository(project, entry.getRepositoryName()); byte[] icon = null; if (entry.getIcon() != null) { icon = Base64.decode(entry.getIcon()); } if (entry.getId() != null) { landingDao.update(entry.getId(), project.getId(), repository.getId(), entry.getName(), entry.getDescription(), icon); return new CreateLandingResponse(OperationResult.UPDATED, entry.getId()); } else { UUID landingId = landingDao.insert(project.getId(), repository.getId(), entry.getName(), entry.getDescription(), icon); return new CreateLandingResponse(OperationResult.CREATED, landingId); } }
private void refresh(RepositoryEntry r) { LandingEntry le = repositoryManager.withLock(r.getUrl(), () -> { Path lpMetaFile = repositoryManager.fetch(r.getProjectId(), r).path() .resolve(LP_META_FILE_NAME); return loadEntry(lpMetaFile); }); tx(tx -> { landingDao.delete(tx, r.getProjectId(), r.getId()); if (le != null) { byte[] icon = le.getIcon() != null ? Base64.decode(le.getIcon()) : null; landingDao.insert(tx, r.getProjectId(), r.getId(), le.getName(), le.getDescription(), icon); } }); log.info("refresh ['{}'] -> done", r.getId()); }