use of org.commonjava.indy.data.IndyDataException in project indy by Commonjava.
the class IndexingContentManagerDecorator method store.
// @Override
// public Transfer store( final List<? extends ArtifactStore> stores, final String path, final InputStream stream, final TransferOperation op )
// throws IndyWorkflowException
// {
// return store( stores, path, stream, op, new EventMetadata() );
// }
@Override
public Transfer store(final List<? extends ArtifactStore> stores, final StoreKey topKey, final String path, final InputStream stream, final TransferOperation op, final EventMetadata eventMetadata) throws IndyWorkflowException {
Transfer transfer = delegate.store(stores, topKey, path, stream, op, eventMetadata);
if (transfer != null) {
indexManager.indexTransferIn(transfer, topKey);
try {
ArtifactStore topStore = storeDataManager.getArtifactStore(topKey);
nfc.clearMissing(new ConcreteResource(LocationUtils.toLocation(topStore), path));
} catch (IndyDataException e) {
Logger logger = LoggerFactory.getLogger(getClass());
logger.error(String.format("Failed to retrieve top store: %s for NFC management. Reason: %s", topKey, e.getMessage()), e);
}
}
return transfer;
}
use of org.commonjava.indy.data.IndyDataException in project indy by Commonjava.
the class IndexingContentManagerDecorator method getIndexedTransfer.
private Transfer getIndexedTransfer(final StoreKey storeKey, final StoreKey topKey, final String path, final TransferOperation op) throws IndyWorkflowException {
Logger logger = LoggerFactory.getLogger(getClass());
logger.trace("Looking for indexed path: {} in: {} (entry point: {})", path, storeKey, topKey);
try {
ArtifactStore store = storeDataManager.getArtifactStore(storeKey);
if (store.isDisabled()) {
logger.info("Content not available in index caching layer due to store disabled for {} in group {}", storeKey, topKey);
return null;
}
} catch (IndyDataException e) {
logger.error(String.format("Failed to lookup store: %s (in membership of: %s). Reason: %s", storeKey, topKey, e.getMessage()), e);
//TODO: Need further check if it is suitable to throw a IndyWorkflowException here.
return null;
}
IndexedStorePath storePath = indexManager.getIndexedStorePath(storeKey, path);
if (storePath != null) {
Transfer transfer = delegate.getTransfer(storeKey, path, op);
if (transfer == null || !transfer.exists()) {
logger.trace("Found obsolete index entry: {}. De-indexing from: {} and {}", storeKey, topKey);
// something happened to the underlying Transfer...de-index it, and don't return it.
indexManager.deIndexStorePath(storeKey, path);
if (topKey != null) {
indexManager.deIndexStorePath(topKey, path);
}
} else {
logger.trace("Found it!");
return transfer;
}
}
return null;
}
use of org.commonjava.indy.data.IndyDataException in project indy by Commonjava.
the class DataFileStoreDataManager method readDefinitions.
@PostConstruct
public void readDefinitions() {
final ChangeSummary summary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "Reading definitions from disk, culling invalid definition files.");
try {
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 {
storeArtifactStore(store, summary, false, false, new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, LOAD_FROM_DISK));
}
} catch (final IOException e) {
logger.error(String.format("Failed to load %s store: %s. Reason: %s", type, f, e.getMessage()), e);
}
}
}
}
}
started = true;
} catch (final IndyDataException e) {
throw new IllegalStateException("Failed to start store data manager: " + e.getMessage(), e);
}
}
use of org.commonjava.indy.data.IndyDataException in project indy by Commonjava.
the class DataFileStoreDataManager method clear.
@Override
public void clear(final ChangeSummary summary) throws IndyDataException {
super.clear(summary);
final DataFile basedir = manager.getDataFile(INDY_STORE);
try {
basedir.delete(summary);
} catch (final IOException e) {
throw new IndyDataException("Failed to delete Indy storage files: {}", e, e.getMessage());
}
}
use of org.commonjava.indy.data.IndyDataException in project indy by Commonjava.
the class MemoryArtifactStoreQuery method getGroupOrdering.
private List<ArtifactStore> getGroupOrdering(final String groupName, final Map<StoreKey, ArtifactStore> stores, final boolean includeGroups, final boolean recurseGroups) throws IndyDataException {
if (packageType == null) {
throw new IndyDataException("packageType must be set on the query before calling this method!");
}
final Group master = (Group) stores.get(new StoreKey(packageType, StoreType.group, groupName));
if (master == null) {
return Collections.emptyList();
}
final List<ArtifactStore> result = new ArrayList<>();
recurseGroup(master, stores, result, new HashSet<>(), includeGroups, recurseGroups);
return result;
}
Aggregations