use of org.commonjava.indy.action.IndyLifecycleException in project indy by Commonjava.
the class FoloLifecycleParticipant method start.
@Override
public void start() throws IndyLifecycleException {
try {
final DataFile dataFile = dataFileManager.getDataFile(".gitignore");
final List<String> lines = dataFile.exists() ? dataFile.readLines() : new ArrayList<String>();
if (!lines.contains(FOLO_DIRECTORY_IGNORE)) {
lines.add(FOLO_DIRECTORY_IGNORE);
dataFile.writeLines(lines, new ChangeSummary(ChangeSummary.SYSTEM_USER, "Adding artimon to ignored list."));
}
} catch (final IOException e) {
throw new IndyLifecycleException("Failed while attempting to access .gitignore for data directory (trying to add artimon dir to ignores list).", e);
}
}
use of org.commonjava.indy.action.IndyLifecycleException in project indy by Commonjava.
the class ImpliedReposOriginMigrationAction method migrate.
@Override
public boolean migrate() throws IndyLifecycleException {
List<RemoteRepository> remoteRepositories;
try {
remoteRepositories = storeDataManager.query().getAllRemoteRepositories();
} catch (IndyDataException e) {
throw new IndyLifecycleException("Cannot retrieve all remote repositories. Reason: %s", e, e.getMessage());
}
List<RemoteRepository> toStore = new ArrayList<>();
remoteRepositories.forEach((repo) -> {
if (repo.getName().startsWith("i-")) {
repo.setMetadata(METADATA_ORIGIN, IMPLIED_REPO_ORIGIN);
toStore.add(repo);
}
});
for (RemoteRepository repo : toStore) {
try {
storeDataManager.storeArtifactStore(repo, new ChangeSummary(ChangeSummary.SYSTEM_USER, "Adding implied-repository origin metadata"), false, true, new EventMetadata());
} catch (IndyDataException e) {
throw new IndyLifecycleException("Failed to store %s with implied-repos origin metadata. Reason: %s", e, repo == null ? "NULL REPO" : repo.getKey(), e.getMessage());
}
}
return !toStore.isEmpty();
}
use of org.commonjava.indy.action.IndyLifecycleException in project indy by Commonjava.
the class HttpProxy method start.
@Override
public void start() throws IndyLifecycleException {
if (!config.isEnabled()) {
logger.info("HTTProx proxy is disabled.");
return;
}
String bind;
if (bootOptions.getBind() == null) {
bind = "0.0.0.0";
} else {
bind = bootOptions.getBind();
}
logger.info("Starting HTTProx proxy on: {}:{}", bind, config.getPort());
XnioWorker worker;
try {
worker = Xnio.getInstance().createWorker(OptionMap.EMPTY);
final InetSocketAddress addr;
if (config.getPort() < 1) {
ThreadLocal<InetSocketAddress> using = new ThreadLocal<>();
ThreadLocal<IOException> errorHolder = new ThreadLocal<>();
server = PortFinder.findPortFor(16, (foundPort) -> {
InetSocketAddress a = new InetSocketAddress(bind, config.getPort());
AcceptingChannel<StreamConnection> result = worker.createStreamConnectionServer(a, acceptHandler, OptionMap.EMPTY);
result.resumeAccepts();
using.set(a);
return result;
});
addr = using.get();
config.setPort(addr.getPort());
} else {
addr = new InetSocketAddress(bind, config.getPort());
server = worker.createStreamConnectionServer(addr, acceptHandler, OptionMap.EMPTY);
server.resumeAccepts();
}
logger.info("HTTProxy listening on: {}", addr);
} catch (IllegalArgumentException | IOException e) {
throw new IndyLifecycleException("Failed to start HTTProx general content proxy: %s", e, e.getMessage());
}
}
use of org.commonjava.indy.action.IndyLifecycleException in project indy by Commonjava.
the class HttProxOriginMigrationAction method migrate.
@Override
public boolean migrate() throws IndyLifecycleException {
List<RemoteRepository> repos;
try {
repos = storeDataManager.query().noPackageType().getAllRemoteRepositories();
} catch (IndyDataException e) {
throw new IndyLifecycleException("Cannot retrieve all remote repositories. Reason: %s", e, e.getMessage());
}
List<RemoteRepository> toStore = new ArrayList<>();
repos.forEach((repo) -> {
if (repo.getDescription() != null && repo.getDescription().contains("HTTProx proxy")) {
repo.setMetadata(ArtifactStore.METADATA_ORIGIN, ProxyAcceptHandler.HTTPROX_ORIGIN);
RemoteRepository store = repo.copyOf(GENERIC_PKG_KEY, repo.getName());
toStore.add(store);
}
});
final ChangeSummary changeSummary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "Adding HttProx origin metadata");
for (RemoteRepository repo : toStore) {
try {
storeDataManager.storeArtifactStore(repo, changeSummary, false, true, new EventMetadata());
} catch (IndyDataException e) {
throw new IndyLifecycleException("Failed to store %s with HttProx origin metadata. Reason: %s", e, repo == null ? "NULL REPO" : repo.getKey(), e.getMessage());
}
}
return !toStore.isEmpty();
}
use of org.commonjava.indy.action.IndyLifecycleException in project indy by Commonjava.
the class KojiOriginMigrationAction method migrate.
@Override
public boolean migrate() throws IndyLifecycleException {
List<RemoteRepository> repos;
try {
repos = storeDataManager.query().noPackageType().getAllRemoteRepositories();
} catch (IndyDataException e) {
throw new IndyLifecycleException("Cannot retrieve all remote repositories. Reason: %s", e, e.getMessage());
}
List<RemoteRepository> toStore = new ArrayList<>();
repos.forEach((repo) -> {
if (repo.getDescription() != null && repo.getDescription().contains("Koji build")) {
repo.setMetadata(METADATA_ORIGIN, KOJI_ORIGIN);
toStore.add(repo);
}
});
final ChangeSummary changeSummary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "Adding Koji origin metadata");
for (RemoteRepository repo : toStore) {
try {
storeDataManager.storeArtifactStore(repo, changeSummary, false, true, new EventMetadata());
} catch (IndyDataException e) {
throw new IndyLifecycleException("Failed to store %s with Koji origin metadata. Reason: %s", e, repo == null ? "NULL REPO" : repo.getKey(), e.getMessage());
}
}
return !toStore.isEmpty();
}
Aggregations