protected Promise<SearchResult> search(QueryExpression queryExpression) { return ps.search(queryExpression); }
public Promise<List<SourceEstimation>> resolve(Project project) { return ps.resolveSources(project.getLocation()); }
protected Promise<String> read(File file) { return ps.getFileContent(file.getLocation()); }
/** * Writes the file {@code content} by given {@code path}. * * @param path path to the file * @param content the file content * @return {@link Promise} with empty response * @see Path * @since 4.4.0 */ public Promise<Void> setFileContent(Path path, String content) { final String url = getBaseUrl() + FILE + encodePath(path); return reqFactory.createRequest(PUT, url, null, false).data(content).send(); }
protected Promise<Void> write(final File file, String content) { checkArgument(content != null, "Null content occurred"); return ps.setFileContent(file.getLocation(), content); }
Promise<SourceEstimation> estimate(Container container, String projectType) { checkArgument(projectType != null, "Null project type"); checkArgument(!projectType.isEmpty(), "Empty project type"); return ps.estimate(container.getLocation(), projectType); }
@Inject(optional = true) private void register(Set<ResolvingProjectStateHolder> holders) { for (ResolvingProjectStateHolder holder : holders) { final String projectType = holder.getProjectType(); if (this.resolvingProjectStateHolders.containsKey(projectType)) { Log.warn( this.getClass(), "Resolving project state holder for '" + projectType + "' project type is already registered."); } else { this.resolvingProjectStateHolders.put(projectType, holder); } } }
@Inject public ProjectTreeNotificationsSubscriber( EventBus eventBus, AppContext appContext, RequestTransmitter requestTransmitter, DtoFactory dtoFactory) { this.requestTransmitter = requestTransmitter; this.dtoFactory = dtoFactory; eventBus.addHandler(WsAgentServerRunningEvent.TYPE, event -> subscribe()); // in case ws-agent is already running eventBus.addHandler( BasicIDEInitializedEvent.TYPE, event -> { if (appContext.getWorkspace().getStatus() == RUNNING) { subscribe(); } }); }
/** * Returns the projects list. If there is no projects were found on server, empty list is * returned. * * @return {@link Promise} with list of project configuration * @see ProjectConfigDto * @since 4.4.0 */ public Promise<List<ProjectConfigDto>> getProjects() { final String url = getBaseUrl(); return reqFactory .createGetRequest(url) .header(ACCEPT, MimeType.APPLICATION_JSON) .send(unmarshaller.newListUnmarshaller(ProjectConfigDto.class)); }
protected Promise<SearchResult> search( final Container container, String fileMask, String contentMask) { QueryExpression queryExpression = new QueryExpression(); if (!isNullOrEmpty(contentMask)) { queryExpression.setText(contentMask); } if (!isNullOrEmpty(fileMask)) { queryExpression.setName(fileMask); } if (!container.getLocation().isRoot()) { queryExpression.setPath(container.getLocation().toString()); } return ps.search(queryExpression); }
/** * Reads the file content by given {@code path}. * * @param path path to the file * @return {@link Promise} with file content * @see Path * @since 4.4.0 */ public Promise<String> getFileContent(Path path) { final String url = getBaseUrl() + FILE + encodePath(path); return reqFactory.createGetRequest(url).send(new StringUnmarshaller()); }
@Override public void onPreviousButtonClicked() { skipCount -= skipCount % SEARCH_RESULT_ITEMS + SEARCH_RESULT_ITEMS; queryExpression.setSkipCount(skipCount); projectServiceClient .search(queryExpression) .then( result -> { List<SearchItemReference> itemReferences = result.getItemReferences(); view.setNextBtnActive(true); boolean hasPreviousResults = itemReferences.size() % SEARCH_RESULT_ITEMS == 0 && skipCount != 0; view.setPreviousBtnActive(hasPreviousResults); view.showResults(result, requestedString); }); }
/** * Removes the item by given {@code path} from the server. * * @param path path to the item * @return {@link Promise} with empty response * @see Path * @since 4.4.0 */ public Promise<Void> deleteItem(Path path) { final String url = getBaseUrl() + encodePath(path); return reqFactory .createRequest(DELETE, url, null, false) .loader(loaderFactory.newLoader("Deleting resource...")) .send(); }
@Override public void onNextButtonClicked() { queryExpression.setSkipCount(skipCount + SEARCH_RESULT_ITEMS); projectServiceClient .search(queryExpression) .then( result -> { List<SearchItemReference> itemReferences = result.getItemReferences(); skipCount += itemReferences.size(); view.setPreviousBtnActive(true); if (itemReferences.isEmpty()) { view.setNextBtnActive(false); return; } if (itemReferences.size() % SEARCH_RESULT_ITEMS == 0) { view.setNextBtnActive(true); } else { skipCount += SEARCH_RESULT_ITEMS; view.setNextBtnActive(false); } view.showResults(result, requestedString); }); }
/** * Creates the folder by given {@code path}. * * @param path path to the future folder * @return {@link Promise} with the {@link ItemReference} * @see ItemReference * @see Path * @since 4.4.0 */ public Promise<ItemReference> createFolder(Path path) { final String url = getBaseUrl() + FOLDER + encodePath(path); return reqFactory .createPostRequest(url, null) .loader(loaderFactory.newLoader("Creating folder...")) .send(unmarshaller.newUnmarshaller(ItemReference.class)); }
/** * Gets list of {@link SourceEstimation} for all supposed project types. * * @param path path of the project to resolve * @return {@link Promise} with the list of resolved estimations * @see Path * @see SourceEstimation * @since 4.4.0 */ public Promise<List<SourceEstimation>> resolveSources(Path path) { final String url = getBaseUrl() + RESOLVE + encodePath(path); return reqFactory .createGetRequest(url) .header(ACCEPT, APPLICATION_JSON) .loader(loaderFactory.newLoader("Resolving sources...")) .send(unmarshaller.newListUnmarshaller(SourceEstimation.class)); }
/** * Returns the specific project by given {@code path}. Path to project should be an absolute. * * @param path path to project * @return {@link Promise} with project configuration * @see ProjectConfigDto * @see Path * @since 4.4.0 */ public Promise<ProjectConfigDto> getProject(Path path) { final String url = getBaseUrl() + encodePath(path); return reqFactory .createGetRequest(url) .header(ACCEPT, APPLICATION_JSON) .loader(loaderFactory.newLoader("Getting project...")) .send(unmarshaller.newUnmarshaller(ProjectConfigDto.class)); }
/** * Returns the item description by given {@code path}. * * @param path path to the item * @return {@link Promise} with the {@link ItemReference} * @see Path * @see ItemReference * @since 4.4.0 */ public Promise<ItemReference> getItem(Path path) { final String url = getBaseUrl() + ITEM + encodePath(path); return reqFactory .createGetRequest(url) .header(ACCEPT, APPLICATION_JSON) .loader(loaderFactory.newLoader("Getting item...")) .send(unmarshaller.newUnmarshaller(ItemReference.class)); }
/** * Estimates the given {@code path} to be applied to specified {@code pType} (project type). * * @param path path to the folder * @param pType project type to estimate * @return {@link Promise} with the {@link SourceEstimation} * @see Path * @see SourceEstimation * @since 4.4.0 */ public Promise<SourceEstimation> estimate(Path path, String pType) { final String url = getBaseUrl() + ESTIMATE + encodePath(path) + "?type=" + pType; return reqFactory .createGetRequest(url) .header(ACCEPT, APPLICATION_JSON) .loader(loaderFactory.newLoader("Estimating project...")) .send(unmarshaller.newUnmarshaller(SourceEstimation.class)); }
/** * Moves the {@code source} item to given {@code target} with {@code newName}. * * @param source the source path to be moved * @param target the target path, should be a container (project or folder) * @param newName the new name of the moved item * @param overwrite overwrite target is such has already exists * @return {@link Promise} with empty response * @see Path * @since 4.4.0 */ public Promise<Void> move(Path source, Path target, String newName, boolean overwrite) { final String url = getBaseUrl() + MOVE + encodePath(source) + "?to=" + encodePath(target); final MoveOptions moveOptions = dtoFactory.createDto(MoveOptions.class); moveOptions.setName(newName); moveOptions.setOverWrite(overwrite); return reqFactory .createPostRequest(url, moveOptions) .loader(loaderFactory.newLoader("Moving...")) .send(); }