use of org.eclipse.che.api.project.server.notification.ProjectItemModifiedEvent in project che by eclipse.
the class ProjectService method createFolder.
@POST
@Path("/folder/{path:.*}")
@Produces({ MediaType.APPLICATION_JSON })
@ApiOperation(value = "Create a folder", notes = "Create a folder is a specified project")
@ApiResponses({ @ApiResponse(code = 201, message = ""), @ApiResponse(code = 403, message = "User not authorized to call this operation"), @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 409, message = "File already exists"), @ApiResponse(code = 500, message = "Internal Server Error") })
public Response createFolder(@ApiParam(value = "Path to a new folder destination", required = true) @PathParam("path") String path) throws ConflictException, ForbiddenException, ServerException, NotFoundException {
final FolderEntry newFolder = projectManager.getProjectsRoot().createFolder(path);
final URI location = getServiceContext().getServiceUriBuilder().clone().path(getClass(), "getChildren").build(new String[] { newFolder.getPath().toString().substring(1) }, false);
eventService.publish(new ProjectItemModifiedEvent(ProjectItemModifiedEvent.EventType.CREATED, workspace, newFolder.getProject(), newFolder.getPath().toString(), true));
return Response.created(location).entity(injectFolderLinks(asDto(newFolder))).build();
}
use of org.eclipse.che.api.project.server.notification.ProjectItemModifiedEvent in project che by eclipse.
the class RenameTypeTest method helperQualifiedName.
private void helperQualifiedName(String oldName, String newName, String textFileName, String filePatterns) throws Exception {
ICompilationUnit cu = createCUfromTestFile(getPackageP(), oldName);
IType classA = getType(cu, oldName);
String content = getFileContents(getTestPath() + name.getMethodName() + TEST_INPUT_INFIX + textFileName);
IProject project = classA.getJavaProject().getProject();
IFile file = project.getFile(textFileName);
file.create(new ByteArrayInputStream(content.getBytes()), true, null);
ResourceChangedEvent event = new ResourceChangedEvent(new File(BaseTest.class.getResource("/projects").getFile()), new ProjectItemModifiedEvent(ProjectItemModifiedEvent.EventType.CREATED, "projects", fProject.getElementName(), file.getFullPath().toOSString(), false));
JavaModelManager.getJavaModelManager().deltaState.resourceChanged(event);
RenameJavaElementDescriptor descriptor = createRefactoringDescriptor(classA, newName);
descriptor.setUpdateQualifiedNames(true);
descriptor.setFileNamePatterns(filePatterns);
assertEquals("was supposed to pass", null, performRefactoring(descriptor));
ICompilationUnit newcu = getPackageP().getCompilationUnit(newName + ".java");
assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName(newName)), newcu.getSource());
InputStreamReader reader = new InputStreamReader(file.getContents(true));
StringBuffer newContent = new StringBuffer();
try {
int ch;
while ((ch = reader.read()) != -1) newContent.append((char) ch);
} finally {
reader.close();
}
String definedContent = getFileContents(getTestPath() + name.getMethodName() + TEST_OUTPUT_INFIX + textFileName);
assertEqualLines("invalid updating", definedContent, newContent.toString());
}
Aggregations