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); }
/** * 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()); }
protected Promise<String> read(File file) { return ps.getFileContent(file.getLocation()); }
final List<NewProjectConfigDto> configDtoList = asDto(projectConfigList); return ps.createBatchProjects(configDtoList) .thenPromise( configList -> ps.getProjects() .thenPromise( updatedConfiguration -> {
.withParameters(sourceStorage.getParameters()); return ps.importProject(path, sourceStorageDto) .thenPromise( ignored -> ps.getProject(path) .then( (Function<ProjectConfigDto, Project>)
Promise<File> createFile(final Container parent, final String name, final String content) { if (!checkFileName(name)) { return promises.reject(new IllegalArgumentException("Invalid file name")); } Optional<Resource> existed = store.getResource(parent.getLocation().append(name)); if (existed.isPresent()) { return promises.reject(new IllegalStateException("Resource already exists")); } if (parent.getLocation().isRoot()) { return promises.reject( new IllegalArgumentException("Failed to create file in workspace root")); } return ps.createFile(parent.getLocation().append(name), content) .thenPromise( reference -> { final Resource createdFile = newResourceFrom(reference); store.register(createdFile); return promises.resolve(createdFile.asFile()); }); }
Promise<Folder> createFolder(final Container parent, final String name) { final Path path = Path.valueOf(name); Optional<Resource> existed = store.getResource(parent.getLocation().append(name)); if (existed.isPresent()) { return promises.reject(new IllegalStateException("Resource already exists")); } if (parent.getLocation().isRoot()) { return promises.reject( new IllegalArgumentException("Failed to create folder in workspace root")); } if (path.segmentCount() == 1 && !checkFolderName(name)) { return promises.reject(new IllegalArgumentException("Invalid folder name")); } return ps.createFolder(parent.getLocation().append(name)) .thenPromise( reference -> { final Resource createdFolder = newResourceFrom(reference); store.register(createdFolder); return promises.resolve(createdFolder.asFolder()); }); }
return ps.copy( source.getLocation(), destination.parent(), destination.lastSegment(), force) .thenPromise(
.getItem(Path.valueOf(dataObject.getPath()).parent().append("pom.xml")) .then( result -> {
protected Promise<Void> delete(final Resource resource) { checkArgument(!resource.getLocation().isRoot(), "Workspace root is not allowed to be moved"); return ps.deleteItem(resource.getLocation()) .then( (Function<Void, Void>)
/** * 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(); }
/** * 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)); }
/** * 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(); }
final String url = getBaseUrl() + SEARCH + encodePath(prjPath.addLeadingSeparator());
/** * Creates the project with given {@code configuration}. * * @param configuration the project configuration * @param options additional parameters that need for project generation * @return {@link Promise} with the {@link ProjectConfigDto} * @see ProjectConfigDto * @since 4.4.0 */ public Promise<ProjectConfigDto> createProject( ProjectConfigDto configuration, Map<String, String> options) { UrlBuilder urlBuilder = new UrlBuilder(getBaseUrl()); for (String key : options.keySet()) { urlBuilder.setParameter(key, options.get(key)); } urlBuilder.setParameter("clientId", appContext.getApplicationId().orElse("")); return reqFactory .createPostRequest(urlBuilder.buildString(), configuration) .header(ACCEPT, APPLICATION_JSON) .loader(loaderFactory.newLoader("Creating project...")) .send(unmarshaller.newUnmarshaller(ProjectConfigDto.class)); }
/** * 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)); }