/** * Get the current value. * * @return the current value. */ public long get() { Long value = operations.get(key); if (value != null) { return value; } throw new DataRetrievalFailureException(String.format("The key '%s' seems to no longer exist.", key)); }
@Override @Nullable public Number getKey() throws InvalidDataAccessApiUsageException, DataRetrievalFailureException { if (this.keyList.isEmpty()) { return null; } if (this.keyList.size() > 1 || this.keyList.get(0).size() > 1) { throw new InvalidDataAccessApiUsageException( "The getKey method should only be used when a single key is returned. " + "The current key entry contains multiple keys: " + this.keyList); } Iterator<Object> keyIter = this.keyList.get(0).values().iterator(); if (keyIter.hasNext()) { Object key = keyIter.next(); if (!(key instanceof Number)) { throw new DataRetrievalFailureException( "The generated key is not of a supported numeric type. " + "Unable to cast [" + (key != null ? key.getClass().getName() : null) + "] to [" + Number.class.getName() + "]"); } return (Number) key; } else { throw new DataRetrievalFailureException("Unable to retrieve the generated key. " + "Check that the table has an identity column enabled."); } }
/** * Get the current value. * * @return the current value. */ public double get() { Double value = operations.get(key); if (value != null) { return value; } throw new DataRetrievalFailureException(String.format("The key '%s' seems to no longer exist.", key)); }
/** * Get the current value. * * @return the current value. */ public int get() { Integer value = operations.get(key); if (value != null) { return value; } throw new DataRetrievalFailureException(String.format("The key '%s' seems to no longer exist.", key)); }
@Override protected final Record createInputRecord(RecordFactory recordFactory, Object inObject) { try { return new CommAreaRecord(objectToBytes(inObject)); } catch (IOException ex) { throw new DataRetrievalFailureException("I/O exception during bytes conversion", ex); } }
public UserDetails loadUserByUsername(String username) { throw new DataRetrievalFailureException( "This mock simulator is designed to fail"); } }
@Override protected final Object extractOutputData(Record record) throws DataAccessException { CommAreaRecord commAreaRecord = (CommAreaRecord) record; try { return bytesToObject(commAreaRecord.toByteArray()); } catch (IOException ex) { throw new DataRetrievalFailureException("I/O exception during bytes conversion", ex); } }
@Override public Pipeline get() { Pipeline pipeline = (Pipeline) getSqlMapClientTemplate().queryForObject("getPipelineByBuildId", buildId); if (pipeline == null) { throw new DataRetrievalFailureException("Could not load pipeline from build with id " + buildId); } return loadMaterialRevisions(pipeline); } });
public Stage getStageByBuild(long buildId) { Stage stage = (Stage) getSqlMapClientTemplate().queryForObject("getStageByBuildId", buildId); if (stage == null) { throw new DataRetrievalFailureException("Unable to load related stage data for buildId " + buildId); } return stage; }
public Pipeline pipelineWithMaterialsAndModsByBuildId(long buildId) { String cacheKey = this.cacheKeyGenerator.generate("getPipelineByBuildId", buildId); return pipelineByBuildIdCache.get(cacheKey, new Supplier<Pipeline>() { @Override public Pipeline get() { Pipeline pipeline = (Pipeline) getSqlMapClientTemplate().queryForObject("getPipelineByBuildId", buildId); if (pipeline == null) { throw new DataRetrievalFailureException("Could not load pipeline from build with id " + buildId); } return loadMaterialRevisions(pipeline); } }); }
private JobInstance job(long buildId, String queryName) { JobInstance instance = (JobInstance) getSqlMapClientTemplate().queryForObject(queryName, buildId); if (instance == null) { throw new DataRetrievalFailureException("Could not load build with id " + buildId); } if (instance.getIdentifier() == null) { throw new RuntimeException("Identifier must not be null!"); } return instance; }
@Override protected final Record createInputRecord(RecordFactory recordFactory, Object inObject) { try { return new CommAreaRecord(objectToBytes(inObject)); } catch (IOException ex) { throw new DataRetrievalFailureException("I/O exception during bytes conversion", ex); } }
@Override protected final Object extractOutputData(Record record) throws DataAccessException { CommAreaRecord commAreaRecord = (CommAreaRecord) record; try { return bytesToObject(commAreaRecord.toByteArray()); } catch (IOException ex) { throw new DataRetrievalFailureException("I/O exception during bytes conversion", ex); } }
throw new DataRetrievalFailureException( "Unable to map column '" + column + "' to property '" + pd.getName() + "'", ex);
@Override public Object extractPrincipal(X509Certificate cert) { try { Element element = cache.get(cert); if (element != null) { return element.getObjectValue(); } } catch (CacheException cacheException) { throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage()); } final Object principal = delegate.extractPrincipal(cert); cache.put(new Element(cert, principal)); return principal; } }
@Nullable @Override public byte[] convert(@Nullable Blob source) { if (source == null) { return null; } InputStream blobStream = null; try { blobStream = source.getBinaryStream(); if (blobStream != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); StreamUtils.copy(blobStream, baos); return baos.toByteArray(); } } catch (SQLException | IOException e) { throw new DataRetrievalFailureException("Couldn't retrieve data from blob.", e); } finally { if (blobStream != null) { try { blobStream.close(); } catch (IOException e) { throw new CleanupFailureDataAccessException("Couldn't close binary stream for given blob.", e); } } } return null; } }
public Pipeline pipelineByIdWithMods(long pipelineId) { Pipeline pipeline = (Pipeline) getSqlMapClientTemplate().queryForObject("pipelineById", pipelineId); if (pipeline == null) { throw new DataRetrievalFailureException("Could not load pipeline with id " + pipelineId); } return loadMaterialRevisions(pipeline); }
/** * Decodes the Ber encoded control data. The ASN.1 value of the control data is: * * <pre> * PasswordPolicyResponseValue ::= SEQUENCE { warning [0] CHOICE { * timeBeforeExpiration [0] INTEGER (0 .. maxInt), * graceAuthNsRemaining [1] INTEGER (0 .. maxInt) } OPTIONAL, error [1] ENUMERATED { * passwordExpired (0), accountLocked (1), * changeAfterReset (2), passwordModNotAllowed (3), * mustSupplyOldPassword (4), insufficientPasswordQuality (5), * passwordTooShort (6), passwordTooYoung (7), * passwordInHistory (8) } OPTIONAL } * </pre> * */ public PasswordPolicyResponseControl(byte[] encodedValue) { this.encodedValue = encodedValue; // PPolicyDecoder decoder = new JLdapDecoder(); PPolicyDecoder decoder = new NetscapeDecoder(); try { decoder.decode(); } catch (IOException e) { throw new DataRetrievalFailureException("Failed to parse control value", e); } }
@Override public Void doInTransaction(TransactionStatus status) { assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(connectionFactory)); CciTemplate ct = new CciTemplate(connectionFactory); ct.execute(interactionSpec, record, record); throw new DataRetrievalFailureException("error"); } });
public Stage stageById(long id) { String key = cacheKeyForStageById(id); Stage stage = (Stage) goCache.get(key); if (stage == null) { synchronized (key) { stage = (Stage) goCache.get(key); if (stage == null) { stage = (Stage) getSqlMapClientTemplate().queryForObject("getStageById", id); if (stage == null) { throw new DataRetrievalFailureException("Unable to load related stage data for id " + id); } goCache.put(key, stage); } } } return cloner.deepClone(stage); }