Source:
<code>protected Promise<Project> update(final Path path, final ProjectRequest request) { final SourceStorageDto sourceDto = dtoFactory.createDto(SourceStorageDto.class); if (request.getBody().getSource() != null) { sourceDto.setLocation(request.getBody().getSource().getLocation()); sourceDto.setType(request.getBody().getSource().getType()); sourceDto.setParameters(request.getBody().getSource().getParameters()); } final ProjectConfigDto dto = dtoFactory.createDto(ProjectConfigDto.class) .withName(request.getBody().getName()) .withPath(path.toString()) .withDescription(request.getBody().getDescription()) .withType(request.getBody().getType()) .withMixins(request.getBody().getMixins()) .withAttributes(request.getBody().getAttributes()) .withSource(sourceDto); return ps.updateProject(dto).thenPromise(new Function<ProjectConfigDto, Promise<Project>>() { @Override public Promise<Project> apply(ProjectConfigDto reference) throws FunctionException { final Optional<Resource> outdatedResource = store.getResource(path); checkState(outdatedResource.isPresent(), "Outdated resource wasn't found"); final Resource resource = outdatedResource.get(); checkState(resource instanceof Container, "Outdated resource is not a container"); Container container = (Container)resource; if (resource instanceof Folder) { Optional<Container> parent = resource.getParent(); checkState(parent.isPresent(), "Parent of the resource wasn't found"); container = parent.get(); } return synchronize(container).then(new Function<Resource[], Project>() { @Override public Project apply(Resource[] synced) throws FunctionException { final Optional<Resource> updatedProject = store.getResource(path); checkState(updatedProject.isPresent(), "Updated resource is not present"); <START> checkState(updatedProject.get().isProject(), "Updateated resource is not a project"); <END> return (Project)updatedProject.get(); } }); } }); }</code><technical_language>fix typo</technical_language>

Target:
protected Promise<Project> update(final Path path, final ProjectRequest request) { final SourceStorageDto sourceDto = dtoFactory.createDto(SourceStorageDto.class); if (request.getBody().getSource() != null) { sourceDto.setLocation(request.getBody().getSource().getLocation()); sourceDto.setType(request.getBody().getSource().getType()); sourceDto.setParameters(request.getBody().getSource().getParameters()); } final ProjectConfigDto dto = dtoFactory.createDto(ProjectConfigDto.class) .withName(request.getBody().getName()) .withPath(path.toString()) .withDescription(request.getBody().getDescription()) .withType(request.getBody().getType()) .withMixins(request.getBody().getMixins()) .withAttributes(request.getBody().getAttributes()) .withSource(sourceDto); return ps.updateProject(dto).thenPromise(new Function<ProjectConfigDto, Promise<Project>>() { @Override public Promise<Project> apply(ProjectConfigDto reference) throws FunctionException { final Optional<Resource> outdatedResource = store.getResource(path); checkState(outdatedResource.isPresent(), "Outdated resource wasn't found"); final Resource resource = outdatedResource.get(); checkState(resource instanceof Container, "Outdated resource is not a container"); Container container = (Container)resource; if (resource instanceof Folder) { Optional<Container> parent = resource.getParent(); checkState(parent.isPresent(), "Parent of the resource wasn't found"); container = parent.get(); } return synchronize(container).then(new Function<Resource[], Project>() { @Override public Project apply(Resource[] synced) throws FunctionException { final Optional<Resource> updatedProject = store.getResource(path); checkState(updatedProject.isPresent(), "Updated resource is not present"); checkState(updatedProject.get().isProject(), "Updated resource is not a project"); return (Project)updatedProject.get(); } }); } }); }