Search in sources :

Example 1 with SettingsURIMatcher

use of org.commonjava.indy.dotmaven.util.SettingsURIMatcher 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()]);
}
Also used : StoreType(org.commonjava.indy.model.core.StoreType) IndyDataException(org.commonjava.indy.data.IndyDataException) SettingsURIMatcher(org.commonjava.indy.dotmaven.util.SettingsURIMatcher) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) TreeSet(java.util.TreeSet) WebdavException(net.sf.webdav.exceptions.WebdavException) List(java.util.List)

Example 2 with SettingsURIMatcher

use of org.commonjava.indy.dotmaven.util.SettingsURIMatcher in project indy by Commonjava.

the class SettingsSubStore method getStoredObject.

@Override
public StoredObject getStoredObject(final ITransaction transaction, final String uri) throws WebdavException {
    final StoredObject so = new StoredObject();
    final Date d = new Date();
    so.setCreationDate(d);
    so.setLastModified(d);
    final SettingsURIMatcher matcher = new SettingsURIMatcher(uri);
    if (matcher.isSettingsFileResource()) {
        so.setFolder(false);
        final SettingsTemplate st = getSettingsTemplate(matcher);
        so.setResourceLength(st.getLength());
    } else {
        so.setFolder(true);
    }
    return so;
}
Also used : SettingsURIMatcher(org.commonjava.indy.dotmaven.util.SettingsURIMatcher) StoredObject(net.sf.webdav.StoredObject) SettingsTemplate(org.commonjava.indy.dotmaven.util.SettingsTemplate) Date(java.util.Date)

Aggregations

SettingsURIMatcher (org.commonjava.indy.dotmaven.util.SettingsURIMatcher)2 Date (java.util.Date)1 List (java.util.List)1 TreeSet (java.util.TreeSet)1 StoredObject (net.sf.webdav.StoredObject)1 WebdavException (net.sf.webdav.exceptions.WebdavException)1 IndyDataException (org.commonjava.indy.data.IndyDataException)1 SettingsTemplate (org.commonjava.indy.dotmaven.util.SettingsTemplate)1 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)1 StoreType (org.commonjava.indy.model.core.StoreType)1