Skip to content

Commit

Permalink
Taking namespace as input while creating a new file. Added auto gener…
Browse files Browse the repository at this point in the history
…ation of new file content at front end. Displaying loaded while new file content is being generated

Signed-off-by: shiv12095 <shiv12095@iiitd.ac.in>
  • Loading branch information
shiv12095 committed Aug 15, 2016
1 parent ebe7ddc commit 4252b8e
Show file tree
Hide file tree
Showing 11 changed files with 265 additions and 163 deletions.
@@ -0,0 +1,12 @@
package org.eclipse.vorto.server.devtool.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/base")
public class BaseController {



}
Expand Up @@ -17,6 +17,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
Expand All @@ -37,54 +38,57 @@ public class ProjectController {
@Autowired
IProjectRepositoryService projectRepositoryService;

@ResponseStatus(value=HttpStatus.NOT_FOUND, reason = "Project not found")
@ExceptionHandler(ProjectNotFoundException.class)
public void handleProjectNotFoundException(){
@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Project not found")
@ExceptionHandler(ProjectNotFoundException.class)
public void handleProjectNotFoundException() {

}
@ResponseStatus(value=HttpStatus.BAD_REQUEST, reason = "Project already exists")
@ExceptionHandler(ProjectAlreadyExistsException.class)
public void handleProjectAlreadyExistsException(){

@ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "Project already exists")
@ExceptionHandler(ProjectAlreadyExistsException.class)
public void handleProjectAlreadyExistsException() {

}

@ApiOperation(value = "Checks whether a Vorto project already exists")
@RequestMapping(value = "/check/{projectName}", method = RequestMethod.GET)
public void checkProjectExists(@ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName,
@ApiParam(value = "Request", required = true) final HttpServletRequest request) throws ProjectAlreadyExistsException{
@RequestMapping(value = "/{projectName}/check", method = RequestMethod.GET)
public void checkProjectExists(
@ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName,
@ApiParam(value = "Request", required = true) final HttpServletRequest request)
throws ProjectAlreadyExistsException {

Objects.requireNonNull(projectName, "projectName must not be null");

String sessionId = request.getSession().getId();

projectRepositoryService.checkProjectExists(sessionId, projectName);
}

@ApiOperation(value = "Creates a new Vorto project")
@RequestMapping(value = "/new/{projectName}", method = RequestMethod.GET )
public void createProject(@ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName,
@ApiParam(value = "Request", required = true) final HttpServletRequest request) throws ProjectAlreadyExistsException{

Objects.requireNonNull(projectName, "projectName must not be null");

@ApiOperation(value = "Creates a new Vorto project")
@RequestMapping(method = RequestMethod.POST)
public void createProject(@RequestBody Project project,
@ApiParam(value = "Request", required = true) final HttpServletRequest request)
throws ProjectAlreadyExistsException {

Objects.requireNonNull(project.getProjectName(), "projectName must not be null");
HttpServiceContext httpServiceContext = new HttpServiceContext(request);
WebEditorResourceSetProvider webEditorResourceSetProvider = (WebEditorResourceSetProvider) injector
.getInstance(IWebResourceSetProvider.class);

String sessionId = request.getSession().getId();

Project project = projectRepositoryService.createProject(sessionId, projectName);
project = projectRepositoryService.createProject(sessionId, project.getProjectName());

webEditorResourceSetProvider.setSessionResourceSet(httpServiceContext, project.getResourceSet());
webEditorResourceSetProvider.setSessionRefencedResourceSet(httpServiceContext,
project.getReferencedResourceSet());
}

@ApiOperation(value = "Opens an existing Vorto project")
@RequestMapping(value = "/open/{projectName}", method = RequestMethod.GET)
@RequestMapping(value = "/{projectName}/open", method = RequestMethod.GET)
public void openProject(@ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName,
@ApiParam(value = "Request", required = true) final HttpServletRequest request) throws ProjectNotFoundException {
@ApiParam(value = "Request", required = true) final HttpServletRequest request)
throws ProjectNotFoundException {

Objects.requireNonNull(projectName, "projectName must not be null");

Expand All @@ -99,32 +103,47 @@ public void openProject(@ApiParam(value = "ProjectName", required = true) final
webEditorResourceSetProvider.setSessionRefencedResourceSet(httpServiceContext,
project.getReferencedResourceSet());
}

@ApiOperation(value = "Returns all the project for the user")
@RequestMapping(value = "/get", method = RequestMethod.GET)
@RequestMapping(method = RequestMethod.GET)
public ArrayList<Project> getProjects(final HttpServletRequest request) {
String sessionId = request.getSession().getId();
return projectRepositoryService.getProjects(sessionId);
}

@ApiOperation(value = "Deletes the resource in the Vorto project")
@RequestMapping(value = "resource/delete/{projectName}/{resourceId}/", method = RequestMethod.GET)
public void getProjectResourceContents(
@RequestMapping(value = "/{projectName}/resources/delete/{resourceId}/", method = RequestMethod.GET)
public void deleteProjectResource(
@ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName,
@ApiParam(value = "ResourceId", required = true) final @PathVariable String resourceId,
@ApiParam(value = "Request", required = true) final HttpServletRequest request) throws ProjectNotFoundException{
@ApiParam(value = "Request", required = true) final HttpServletRequest request)
throws ProjectNotFoundException {

Objects.requireNonNull(projectName, "projectName must not be null");
Objects.requireNonNull(resourceId, "resourceId must not be null");
String sessionId = request.getSession().getId();
projectRepositoryService.deleteResource(sessionId, projectName, resourceId);
}


@ApiOperation(value = "Creates a new resource in the Vorto project")
@RequestMapping(value = "/{projectName}/resources/create", method = RequestMethod.POST)
public void getProjectResourceContents(
@RequestBody ProjectResource projectResoure,
@ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName,
@ApiParam(value = "Request", required = true) final HttpServletRequest request)
throws ProjectNotFoundException {

Objects.requireNonNull(projectName, "projectName must not be null");
String sessionId = request.getSession().getId();
projectRepositoryService.createResource(sessionId, projectName, projectResoure.getName(), projectResoure.getResourceId());
}

@ApiOperation(value = "Returns a list of resources in the Vorto project")
@RequestMapping(value = "/resources/{projectName}", method = RequestMethod.GET)
@RequestMapping(value = "/{projectName}/resources", method = RequestMethod.GET)
public ArrayList<ProjectResource> getResources(
@ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName,
@ApiParam(value = "Request", required = true) final HttpServletRequest request) throws ProjectNotFoundException {
@ApiParam(value = "Request", required = true) final HttpServletRequest request)
throws ProjectNotFoundException {

Objects.requireNonNull(projectName, "projectName must not be null");

Expand Down
Expand Up @@ -13,6 +13,10 @@ public class Project {
private HashSet<String> referencedResourceSet;
private ArrayList<ProjectResource> resourceList;

public Project(){

}

public Project(String projectName){
this.projectName = projectName;
}
Expand Down
Expand Up @@ -58,5 +58,4 @@ private List<ModelResource> searchModelByExpressionAndValidate(String expression
}
return modelResourceList;
}

}
2 changes: 1 addition & 1 deletion server/devtool/src/main/resources/static/css/style.css
Expand Up @@ -891,5 +891,5 @@ a:hover {
}

.search-box-open-project {
width: 440px;
width: 600px;
}

0 comments on commit 4252b8e

Please sign in to comment.