private void assertToken(JsonToken expected, JsonToken actual) throws MetadataParseException { if(expected != actual) { throw new MetadataParseException("Unable to parse entity metadata, expected token: " + expected + " but got token: " + actual); } }
private void checkClosed() { if(closed) { throw new RuntimeJasDBException("Query cursor is closed"); } }
private void offsetCheck(int offset) throws JasDBStorageException { if(offset >= (DataBlockHeader.HEADER_SIZE - BLOCK_MANDATORY_HEADER)) { throw new JasDBStorageException("Illegal offset for header, offset needs smaller than block header size: " + (DataBlockHeader.HEADER_SIZE - BLOCK_MANDATORY_HEADER)); } }
@Override public UserAdministration getUserAdministration() throws JasDBStorageException { if(userSession != null) { return new LocalUserAdministration(userSession); } else { throw new JasDBSecurityException("Unable to get user administration, not logged in"); } }
@Override public <T extends RestEntity> T deserialize(Class<T> dataType, String data) throws RestException { throw new RestException("Streaming of raw string data not supported"); }
@Override public void removeGrant(String userName) { throw new RuntimeJasDBException("Grant not allowed to be modified"); } }
private void doInstanceCheck() throws JasDBStorageException { if(instance == null) { throw new JasDBStorageException("DB current session has no active instance bound"); } }
@Override public List<?> mapToRawType(Object value) { if(value instanceof List) { return (List<?>) value; } else { throw new RuntimeJasDBException("Invalid type, cannot cast object: " + value + " to a list"); } }
@Override public DBInstance getInstance(String instanceId) throws JasDBStorageException { try { return instanceFactory.getInstance(instanceId); } catch(ConfigurationException e) { throw new JasDBStorageException("Unable to retrieve instance: " + instanceId, e); } }
@Override public Map<String, ?> mapToRawType(Object value) { if(value instanceof Map) { return (Map<String, ?>) value; } else { throw new RuntimeJasDBException("Invalid type, cannot cast object: " + value + " to a map"); } }
public ClonableDataStream getStream() throws JasDBStorageException { try { return stream.clone(); } catch(CloneNotSupportedException e) { throw new JasDBStorageException("Unable to clone datastream", e); } }
@Override public Long mapToRawType(Object value) { if(value instanceof Long) { return (Long)value; } else if(value instanceof Integer) { int v = (Integer) value; return (long) v; } else { throw new RuntimeJasDBException("Unable to map value: " + value); } }
@Override public DataBlock writeKey(Key key, DataBlock dataBlock) throws JasDBStorageException { if(key instanceof CompositeKey) { return multiKeyloader.writeKeys(key, dataBlock); } else { throw new JasDBStorageException("Unable to write key not a composite key"); } }
@Override public Key cloneKey() { throw new RuntimeJasDBException("Not implemented"); }
private void doLeaveBlockUpdate(LeaveBlock leaveBlock, Key key) throws JasDBStorageException { if(leaveBlock.contains(key)) { leaveBlock.updateKey(key); } else { throw new JasDBStorageException("Unable to update key: " + key + " cannot be found in the index"); } }
@Override public Key cloneKey(boolean includeChildren) { throw new RuntimeJasDBException("Not implemented"); }
@Override public void addGrant(Grant grant) { throw new RuntimeJasDBException("Grant not allowed to be modified"); }
@Override public Object getValue() { throw new RuntimeJasDBException("Not implemented"); }
@Override public int compareTo(Key o) { throw new RuntimeJasDBException("Cannot use data key for compare or sorting"); }
public static byte[] getUnicodeBytes(String data) { try { return data.getBytes(DEFAULT_ENCODING); } catch(UnsupportedEncodingException e) { throw new RuntimeJasDBException("Unable to retrieve unicode key, character set invalid", e); } }