001/* 002 * Copyright 2016 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.workspaces.project; 017 018import java.util.Map; 019 020import org.apache.avalon.framework.service.ServiceException; 021import org.apache.avalon.framework.service.ServiceManager; 022 023import org.ametys.core.ui.Callable; 024import org.ametys.core.user.UserIdentity; 025import org.ametys.plugins.workspaces.members.ProjectMemberManager; 026import org.ametys.web.administration.SuperUserClientSideElement; 027 028import com.google.common.collect.ImmutableList; 029 030/** 031 * This implementation creates a control allowing to affect a super user to a given context of a project. 032 * This implementation does NOT set the super user on project'site. 033 */ 034public class ProjectSuperUserClientSideElement extends SuperUserClientSideElement 035{ 036 /** The project user manager */ 037 protected ProjectMemberManager _projectUserManager; 038 039 @Override 040 public void service(ServiceManager smanager) throws ServiceException 041 { 042 super.service(smanager); 043 _projectUserManager = (ProjectMemberManager) smanager.lookup(ProjectMemberManager.ROLE); 044 } 045 046 @Override 047 @Callable 048 public void affectUserToProfile(Map<String, String> user, String profileId, Map<String, Object> jsParameters) 049 { 050 UserIdentity userIdentity = new UserIdentity(user.get("login"), user.get("populationId")); 051 _projectUserManager.setProjectManager((String) jsParameters.get("projectName"), profileId, ImmutableList.of(userIdentity)); 052 } 053 054}