use of se.light.assembly64.model.Artifact in project archiva by apache.
the class SearchServiceTest method searchWithSearchUnknwownRepoId.
@Test
public /**
* ensure we don't return response for an unknown repo
*/
void searchWithSearchUnknwownRepoId() throws Exception {
SearchService searchService = getSearchService(authorizationHeader);
SearchRequest searchRequest = new SearchRequest();
searchRequest.setBundleExportPackage("org.apache.karaf.features.command.completers");
searchRequest.setRepositories(Arrays.asList("tototititata"));
List<Artifact> artifacts = searchService.searchArtifacts(searchRequest);
assertNotNull(artifacts);
assertTrue(" not 0 results for Bundle ExportPackage org.apache.karaf.features.command.completers but " + artifacts.size() + ":" + artifacts, artifacts.size() == 0);
}
use of se.light.assembly64.model.Artifact in project archiva by apache.
the class SearchServiceTest method quickSearchOnArtifactIdGuest.
/**
* same search but with Guest user
*
* @throws Exception
*/
@Test
public void quickSearchOnArtifactIdGuest() throws Exception {
SearchService searchService = getSearchService(null);
// START SNIPPET: quick-search
List<Artifact> artifacts = searchService.quickSearch("commons-logging");
// return all artifacts with groupId OR artifactId OR version OR packaging OR className
// NOTE : only artifacts with classifier empty are returned
// END SNIPPET: quick-search
assertNotNull(artifacts);
assertTrue(" not 6 results for commons-logging search but " + artifacts.size() + ":" + artifacts, artifacts.size() == 6);
log.info("artifacts for commons-logging size {} search {}", artifacts.size(), artifacts);
}
use of se.light.assembly64.model.Artifact in project assembly64fx by freabemania.
the class Main method handleMouseClicked.
private static void handleMouseClicked(MouseEvent event) {
tree.setContextMenu(null);
TreeItem<GuiLocation> selectedItem = tree.getSelectionModel().getSelectedItem();
if (selectedItem == null || selectedItem.getValue() == null) {
return;
}
if (selectedItem.getValue().getType() == TYPE.ROOT) {
final ContextMenu contextMenu = new ContextMenu();
if (userService.getLocations().size() < MAX_INSTALLATIONS) {
contextMenu.getItems().add(createMenuWithAction(null, "Add new location", Type.ADD_LOCATION, selectedItem.getValue()));
}
contextMenu.getItems().add(createMenuWithAction(null, "Locally synced directory", Type.ADD_PRIVATE_DIR, null));
contextMenu.getItems().add(createMenuWithAction(null, "Install and update all", Type.INSTALL_AND_UPDATE_ALL_LOCATIONS, selectedItem.getValue()));
contextMenu.getItems().add(createMenuWithAction(null, "Update all", Type.UPDATE_ALL_LOCATIONS, selectedItem.getValue()));
contextMenu.getItems().add(createMenuWithAction(null, "Refresh view", Type.REFRESH_VIEW, selectedItem.getValue()));
contextMenu.getItems().add(createMenuWithAction(null, "Reset all views", Type.RESET_ALL_VIEWS, selectedItem.getValue()));
tree.setContextMenu(contextMenu);
return;
}
if (selectedItem.getValue().getType() == TYPE.INSTALLATION_ROOT) {
GuiLocation selectedInstallation = selectedItem.getValue();
if (userService.isInstallationExisting(selectedInstallation.getId())) {
if (event.getButton() == MouseButton.SECONDARY || event.isControlDown()) {
final ContextMenu contextMenu = new ContextMenu();
contextMenu.getItems().add(createMenuWithAction(null, "Update and install all", Type.INSTALLUPDATE_ALL, selectedInstallation));
contextMenu.getItems().add(createMenuWithAction(null, "Update all", Type.UPDATE_ALL, selectedInstallation));
contextMenu.getItems().add(createMenuWithAction(null, "Housekeep", Type.HOUSEKEEP, selectedInstallation));
contextMenu.getItems().add(createMenuWithAction(null, "Set as primary", Type.SET_AS_PRIMARY, selectedInstallation));
contextMenu.getItems().add(createMenuWithAction(null, "Reset view", Type.RESET_VIEW, selectedInstallation));
contextMenu.getItems().add(createMenuWithAction(null, "Open folder", Type.OPEN_LOCATION, selectedInstallation));
contextMenu.getItems().add(createMenuWithAction(null, "Remove location", Type.REMOVE_LOCATION, selectedInstallation));
tree.setContextMenu(contextMenu);
} else if (event.getClickCount() == 2) {
String key = resolveInstallationExpandedKey(selectedInstallation.getId());
if (localDbService.hasLocalDBSetting(key)) {
localDbService.addLocalBooleanDBSetting(key, !localDbService.getBooleanLocalDBSetting(key));
} else {
localDbService.addLocalBooleanDBSetting(key, Boolean.FALSE);
}
}
} else {
final ContextMenu contextMenu = new ContextMenu();
contextMenu.getItems().add(createMenuWithAction(null, "Remove location", Type.REMOVE_LOCATION, selectedInstallation));
tree.setContextMenu(contextMenu);
}
return;
}
if (selectedItem.getValue().getType() == TYPE.LEAF) {
if (event.getClickCount() == 2) {
GuiLocation selectedInstallation = selectedItem.getValue();
String key = resolveLeafInInstallationExpandedKey(selectedInstallation);
if (localDbService.hasLocalDBSetting(key)) {
localDbService.addLocalBooleanDBSetting(key, !localDbService.getBooleanLocalDBSetting(key));
} else {
localDbService.addLocalBooleanDBSetting(key, Boolean.FALSE);
}
} else if (event.getButton() == MouseButton.SECONDARY || event.isControlDown()) {
ContextMenu contextMenu = getContextMenu();
contextMenu.getItems().add(createMenuWithAction(null, "Open folder", Type.OPEN_LEAF_LOCATION, selectedItem.getValue()));
}
return;
}
if (selectedItem.getValue().getType() == TYPE.INSTALLATION) {
if (event.getClickCount() == 2) {
tree.getSelectionModel().clearSelection();
GuiUtils.showDialog("searchMain.fxml", "Search assemblydb", selectedItem.getValue().getArtifact());
return;
} else {
try {
if (event.getButton() == MouseButton.SECONDARY || event.isControlDown()) {
if (tree.getContextMenu() == null) {
tree.setContextMenu(new ContextMenu());
}
ContextMenu contextMenu = tree.getContextMenu();
contextMenu.getItems().clear();
GuiLocation selectedInstallation = selectedItem.getValue();
List<ActionAndIdHolder> actions = new ArrayList<>();
Artifact clickedEntry = selectedInstallation.getArtifact();
boolean installed = artifactsService.isInstalled(userService.getLocation(selectedInstallation.getId()).toLocationAndInstallation(), clickedEntry);
if (!installed) {
actions.add(new ActionAndIdHolder(clickedEntry, Type.INSTALL, selectedInstallation));
} else if (artifactsService.needsUpdate(userService.getLocation(selectedInstallation.getId()).toLocationAndInstallation(), clickedEntry)) {
actions.add(new ActionAndIdHolder(clickedEntry, Type.UPDATE, selectedInstallation));
}
boolean containsInstall = actions.stream().filter(item -> item.getType() == Type.INSTALL).findFirst().isPresent();
boolean containsUpdate = actions.stream().filter(item -> item.getType() == Type.UPDATE).findFirst().isPresent();
if (Support.isRemoteArtifact(clickedEntry) || (Support.isLocalArtifact(clickedEntry) && artifactsService.isPrivateDirAvailable())) {
if (containsInstall) {
contextMenu.getItems().add(createMenuWithAction(clickedEntry, "Install", Type.INSTALL, selectedInstallation));
} else if (containsUpdate) {
contextMenu.getItems().add(createMenuWithAction(clickedEntry, "Update", Type.INSTALL, selectedInstallation));
}
}
contextMenu.getItems().add(createMenuWithAction(clickedEntry, "Info", Type.INFO, selectedInstallation));
if (installed) {
contextMenu.getItems().add(createMenuWithAction(clickedEntry, "Open folder", Type.OPEN, selectedInstallation));
}
if (Support.isRemoteArtifact(clickedEntry) && artifactsService.isPrivateDirAvailable()) {
if (!installed) {
contextMenu.getItems().add(createMenuWithAction(clickedEntry, "Hide", Type.HIDE, selectedInstallation));
} else {
contextMenu.getItems().add(createMenuWithAction(clickedEntry, "Uninstall", Type.UNINSTALL, selectedInstallation));
contextMenu.getItems().add(createMenuWithAction(clickedEntry, "Hide & uninstall", Type.HIDE, selectedInstallation));
}
}
if (Support.isRemoteArtifact(clickedEntry) && userService.isPremium()) {
contextMenu.getItems().add(createMenuWithAction(clickedEntry, "Search", Type.SEARCH, selectedInstallation));
}
if (clickedEntry.isMarkedForUpdate()) {
if (!clickedEntry.isUpdating()) {
contextMenu.getItems().add(createMenuWithAction(clickedEntry, "Cancel", Type.CANCEL_UPDATE, selectedInstallation));
}
}
if (installed && Support.isRemoteArtifact(clickedEntry)) {
String baseLocation = Support.appendPathIfMissing(userService.getLocation(selectedInstallation.getId()).toLocationAndInstallation().getLocation()) + clickedEntry.getAbsoluteInstallationPath();
File releaseNoteFile = new File(Support.appendPathIfMissing(baseLocation + "/releaselog.json"));
ReturningTask<Void> showExtraMenuTask = () -> {
if (releaseNoteFile.exists()) {
Platform.runLater(() -> {
contextMenu.getItems().add(createMenuWithAction(clickedEntry, "View new entries", Type.SHOW_RELEASES, selectedInstallation, baseLocation));
});
}
return null;
};
ExecutorUtil.executeAsyncWithRetry(showExtraMenuTask);
}
} else {
tree.getSelectionModel().clearSelection();
}
} catch (Exception e) {
LOGGER.error("Exception in mouseclick", e);
}
}
}
}
use of se.light.assembly64.model.Artifact in project assembly64fx by freabemania.
the class ArtifactsService method getArtifactsDb.
public List<Artifact> getArtifactsDb(boolean refresh) {
if (artifactsDb == null || refresh) {
try {
List<Artifact> tmp = getClient().target(getBackendServer()).path("/leet/artifacts2").request().header("email", getSessionInfo().getEmail()).header("token", getSessionInfo().getToken()).get(new GenericType<List<Artifact>>() {
});
if (localDbService.hasPrivateDirConfigured()) {
String path = localDbService.getPrivateDir().replace("\\", "/");
String name = path.substring(path.lastIndexOf("/") + 1);
Artifact localArtifact = Artifact.localArtifact("Misc", name);
tmp.add(localArtifact);
}
Collections.sort(tmp, (i1, i2) -> (i1.getPrefix() + i1.getFolder()).toLowerCase().compareTo((i2.getPrefix() + i2.getFolder()).toLowerCase()));
artifactsDb = Collections.unmodifiableList(tmp);
} catch (Exception e) {
LOGGER.error("Unable to parse localdb", e);
throw new RuntimeException(e);
}
}
return artifactsDb;
}
use of se.light.assembly64.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));
}
Aggregations