use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class IndexingContentManagerDecorator method getTransfer.
@Override
public Transfer getTransfer(final ArtifactStore store, final String path, final TransferOperation op) throws IndyWorkflowException {
Logger logger = LoggerFactory.getLogger(getClass());
Transfer transfer = getIndexedTransfer(store.getKey(), null, path, TransferOperation.DOWNLOAD);
if (transfer != null) {
return transfer;
}
ConcreteResource resource = new ConcreteResource(LocationUtils.toLocation(store), path);
StoreType type = store.getKey().getType();
if (StoreType.group == type) {
if (!nfc.isMissing(resource)) {
logger.debug("No group index hits. Devolving to member store indexes.");
transfer = getIndexedMemberTransfer((Group) store, path, op, (member) -> {
try {
return delegate.getTransfer(member, path, op);
} catch (IndyWorkflowException e) {
logger.error(String.format("Failed to getTransfer() for: %s:%s with operation: %s. Reason: %s", member.getKey(), path, op, e.getMessage()), e);
}
return null;
});
if (transfer != null) {
return transfer;
}
} else {
logger.debug("NFC marks {} as missing. Returning null.", resource);
return null;
}
}
transfer = delegate.getTransfer(store, path, op);
// index the transfer only if it exists, it cannot be null at this point
if (transfer != null && transfer.exists()) {
indexManager.indexTransferIn(transfer, store.getKey());
}
logger.debug("Returning transfer: {}", transfer);
return transfer;
}
use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class ArtifactStoreSubStore method getChildrenNames.
@Override
public String[] getChildrenNames(final ITransaction transaction, final String folderUri) throws WebdavException {
String[] names;
final StoreURIMatcher matcher = new StoreURIMatcher(folderUri);
if (matcher.hasStorePath() || matcher.hasStoreName()) {
String path = matcher.getStorePath();
if (isEmpty(path)) {
path = PathUtils.ROOT;
}
final StoreKey key = matcher.getStoreKey();
try {
if (key != null && StoreType.group == key.getType()) {
final List<ArtifactStore> stores = indy.query().packageType(key.getPackageType()).getOrderedStoresInGroup(key.getName());
final Set<String> noms = new TreeSet<>();
for (final ArtifactStore store : stores) {
final Transfer item = fileManager.getStorageReference(store, path);
if (!item.exists()) {
continue;
}
if (!item.isDirectory()) {
logger.error("Transfer: {} in {} is not a directory.", path, store.getKey());
continue;
}
noms.addAll(Arrays.asList(item.list()));
}
names = noms.toArray(new String[noms.size()]);
} else {
final ArtifactStore store = indy.getArtifactStore(key);
if (store == null) {
logger.error("Cannot find ArtifactStore to match key: {}.", key);
names = new String[] {};
} else {
final Transfer item = fileManager.getStorageReference(store, path);
if (!item.exists() || !item.isDirectory()) {
logger.error("Transfer: {} in {} is not a directory.", path, store.getKey());
names = new String[] {};
} else {
names = item.list();
}
}
}
} catch (final IndyDataException e) {
logger.error(String.format("Failed to lookup ArtifactStore(s) for key: %s. Reason: %s", key, e.getMessage()), e);
throw new WebdavException("Failed to get listing for: " + folderUri);
} catch (final IOException e) {
logger.error(String.format("Failed to list %s in %s. Reason: %s", path, key, e.getMessage()), e);
throw new WebdavException("Failed to get listing for: " + folderUri);
}
} else if (matcher.hasStoreType()) {
String packageType = matcher.getPackageType();
final StoreType type = matcher.getStoreType();
try {
List<String> noms = indy.query().packageType(packageType).storeTypes(type).stream().map(ArtifactStore::getName).collect(Collectors.toList());
names = noms.toArray(new String[noms.size()]);
} catch (final IndyDataException e) {
logger.error(String.format("Failed to lookup ArtifactStores of type: %s. Reason: %s", type, e.getMessage()), e);
throw new WebdavException("Failed to get listing for: " + folderUri);
}
} else {
names = new String[] { StoreType.hosted.singularEndpointName(), StoreType.group.singularEndpointName(), StoreType.remote.singularEndpointName() };
}
return names;
}
use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class SettingsSubStore method getChildrenNames.
@Override
public String[] getChildrenNames(final ITransaction transaction, final String folderUri) throws WebdavException {
final SettingsURIMatcher matcher = new SettingsURIMatcher(folderUri);
final Set<String> names = new TreeSet<String>();
if (matcher.isSettingsRootResource()) {
for (final StoreType type : StoreType.values()) {
names.add(type.singularEndpointName());
}
} else if (matcher.isSettingsTypeResource()) {
final StoreType type = matcher.getStoreType();
List<? extends ArtifactStore> all;
try {
all = indy.query().packageType(MAVEN_PKG_KEY).storeTypes(type).getAll();
} catch (final IndyDataException e) {
logger.error(String.format("Failed to retrieve list of artifact stores: %s", e.getMessage()), e);
throw new WebdavException("Failed to retrieve list of settings configurations.");
}
for (final ArtifactStore store : all) {
final String storeName = formatSettingsResourceName(store.getKey().getType(), store.getName());
// logger.info( "\n\nCreating settings resource for: '{}'\n\n", storeName );
names.add(storeName);
}
}
return names.toArray(new String[names.size()]);
}
use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class SettingsURIMatcher method getStoreKey.
/* (non-Javadoc)
* @see org.commonjava.indy.dotmaven.util.URIMatcher#getStoreKey()
*/
@Override
public StoreKey getStoreKey() {
final StoreType type = getStoreType();
if (type == null) {
return null;
}
final String name = matcher.group(NAME_GRP);
if (isEmpty(name)) {
return null;
}
return new StoreKey(type, name);
}
use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class StoreURIMatcher method getStoreKey.
@Override
public StoreKey getStoreKey() {
if (!matches()) {
return null;
}
if (!hasStoreName()) {
return null;
}
final String packageType = getPackageType();
if (packageType == null) {
return null;
}
final StoreType type = getStoreType();
if (type == null) {
return null;
}
String name = getStoreName();
if (name == null) {
return null;
}
return new StoreKey(packageType, type, name);
}
Aggregations