private void store( final boolean skipIfExists, final ChangeSummary summary, final ArtifactStore... stores )
throws IndyDataException
{
for ( final ArtifactStore store : stores )
{
final DataFile f =
manager.getDataFile( INDY_STORE, store.getPackageType(), store.getType().singularEndpointName(),
store.getName() + ".json" );
if ( skipIfExists && f.exists() )
{
continue;
}
final DataFile d = f.getParent();
if ( !d.mkdirs() )
{
throw new IndyDataException( "Cannot create storage directory: {} for definition: {}", d, store );
}
try
{
final String json = serializer.writeValueAsString( store );
f.writeString( json, "UTF-8", summary );
logger.debug( "Persisted {} to disk at: {}\n{}", store, f, json );
}
catch ( final IOException e )
{
throw new IndyDataException( "Cannot write definition: {} to: {}. Reason: {}", e, store, f,
e.getMessage() );
}
}
}