use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class InfinispanStoreDataMigrationAction method loadFromDiskAnd.
/**
* Copy from DataFileStoreUtils. This is one-off action.
*/
private void loadFromDiskAnd(DataFileManager manager, IndyObjectMapper serializer, final ChangeSummary summary, Consumer<ArtifactStore> consumer) {
DataFile[] packageDirs = manager.getDataFile(INDY_STORE).listFiles((f) -> true);
for (DataFile pkgDir : packageDirs) {
for (StoreType type : StoreType.values()) {
DataFile[] files = pkgDir.getChild(type.singularEndpointName()).listFiles(f -> true);
if (files != null) {
for (final DataFile f : files) {
try {
final String json = f.readString();
final ArtifactStore store = serializer.readValue(json, type.getStoreClass());
if (store == null) {
f.delete(summary);
} else {
consumer.accept(store);
}
} catch (final IOException e) {
logger.error(String.format("Failed to load %s store: %s. Reason: %s", type, f, e.getMessage()), e);
try {
f.delete(summary);
} catch (IOException e1) {
logger.error("Failed to delete invalid store definition file: " + f, e);
}
}
}
}
}
}
}
use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class InfinispanStoreDataManager method removeArtifactStoreInternal.
@Override
protected synchronized ArtifactStore removeArtifactStoreInternal(StoreKey key) {
final ArtifactStore store = stores.remove(key);
final Map<StoreType, Set<StoreKey>> typedKeys = storesByPkg.get(key.getPackageType());
if (typedKeys != null) {
final Set<StoreKey> keys = typedKeys.get(key.getType());
if (keys != null) {
keys.remove(key);
}
}
return store;
}
use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class InfinispanStoreDataManager method putArtifactStoreInternal.
@Override
protected synchronized ArtifactStore putArtifactStoreInternal(StoreKey storeKey, ArtifactStore store) {
final ArtifactStore added = stores.put(storeKey, store);
final Map<StoreType, Set<StoreKey>> typedKeys = storesByPkg.computeIfAbsent(storeKey.getPackageType(), k -> new HashMap<>());
final Set<StoreKey> keys = typedKeys.computeIfAbsent(storeKey.getType(), k -> new HashSet<>());
keys.add(storeKey);
return added;
}
Aggregations