use of org.apache.archiva.maven2.model.Artifact in project assembly64fx by freabemania.
the class InstallationService method addToLatestInstalled.
public void addToLatestInstalled(LocationAndInstallationStatus location, Artifact entry) {
Set<LatestInstalledItemInfo> latestItems = resolveLatestInstalledByLocation(location);
Optional<LatestInstalledItemInfo> foundItem = latestItems.stream().filter(item -> item.getId().equals(entry.getName())).findFirst();
LatestInstalledItemInfo updatedItem = LatestInstalledItemInfo.builder().id(entry.getName()).date(getTodayDateAsBasicIsoString()).build();
if (foundItem.isPresent()) {
latestItems.remove(foundItem.get());
}
latestItems.add(updatedItem);
flush(latestItems, resolvedLatestInstallationsFile(location));
}
use of org.apache.archiva.maven2.model.Artifact in project assembly64fx by freabemania.
the class InstallationService method housekeep.
public void housekeep(File base) {
GenericMessageDialogController.withInfoProps("Scan was started", "Scanning " + base.getAbsolutePath()).show();
ReturningTask<Void> task = () -> {
final AtomicInteger emptyDirs = new AtomicInteger();
final AtomicInteger emptyFiles = new AtomicInteger();
for (Artifact entry : artifactsService.getArtifactsDb()) {
if (artifactsService.isInstalled(base, entry)) {
boolean emptyDirFound = true;
while (emptyDirFound) {
emptyDirFound = false;
for (File f : FileUtils.listFilesAndDirs(LocalStorageUtil.getSubdirOrFile(base, entry), TrueFileFilter.TRUE, TrueFileFilter.TRUE)) {
if (!f.isDirectory()) {
if (f.length() == 0) {
emptyFiles.incrementAndGet();
FileUtils.deleteQuietly(f);
emptyDirFound = true;
}
} else {
if (f.list().length == 0 || f.getName().toUpperCase().equals("__MACOSX")) {
emptyDirs.incrementAndGet();
FileUtils.deleteQuietly(f);
emptyDirFound = true;
}
}
}
}
}
}
GenericMessageDialogController.withInfoProps("Housekeeping finished", "Removed " + emptyFiles.get() + " empty files and " + emptyDirs.get() + " dirs", true).showAndWait();
return null;
};
ExecutorUtil.executeAsyncWithRetry(task, 3);
}
use of org.apache.archiva.maven2.model.Artifact in project assembly64fx by freabemania.
the class InstallationService method installDelta.
private void installDelta(LocationAndInstallationStatus location, Artifact entry) throws Exception {
LOGGER.info("Updating " + entry.getName());
if (entry.isCreateDelta()) {
Integer latestUpdated = getVersionAsInteger(artifactsService.getLatestVersion(artifactsService.resolveDB(location, entry)));
List<ArtifactDelta> entries = entry.getDeltas().stream().filter(item -> {
return getVersionAsInteger(item.getVersion()) > latestUpdated;
}).collect(Collectors.toList());
CancelableTask cancelTask = CancelableTask.of();
for (ArtifactDelta e : entries) {
if (cancelTask.isRunning()) {
if (entry.isDynamicImport()) {
File file = installEntry(location, entry, entry.getBaseDir() + "/delta", e.getFile(), e.getVersion(), true, true);
unpackDynamic(file, location, entry, e);
if (!cancelTask.isCancelled()) {
updateDb(location, entry, e.getVersion());
} else {
break;
}
} else {
installEntry(location, entry, entry.getBaseDir() + "/delta", e.getFile(), e.getVersion());
}
} else {
ProgressControlWrapper.getInstance().setProgressLabel("Cancelling");
return;
}
}
} else {
ProgressControlWrapper.getInstance().setProgressLabel("Will delete current folder " + entry.getName() + ", please wait...");
FileUtils.deleteQuietly(LocalStorageUtil.getSubdirOrFile(location.getLocation(), entry.getAbsoluteInstallationPath()));
ProgressControlWrapper.getInstance().setProgressLabel("Installing new version");
installEntry(location, entry, entry.getBaseDir(), entry.getFile(), entry.getVersion());
}
}
use of org.apache.archiva.maven2.model.Artifact in project assembly64fx by freabemania.
the class Scheduler method addToQueue.
public void addToQueue(Integer installation, Artifact entry) {
File location = UserService.getInstance().getLocation(installation).asFile();
Optional<LocationAndArtifactToInstall> itemPossiblyAlreadyInList = workQueue.stream().filter(item -> item.getArtifact().getName().equals(entry.getName())).findFirst();
LocationAndInstallationStatus tmp = LocationAndInstallationStatus.builder().location(location).id(installation).build();
if (itemPossiblyAlreadyInList.isPresent()) {
LOGGER.info("Adding " + entry.getName() + " " + installation + " to already in queue");
ProgressControlWrapper.getInstance().addProgressSteps(countNofItems(tmp, entry));
itemPossiblyAlreadyInList.get().addLocationAndInstallationStatus(tmp);
} else if (currentlyInstalling.containsKey(entry.getName())) {
LOGGER.info("Adding " + entry.getName() + " to current worker");
ProgressControlWrapper.getInstance().addProgressSteps(countNofItems(tmp, entry));
currentlyInstalling.get(entry.getName()).addLocationAndInstallationStatus(tmp);
} else {
Optional<Artifact> first = artifactsService.getArtifactsDb().stream().filter(item -> item.isMarkedForUpdate() || item.isUpdating()).findFirst();
LocationAndInstallationStatus locationAndInstallation = LocationAndInstallationStatus.builder().location(location).id(installation).build();
if (!first.isPresent()) {
ProgressControlWrapper.getInstance().resetThreadIdMapping();
ProgressControlWrapper.getInstance().setProgressSteps(countNofItems(locationAndInstallation, entry));
} else {
ProgressControlWrapper.getInstance().addProgressSteps(countNofItems(locationAndInstallation, entry));
}
entry.setMarkedForUpdate(true);
// Main.resolveFXMain().refreshTree();
Support.refreshTree();
workQueue.offer(LocationAndArtifactToInstall.builder().artifact(entry).locationsAndInstallationStatus(LocationAndInstallationStatus.builder().location(location).id(installation).build()).build());
}
}
Aggregations