use of com.enonic.xp.project.ModifyProjectParams in project xp by enonic.
the class ProjectServiceImpl method doModify.
private Project doModify(final ModifyProjectParams params) {
final UpdateRepositoryParams updateParams = UpdateRepositoryParams.create().repositoryId(params.getName().getRepoId()).editor(editableRepository -> modifyProjectData(params, editableRepository.data)).build();
final Repository updatedRepository = repositoryService.updateRepository(updateParams);
if (!ProjectConstants.DEFAULT_PROJECT_NAME.equals(params.getName())) {
UpdateProjectRoleNamesCommand.create().securityService(securityService).projectName(params.getName()).projectDisplayName(params.getDisplayName()).build().execute();
}
return Project.from(updatedRepository);
}
use of com.enonic.xp.project.ModifyProjectParams in project xp by enonic.
the class ModifyProjectHandler method doExecute.
@Override
protected ProjectMapper doExecute() {
final Project projectBeforeUpdate = this.projectService.get(this.id);
final ModifyProjectParams params = modifyProjectParams(projectBeforeUpdate);
final Project project = this.projectService.modify(params);
Locale projectLanguage;
if (this.language != null) {
projectLanguage = ApplyProjectLanguageCommand.create().projectName(this.id).language(this.language).contentService(this.contentService).build().execute();
} else {
projectLanguage = GetProjectLanguageCommand.create().projectName(this.id).contentService(this.contentService).build().execute();
}
final Boolean isPublic = GetProjectReadAccessCommand.create().projectName(this.id).contentService(this.contentService).build().execute();
final ProjectPermissions projectPermissions = this.projectService.getPermissions(this.id);
return ProjectMapper.create().setProject(project).setLanguage(projectLanguage).setProjectPermissions(projectPermissions).setIsPublic(isPublic).build();
}
use of com.enonic.xp.project.ModifyProjectParams in project xp by enonic.
the class BaseProjectHandlerTest method mockProject.
protected void mockProject() {
final Map<ProjectName, Project> projects = new HashMap<>();
when(this.projectService.create(any(CreateProjectParams.class))).thenAnswer(mock -> {
final Project project = createProject((CreateProjectParams) mock.getArguments()[0]);
Mockito.when(projectService.get(project.getName())).thenReturn(project);
Mockito.when(projectService.delete(project.getName())).thenReturn(true);
projects.put(project.getName(), project);
return project;
});
when(this.projectService.modify(any(ModifyProjectParams.class))).thenAnswer(mock -> {
final Project project = createProject((ModifyProjectParams) mock.getArguments()[0]);
Mockito.when(projectService.get(project.getName())).thenReturn(project);
projects.put(project.getName(), project);
return project;
});
when(this.projectService.list()).thenAnswer(mock -> Projects.create().addAll(projects.values()).build());
when(this.projectService.getPermissions(any(ProjectName.class))).thenReturn(ProjectPermissions.create().build());
when(this.projectService.modifyPermissions(any(ProjectName.class), any(ProjectPermissions.class))).thenAnswer(mock -> {
final ProjectName projectName = (ProjectName) mock.getArguments()[0];
final ProjectPermissions projectPermissions = (ProjectPermissions) mock.getArguments()[1];
Mockito.when(projectService.getPermissions(projectName)).thenReturn(projectPermissions);
return projectPermissions;
});
}
Aggregations