Search in sources :

Example 1 with ModifyProjectParams

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);
}
Also used : ArchiveInitializer(com.enonic.xp.core.impl.project.init.ArchiveInitializer) DeleteRepositoryParams(com.enonic.xp.repository.DeleteRepositoryParams) RepositoryService(com.enonic.xp.repository.RepositoryService) LoggerFactory(org.slf4j.LoggerFactory) AttachmentSerializer(com.enonic.xp.attachment.AttachmentSerializer) ImageHelper(com.enonic.xp.image.ImageHelper) IndexService(com.enonic.xp.index.IndexService) BigDecimal(java.math.BigDecimal) RepositoryId(com.enonic.xp.repository.RepositoryId) ContextAccessor(com.enonic.xp.context.ContextAccessor) NodeService(com.enonic.xp.node.NodeService) CreateAttachment(com.enonic.xp.attachment.CreateAttachment) ImageIO(javax.imageio.ImageIO) ContextBuilder(com.enonic.xp.context.ContextBuilder) EnumSet(java.util.EnumSet) SecurityService(com.enonic.xp.security.SecurityService) RoundingMode(java.math.RoundingMode) BinaryReference(com.enonic.xp.util.BinaryReference) ProjectService(com.enonic.xp.project.ProjectService) Projects(com.enonic.xp.project.Projects) BufferedImage(java.awt.image.BufferedImage) BinaryAttachment(com.enonic.xp.node.BinaryAttachment) Project(com.enonic.xp.project.Project) Collectors(java.util.stream.Collectors) CreateProjectParams(com.enonic.xp.project.CreateProjectParams) UpdateRepositoryParams(com.enonic.xp.repository.UpdateRepositoryParams) UncheckedIOException(java.io.UncheckedIOException) List(java.util.List) ProjectNotFoundException(com.enonic.xp.project.ProjectNotFoundException) Optional(java.util.Optional) RoleKeys(com.enonic.xp.security.RoleKeys) Context(com.enonic.xp.context.Context) Queue(java.util.Queue) Repository(com.enonic.xp.repository.Repository) EventPublisher(com.enonic.xp.event.EventPublisher) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Callable(java.util.concurrent.Callable) Attachment(com.enonic.xp.attachment.Attachment) ProjectConstants(com.enonic.xp.project.ProjectConstants) ProjectGraphEntry(com.enonic.xp.project.ProjectGraphEntry) ArrayList(java.util.ArrayList) IssueInitializer(com.enonic.xp.core.impl.project.init.IssueInitializer) ProjectRole(com.enonic.xp.project.ProjectRole) CreateAttachments(com.enonic.xp.attachment.CreateAttachments) ProjectName(com.enonic.xp.project.ProjectName) ContentInitializer(com.enonic.xp.core.impl.project.init.ContentInitializer) ModifyProjectIconParams(com.enonic.xp.project.ModifyProjectIconParams) ByteSource(com.google.common.io.ByteSource) PropertyTree(com.enonic.xp.data.PropertyTree) Logger(org.slf4j.Logger) ProjectGraph(com.enonic.xp.project.ProjectGraph) ProjectPermissions(com.enonic.xp.project.ProjectPermissions) PropertySet(com.enonic.xp.data.PropertySet) IOException(java.io.IOException) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) ArrayDeque(java.util.ArrayDeque) Collections(java.util.Collections) ModifyProjectParams(com.enonic.xp.project.ModifyProjectParams) InputStream(java.io.InputStream) Repository(com.enonic.xp.repository.Repository) UpdateRepositoryParams(com.enonic.xp.repository.UpdateRepositoryParams)

Example 2 with ModifyProjectParams

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();
}
Also used : Locale(java.util.Locale) Project(com.enonic.xp.project.Project) ModifyProjectParams(com.enonic.xp.project.ModifyProjectParams) ProjectPermissions(com.enonic.xp.project.ProjectPermissions)

Example 3 with ModifyProjectParams

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;
    });
}
Also used : Project(com.enonic.xp.project.Project) ModifyProjectParams(com.enonic.xp.project.ModifyProjectParams) ProjectName(com.enonic.xp.project.ProjectName) HashMap(java.util.HashMap) ProjectPermissions(com.enonic.xp.project.ProjectPermissions) CreateProjectParams(com.enonic.xp.project.CreateProjectParams)

Aggregations

ModifyProjectParams (com.enonic.xp.project.ModifyProjectParams)3 Project (com.enonic.xp.project.Project)3 ProjectPermissions (com.enonic.xp.project.ProjectPermissions)3 CreateProjectParams (com.enonic.xp.project.CreateProjectParams)2 ProjectName (com.enonic.xp.project.ProjectName)2 Attachment (com.enonic.xp.attachment.Attachment)1 AttachmentSerializer (com.enonic.xp.attachment.AttachmentSerializer)1 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)1 CreateAttachments (com.enonic.xp.attachment.CreateAttachments)1 Context (com.enonic.xp.context.Context)1 ContextAccessor (com.enonic.xp.context.ContextAccessor)1 ContextBuilder (com.enonic.xp.context.ContextBuilder)1 ArchiveInitializer (com.enonic.xp.core.impl.project.init.ArchiveInitializer)1 ContentInitializer (com.enonic.xp.core.impl.project.init.ContentInitializer)1 IssueInitializer (com.enonic.xp.core.impl.project.init.IssueInitializer)1 PropertySet (com.enonic.xp.data.PropertySet)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 EventPublisher (com.enonic.xp.event.EventPublisher)1 ImageHelper (com.enonic.xp.image.ImageHelper)1 IndexService (com.enonic.xp.index.IndexService)1