use of se.light.assembly64.model.Artifact in project archiva by apache.
the class BrowseServiceTest method searchArtifacts.
@Test
public void searchArtifacts() throws Exception {
// START SNIPPET: search-artifacts
BrowseService browseService = getBrowseService(authorizationHeader, true);
List<Artifact> artifactDownloadInfos = browseService.searchArtifacts("The Apache Software Foundation", TEST_REPO_ID, true);
assertThat(artifactDownloadInfos).isNotNull().isNotEmpty().hasSize(7);
// END SNIPPET: search-artifacts
}
use of se.light.assembly64.model.Artifact in project archiva by apache.
the class AbstractRestService method buildArtifacts.
protected List<Artifact> buildArtifacts(Collection<ArtifactMetadata> artifactMetadatas, String repositoryId) throws ArchivaRestServiceException {
try {
if (artifactMetadatas != null && !artifactMetadatas.isEmpty()) {
List<Artifact> artifacts = new ArrayList<>(artifactMetadatas.size());
for (ArtifactMetadata artifact : artifactMetadatas) {
String repoId = repositoryId != null ? repositoryId : artifact.getRepositoryId();
if (repoId == null) {
throw new IllegalStateException("Repository Id is null");
}
ManagedRepository repo = repositoryRegistry.getManagedRepository(repoId);
if (repo == null) {
throw new RepositoryException("Repository not found " + repoId);
}
ManagedRepositoryContent content = repo.getContent();
ArtifactBuilder builder = new ArtifactBuilder().forArtifactMetadata(artifact).withManagedRepositoryContent(content);
Artifact art = builder.build();
art.setUrl(getArtifactUrl(art, repositoryId));
artifacts.add(art);
}
return artifacts;
}
return Collections.emptyList();
} catch (RepositoryException e) {
log.error(e.getMessage(), e);
throw new ArchivaRestServiceException(e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
}
}
use of se.light.assembly64.model.Artifact in project archiva by apache.
the class DownloadMergedIndexNonDefaultPathTest method downloadMergedIndexWithNonDefaultPath.
@Test
public void downloadMergedIndexWithNonDefaultPath() throws Exception {
Path indexBaseDir = Paths.get(System.getProperty("java.io.tmpdir")).resolve("archiva").resolve("remotedownloadtest");
String indexBase = indexBaseDir.toString();
FileUtils.deleteQuietly(indexBaseDir);
if (!Files.exists(indexBaseDir)) {
Files.createDirectories(indexBaseDir);
}
String id = Long.toString(System.currentTimeMillis());
ManagedRepository managedRepository = new ManagedRepository(Locale.getDefault());
managedRepository.setId(id);
managedRepository.setName("name of " + id);
managedRepository.setLocation(System.getProperty("basedir") + "/src/test/repositories/test-repo");
managedRepository.setIndexDirectory(indexBase + "/index-" + id);
managedRepository.setPackedIndexDirectory(indexBase + "/indexPacked-" + id);
ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService();
if (managedRepositoriesService.getManagedRepository(id) != null) {
managedRepositoriesService.deleteManagedRepository(id, false);
}
getManagedRepositoriesService().addManagedRepository(managedRepository);
RepositoriesService repositoriesService = getRepositoriesService();
repositoriesService.scanRepositoryNow(id, true);
// wait a bit to ensure index is finished
int timeout = 20000;
while (timeout > 0 && repositoriesService.alreadyScanning(id)) {
Thread.sleep(500);
timeout -= 500;
}
RepositoryGroupService repositoryGroupService = getRepositoryGroupService();
String repoGroupId = "test-group";
if (repositoryGroupService.getRepositoryGroup(repoGroupId) != null) {
repositoryGroupService.deleteRepositoryGroup(repoGroupId);
}
RepositoryGroup repositoryGroup = new RepositoryGroup();
repositoryGroup.setId(repoGroupId);
String path = ".fooooo";
repositoryGroup.setRepositories(Arrays.asList(id));
repositoryGroup.setMergedIndexPath(path);
repositoryGroupService.addRepositoryGroup(repositoryGroup);
// create a repo with a remote on the one with index
id = Long.toString(System.currentTimeMillis());
managedRepository = new ManagedRepository(Locale.getDefault());
managedRepository.setId(id);
managedRepository.setName("name of " + id);
managedRepository.setLocation(System.getProperty("basedir") + "/src/test/repositories/test-repo");
managedRepository.setIndexDirectory(indexBaseDir + "/index-" + id);
managedRepository.setPackedIndexDirectory(indexBase + "/tmpIndexPacked-" + id);
if (managedRepositoriesService.getManagedRepository(id) != null) {
managedRepositoriesService.deleteManagedRepository(id, false);
}
getManagedRepositoriesService().addManagedRepository(managedRepository);
String remoteId = Long.toString(System.currentTimeMillis());
RemoteRepository remoteRepository = new RemoteRepository(Locale.getDefault());
remoteRepository.setId(remoteId);
remoteRepository.setName(remoteId);
remoteRepository.setDownloadRemoteIndex(true);
remoteRepository.setUrl("http://localhost:" + port + "/repository/test-group");
remoteRepository.setRemoteIndexUrl("http://localhost:" + port + "/repository/test-group/" + path);
remoteRepository.setUserName(RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME);
remoteRepository.setPassword(FakeCreateAdminService.ADMIN_TEST_PWD);
getRemoteRepositoriesService().addRemoteRepository(remoteRepository);
ProxyConnectorService proxyConnectorService = getProxyConnectorService();
ProxyConnector proxyConnector = new ProxyConnector();
proxyConnector.setProxyId("foo-bar2");
proxyConnector.setSourceRepoId(id);
proxyConnector.setTargetRepoId(remoteId);
proxyConnectorService.addProxyConnector(proxyConnector);
repositoriesService.scheduleDownloadRemoteIndex(remoteId, true, true);
// wait the end
while (!repositoriesService.getRunningRemoteDownloadIds().getStrings().isEmpty()) {
Thread.sleep(500);
log.debug("still running remote download");
}
SearchService searchService = getSearchService();
SearchRequest request = new SearchRequest();
request.setRepositories(Arrays.asList(id));
request.setGroupId("org.apache.felix");
List<Artifact> artifacts = searchService.searchArtifacts(request);
assertThat(artifacts).isNotNull().isNotEmpty().hasSize(1);
}
use of se.light.assembly64.model.Artifact in project assembly64fx by freabemania.
the class SearchController method init.
public void init(Artifact searchEntry) throws Exception {
localDb = LocalDBService.getInstance();
userService = UserService.getInstance();
searchService = SearchService.getInstance();
mappingService = CategoryMappingService.getInstance();
// populate years
table.setPlaceholder(new Label(""));
yearInput.getItems().add(ALL);
IntStream.range(1980, Calendar.getInstance().get(Calendar.YEAR) + 1).forEach(item -> yearInput.getItems().add(String.valueOf(item)));
yearInput.getSelectionModel().selectFirst();
// populate ratings
ratingInput.getItems().add(ALL);
IntStream.range(1, 10).forEach(item -> ratingInput.getItems().add(String.valueOf(item)));
ratingInput.getSelectionModel().selectFirst();
categoryInput.getItems().add(ALL);
List<CategoryMapping> l = new ArrayList<CategoryMapping>(mappingService.values());
Collections.sort(l, (i1, i2) -> i1.getDescription().toLowerCase().compareTo(i2.getDescription().toLowerCase()));
l.stream().forEach(item -> categoryInput.getItems().add(item.getDescription()));
if (searchEntry != null) {
try {
CategoryMapping categoryMappingByName = mappingService.getCategoryMappingByName(searchEntry.getDatabaseId());
categoryInput.getSelectionModel().select(categoryMappingByName.getDescription());
} catch (Exception e) {
categoryInput.getSelectionModel().selectFirst();
}
} else {
categoryInput.getSelectionModel().selectFirst();
}
name.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("name"));
group.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("group"));
year.setCellValueFactory(new PropertyValueFactory<SearchResultItem, Integer>("year"));
handle.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("handle"));
event.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("event"));
group.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("group"));
rating.setCellValueFactory(new PropertyValueFactory<SearchResultItem, Integer>("rating"));
category.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("categoryName"));
updated.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("updated"));
EventHandler<MouseEvent> mouseEventHandle = (MouseEvent event) -> {
handleMouseClicked(event);
};
table.setOnKeyTyped(event -> {
if (event.getCharacter().length() > 0 && event.getCharacter().charAt(0) == ENTER_KEY) {
openFiles();
}
});
table.addEventHandler(MouseEvent.MOUSE_PRESSED, mouseEventHandle);
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
registerSearchOnEnter(nameInput);
registerSearchOnEnter(groupInput);
registerSearchOnEnter(handleInput);
registerSearchOnEnter(eventInput);
registerChoice(yearInput);
registerChoice(categoryInput);
registerChoice(ratingInput);
checkCheckbox(t64, T64SEARCH);
checkCheckbox(d64, D64SEARCH);
checkCheckbox(d71, T71SEARCH);
checkCheckbox(d81, T81SEARCH);
checkCheckbox(prg, PRGSEARCH);
checkCheckbox(tap, TAPSEARCH);
checkCheckbox(crt, CRTSEARCH);
checkCheckbox(bin, BINSEARCH);
checkCheckbox(sid, SIDSEARCH);
checkCheckbox(g64, G64SEARCH);
searchPeriod.setItems(FXCollections.observableArrayList(SEARCH_PERIOD.ALL, SEARCH_PERIOD.ONE_DAY, SEARCH_PERIOD.TWO_DAYS, SEARCH_PERIOD.FOUR_DAYS, SEARCH_PERIOD.ONE_WEEK, SEARCH_PERIOD.TWO_WEEKS, SEARCH_PERIOD.THREE_WEEKS, SEARCH_PERIOD.ONE_MONTH, SEARCH_PERIOD.TWO_MONTHS));
searchPeriod.getSelectionModel().select(0);
try {
searchPeriod.getSelectionModel().selectedItemProperty().addListener((ObservableValue<? extends SEARCH_PERIOD> observable, SEARCH_PERIOD oldValue, SEARCH_PERIOD newValue) -> performSearch());
} catch (Exception e) {
logger.error("Unable to install listener", e);
}
registerCheckboxChangeForSearch(t64, T64SEARCH);
registerCheckboxChangeForSearch(d64, D64SEARCH);
registerCheckboxChangeForSearch(d71, T71SEARCH);
registerCheckboxChangeForSearch(d81, T81SEARCH);
registerCheckboxChangeForSearch(prg, PRGSEARCH);
registerCheckboxChangeForSearch(tap, TAPSEARCH);
registerCheckboxChangeForSearch(crt, CRTSEARCH);
registerCheckboxChangeForSearch(bin, BINSEARCH);
registerCheckboxChangeForSearch(sid, SIDSEARCH);
registerCheckboxChangeForSearch(g64, G64SEARCH);
searchFromStartOfString.selectedProperty().addListener(new ChangeListener<Boolean>() {
public void changed(ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) {
ExecutorUtil.executeAsyncWithRetry(() -> {
localDb.addLocalDBSetting("search_from_start", String.valueOf(newVal));
return null;
});
}
});
String val = localDb.getLocalDBSetting("search_from_start");
if (val != null) {
searchFromStartOfString.setSelected(Boolean.valueOf(val));
} else {
searchFromStartOfString.setSelected(true);
}
if (!userService.isLocationSelectedAndExisting()) {
downloadFolderImage.setVisible(false);
}
}
use of se.light.assembly64.model.Artifact in project assembly64fx by freabemania.
the class InstallationService method unpackDynamic.
private void unpackDynamic(File content, LocationAndInstallationStatus location, Artifact entry, ArtifactDelta delta) throws Exception {
CancelableTask cancelTask = CancelableTask.of();
LocalStorageUtil.createDir(pathService.getTmpDynFolder());
unzipService.extractZip(content, pathService.getTmpDynFolder(), entry);
if (cancelTask.isCancelled()) {
return;
}
File[] files = LocalStorageUtil.getSubdirOrFile(pathService.getTmpDynFolder(), entry.getFolder()).listFiles();
File base = LocalStorageUtil.getSubdirOrFile(location.getLocation(), entry.getPrefix() + "/" + entry.getFolder());
Optional<File> releaseLogFile = Arrays.stream(files).filter(item -> item.getName().equals("releaselog.json")).findFirst();
List<ReleaseInfo> releaseInfoList = null;
List<ReleaseInfo> matchedReleaseInfoList = new ArrayList<>();
if (releaseLogFile.isPresent()) {
releaseInfoList = Support.readList(ReleaseInfo.class, releaseLogFile.get()).stream().collect(Collectors.toList());
for (ReleaseInfo item : releaseInfoList) {
String p = item.getPath();
int start = p.indexOf("/", p.indexOf("/") + 1);
item.setPath(entry.getPrefix() + "/" + entry.getFolder() + "/" + p.substring(start + 1));
item.setStrippedPath(entry.getFolder() + "/" + p.substring(start + 1));
}
}
for (File f : files) {
if (f.isDirectory()) {
String dirname = f.getName().toUpperCase();
char firstChar = dirname.charAt(0);
boolean isDigit = Character.isDigit(firstChar);
boolean isAlpha = Character.isAlphabetic(firstChar);
String target = findDestination(firstChar, dirname, base);
if (target != null) {
File t = null;
if (isDigit) {
t = new File(base.getAbsolutePath() + "/0-9/" + target + "/" + f.getName());
} else if (isAlpha) {
t = new File(base.getAbsolutePath() + "/" + String.valueOf(firstChar) + "/" + target + "/" + f.getName());
} else {
t = new File(base.getAbsolutePath() + "/___MISC___/" + target + "/" + f.getName());
}
FileUtils.forceMkdir(t);
FileUtils.copyDirectory(f, t);
if (releaseInfoList != null) {
ReleaseInfo matchedReleaseInfo = null;
for (ReleaseInfo item : releaseInfoList) {
File[] subdirs = f.listFiles(File::isDirectory);
for (File dir : subdirs) {
if (dir.getPath().contains(item.getStrippedPath())) {
matchedReleaseInfo = item;
break;
}
}
}
if (matchedReleaseInfo != null) {
matchedReleaseInfo.setPath(t.getAbsolutePath().substring(base.getAbsolutePath().length() + 1));
matchedReleaseInfoList.add(matchedReleaseInfo);
}
}
ProgressControlWrapper.getInstance().setProgressLabel("Moved " + f.getName() + " to " + t.getAbsolutePath());
if (cancelTask.isCancelled()) {
break;
}
} else {
LOGGER.info("Unable to install " + dirname);
}
}
}
ProgressControlWrapper.getInstance().increaseProgress();
if (releaseLogFile.isPresent()) {
File t = new File(base.getAbsolutePath() + "/releaselog.json");
LOGGER.info("Flushing rebuildt releaselog.json to " + t.getAbsolutePath());
Support.flush(matchedReleaseInfoList, t);
}
}
Aggregations