@@ -0,0 +1,3026 @@
+/**%0A * Licensed to Jasig under one or more contributor license%0A * agreements. See the NOTICE file distributed with this work%0A * for additional information regarding copyright ownership.%0A * Jasig licenses this file to you under the Apache License,%0A * Version 2.0 (the %22License%22); you may not use this file%0A * except in compliance with the License. You may obtain a%0A * copy of the License at:%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on%0A * an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0A * KIND, either express or implied. See the License for the%0A * specific language governing permissions and limitations%0A * under the License.%0A */%0Apackage org.jasig.portal.layout.profile;%0A%0Aimport org.jasig.portal.layout.profile.dao.IProfileSelectionDao;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.util.Assert;%0A%0A/**%0A * Trivial implementation of profile selection registry API that relies upon an IProfileSelectionDao.%0A *%0A * Translates between the very simple selections-are-just-plain-old-Strings Registry API and the selections-are-objects%0A * DAO API.%0A * @since uPortal 4.2%0A */%0Apublic class ProfileSelectionRegistry%0A    implements IProfileSelectionRegistry %7B%0A%0A    // autowired%0A    private IProfileSelectionDao profileSelectionDao;%0A%0A    @Override%0A    public String profileSelectionForUser(final String username) %7B%0A%0A        Assert.notNull(username, %22Cannot look up the profile selection for a null username.%22);%0A%0A        final IProfileSelection profileSelection = this.profileSelectionDao.readProfileSelectionForUser(username);%0A%0A        if (null == profileSelection) %7B%0A            return null;%0A        %7D%0A%0A        return profileSelection.getProfileFName();%0A    %7D%0A%0A    @Override%0A    public void registerUserProfileSelection(final String userName, final String profileFName) %7B%0A%0A        Assert.notNull(userName, %22Cannot register a profile selection for a null username.%22);%0A%0A        final IProfileSelection existingSelection = this.profileSelectionDao.readProfileSelectionForUser(userName);%0A%0A        if (null == profileFName) %7B%0A            // null profileFName translates to deleting existing Selection if any%0A%0A            if (null != existingSelection) %7B%0A                this.profileSelectionDao.deleteProfileSelection(existingSelection);%0A            %7D%0A%0A        %7D else %7B%0A            // non-null profileFName translates to creating or updating a Selection.%0A%0A            if (null == existingSelection) %7B%0A                this.profileSelectionDao.createProfileSelection(userName, profileFName);%0A            %7D else %7B%0A                existingSelection.setProfileFName(profileFName);%0A                this.profileSelectionDao.updateProfileSelection(existingSelection);%0A            %7D%0A%0A        %7D%0A%0A    %7D%0A%0A    @Autowired%0A    public void setProfileSelectionDao(final IProfileSelectionDao profileSelectionDao) %7B%0A        this.profileSelectionDao = profileSelectionDao;%0A    %7D%0A%7D%0A

Add ProfileSelectionRegistry.