Search in sources :

Example 41 with Artifact

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);
}
Also used : SearchRequest(org.apache.archiva.rest.api.model.SearchRequest) SearchService(org.apache.archiva.rest.api.services.SearchService) Artifact(org.apache.archiva.maven2.model.Artifact) Test(org.junit.Test)

Example 42 with Artifact

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);
}
Also used : SearchService(org.apache.archiva.rest.api.services.SearchService) Artifact(org.apache.archiva.maven2.model.Artifact) Test(org.junit.Test)

Example 43 with Artifact

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);
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) GuiLocation(se.light.assembly64.model.GuiLocation) ContextMenu(javafx.scene.control.ContextMenu) Artifact(se.light.assembly64.model.Artifact) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 44 with Artifact

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;
}
Also used : List(java.util.List) Artifact(se.light.assembly64.model.Artifact) Support.isRemoteArtifact(se.light.assembly64.Support.isRemoteArtifact) IOException(java.io.IOException)

Example 45 with Artifact

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));
}
Also used : ArtifactDelta(se.light.assembly64.model.ArtifactDelta) ReturningTask(se.light.assembly64.model.ReturningTask) Arrays(java.util.Arrays) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) Support.isRemoteArtifact(se.light.assembly64.Support.isRemoteArtifact) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LatestInstalledItemInfo(se.light.assembly64.model.LatestInstalledItemInfo) Support.getVersionAsInteger(se.light.assembly64.Support.getVersionAsInteger) ArtifactType(se.light.assembly64.model.ArtifactType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ProgressDBController(se.light.assembly64.fx.ProgressDBController) GuiUtils(se.light.assembly64.util.GuiUtils) Map(java.util.Map) Support(se.light.assembly64.Support) Support.flush(se.light.assembly64.Support.flush) CancelableTask(se.light.assembly64.model.CancelableTask) TrueFileFilter(org.apache.commons.io.filefilter.TrueFileFilter) Support.getObjectMapper(se.light.assembly64.Support.getObjectMapper) ContentEntry(se.light.assembly64.model.ContentEntry) GenericMessageDialogController(se.light.assembly64.fx.GenericMessageDialogController) Analytics(se.light.assembly64.Analytics) Logger(org.slf4j.Logger) ExecutorUtil(se.light.assembly64.util.ExecutorUtil) Set(java.util.Set) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Artifact(se.light.assembly64.model.Artifact) Collectors(java.util.stream.Collectors) LocalStorageUtil(se.light.assembly64.util.LocalStorageUtil) File(java.io.File) ReleaseInfo(se.light.assembly64.model.ReleaseInfo) Platform(javafx.application.Platform) ProgressControlWrapper(se.light.assembly64.fx.ProgressControlWrapper) List(java.util.List) ChronoUnit(java.time.temporal.ChronoUnit) SearchResultItem(se.light.assembly64.model.SearchResultItem) NullWindowOwner(se.light.assembly64.fx.NullWindowOwner) LocalDate(java.time.LocalDate) DateTimeFormatter(java.time.format.DateTimeFormatter) Optional(java.util.Optional) DOWNLOAD_STATUS(se.light.assembly64.service.FTPService.DOWNLOAD_STATUS) ProgressMessageBox(se.light.assembly64.ProgressMessageBox) FILE_ACTION(se.light.assembly64.Support.FILE_ACTION) Support.getTodayDateAsBasicIsoString(se.light.assembly64.Support.getTodayDateAsBasicIsoString) LocationAndInstallationStatus(se.light.assembly64.model.LocationAndInstallationStatus) LatestInstalledItemInfo(se.light.assembly64.model.LatestInstalledItemInfo)

Aggregations

Artifact (org.apache.archiva.maven2.model.Artifact)37 Test (org.junit.Test)29 SearchService (org.apache.archiva.rest.api.services.SearchService)14 ArrayList (java.util.ArrayList)13 BrowseService (org.apache.archiva.rest.api.services.BrowseService)11 File (java.io.File)10 SearchRequest (org.apache.archiva.rest.api.model.SearchRequest)9 Artifact (se.light.assembly64.model.Artifact)9 ManagedRepositoriesService (org.apache.archiva.rest.api.services.ManagedRepositoriesService)8 RepositoriesService (org.apache.archiva.rest.api.services.RepositoriesService)8 Path (java.nio.file.Path)7 List (java.util.List)6 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)6 CancelableTask (se.light.assembly64.model.CancelableTask)6 IOException (java.io.IOException)5 Optional (java.util.Optional)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 ArtifactDelta (se.light.assembly64.model.ArtifactDelta)5 ArtifactType (se.light.assembly64.model.ArtifactType)5