@Override public Serialiser<Object, byte[]> getSerialisation() { MultiSerialiser multiSerialiser; try { multiSerialiser = JSONSerialiser.deserialise(StreamUtil.openStream(getClass(), path), MultiSerialiser.class); } catch (SerialisationException e) { throw new RuntimeException(e); } return multiSerialiser; }
@Test public void shouldMatchHistoricalSerialisation() throws IOException, GafferCheckedException { final String fromDisk = IOUtils.readLines(StreamUtil.openStream(getClass(), path)) .stream() .collect(Collectors.joining("\n")); final MultiSerialiser multiSerialiser = new MultiSerialiser() .addSerialiser((byte) 0, new StringSerialiser(), String.class) .addSerialiser((byte) 1, new CompactRawLongSerialiser(), Long.class) .addSerialiser((byte) 2, new CompactRawIntegerSerialiser(), Integer.class); final String fromCode = new String(JSONSerialiser.serialise(multiSerialiser, true)); assertEquals(fromDisk, fromCode); }
/** * Open the elements schema file located at the same location as the provided * class. * * @param clazz the class determining the location of the elements schema file * @return an {@link InputStream} representing the elements schema file */ public static InputStream elementsSchema(final Class clazz) { return openStream(clazz, ELEMENTS_SCHEMA); }
/** * Open the schema file located at the same location as the provided * class. * * @param clazz the class determining the location of the schema file * @return an {@link InputStream} representing the schema file */ public static InputStream schema(final Class clazz) { return openStream(clazz, SCHEMA); }
/** * Open the view file located at the same location as the provided class. * * @param clazz the class determining the location of the view file * @return an {@link InputStream} representing the view file */ public static InputStream view(final Class clazz) { return openStream(clazz, VIEW); }
/** * Open the store properties file located at the same location as the provided * class. * * @param clazz the class determining the location of the store properties file * @return an {@link InputStream} representing the store properties file */ public static InputStream storeProps(final Class clazz) { return openStream(clazz, STORE_PROPERTIES); }
/** * Open the graph config file located at the same location as the provided * class. * * @param clazz the class determining the location of the graph config file * @return an {@link InputStream} representing the graph config file */ public static InputStream graphConfig(final Class clazz) { return openStream(clazz, GRAPH_CONFIG); }
/** * Open the types schema file located at the same location as the provided * class. * * @param clazz the class determining the location of the types schema file * @return an {@link InputStream} representing the types schema file */ public static InputStream typesSchema(final Class clazz) { return openStream(clazz, TYPES_SCHEMA); }
protected InputStream getStoreProperties() { return StreamUtil.openStream(LoadAndQuery.class, storePropertiesLocation, true); } }
protected InputStream getData() { return StreamUtil.openStream(LoadAndQuery.class, dataFileLocation, true); }
private static String getResource(final String resourcePath, final Class<?> clazz) { final String resource; try (final InputStream stream = StreamUtil.openStream(clazz, resourcePath)) { if (null == stream) { resource = ""; } else { resource = new String(IOUtils.toByteArray(stream), CommonConstants.UTF_8); } } catch (final IOException e) { throw new RuntimeException(e); } return resource; }
public static String getResource(final String resourcePath, final Class<?> clazz) { final String resource; try (final InputStream stream = StreamUtil.openStream(clazz, resourcePath)) { if (null == stream) { throw new IllegalArgumentException("Resource was not found: " + resourcePath); } else { resource = new String(IOUtils.toByteArray(stream), CommonConstants.UTF_8); } } catch (final IOException e) { throw new RuntimeException(e); } return resource; }
private void printIntro() { final String intro; try (final InputStream stream = StreamUtil.openStream(getClass(), resourcePrefix + "/walkthrough/Intro.md")) { intro = new String(IOUtils.toByteArray(stream), CommonConstants.UTF_8); } catch (final IOException e) { throw new RuntimeException(e); } System.out.println(WalkthroughStrSubstitutor.substitute(intro, modulePath)); }
public Builder json(final URI uri) { try { json(null != uri ? StreamUtil.openStream(uri) : null); } catch (final IOException e) { throw new IllegalArgumentException("Unable to read graph config from uri: " + uri, e); } return this; }
private void printIntro() { final String intro; try (final InputStream stream = StreamUtil.openStream(getClass(), "/example/gettingstarted/intro.md")) { intro = new String(IOUtils.toByteArray(stream), CommonConstants.UTF_8); } catch (final IOException e) { throw new RuntimeException(e); } LOGGER.info(WalkthroughStrSubstitutor.substitute(intro)); }
public String walkthrough() throws OperationException { cacheLogs = true; final String walkthrough; try (final InputStream stream = StreamUtil.openStream(getClass(), resourcePrefix + "/walkthrough/" + exampleId + ".md")) { if (null == stream) { throw new RuntimeException("Missing walkthrough file"); } walkthrough = new String(IOUtils.toByteArray(stream), CommonConstants.UTF_8); } catch (final IOException e) { throw new RuntimeException(e); } final String formattedWalkthrough = substituteParameters(walkthrough); cacheLogs = false; return formattedWalkthrough; }
public Builder storeProperties(final URI propertiesURI) { if (null != propertiesURI) { try { storeProperties(StreamUtil.openStream(propertiesURI)); } catch (final IOException e) { throw new SchemaException("Unable to read storeProperties from URI: " + propertiesURI, e); } } return this; }
public Builder addSchema(final URI schemaURI) { if (null != schemaURI) { try { addSchema(StreamUtil.openStream(schemaURI)); } catch (final IOException e) { throw new SchemaException(UNABLE_TO_READ_SCHEMA_FROM_URI, e); } } return this; }
public Builder view(final URI view) { try { view(null != view ? StreamUtil.openStream(view) : null); } catch (final IOException e) { throw new SchemaException("Unable to read view from URI: " + view, e); } return this; }
public Builder addStoreProperties(final URI updatePropertiesURI) { if (null != updatePropertiesURI) { try { addStoreProperties(StreamUtil.openStream(updatePropertiesURI)); } catch (final IOException e) { throw new SchemaException("Unable to read storeProperties from URI: " + updatePropertiesURI, e); } } return this; }