[jboss-svn-commits] JBL Code SVN: r34772 - labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Aug 18 06:44:04 EDT 2010
Author: lkrzyzanek
Date: 2010-08-18 06:44:04 -0400 (Wed, 18 Aug 2010)
New Revision: 34772
Removed:
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesUserManager.java
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/NukesUserManager.java
Log:
Upgraded to work with SBS 4.5.x
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesUserManager.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesUserManager.java 2010-08-18 10:43:34 UTC (rev 34771)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesUserManager.java 2010-08-18 10:44:04 UTC (rev 34772)
@@ -1,156 +0,0 @@
-/*
- * JBoss.org http://jboss.org/
- *
- * Copyright (c) 2009 Red Hat Middleware, LLC. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT A WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License, v.2.1 along with this distribution; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- * Red Hat Author(s): Libor Krzyzanek
- */
-package org.jboss.labs.clearspace.plugin.nfm;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.jboss.labs.clearspace.plugin.nfm.dao.NukesForumsDAO;
-import org.jboss.labs.clearspace.plugin.nfm.dao.NukesUserBean;
-
-import com.jivesoftware.base.EmailAlreadyExistsException;
-import com.jivesoftware.base.User;
-import com.jivesoftware.base.UserAlreadyExistsException;
-import com.jivesoftware.base.UserManager;
-import com.jivesoftware.base.UserNotFoundException;
-import com.jivesoftware.base.UserTemplate;
-import com.jivesoftware.community.user.profile.ProfileField;
-import com.jivesoftware.community.user.profile.ProfileFieldManager;
-import com.jivesoftware.community.user.profile.ProfileFieldValue;
-import com.jivesoftware.community.user.profile.ProfileManager;
-
-/**
- * DB Implementation of manager
- *
- * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
- */
-public class DbNukesUserManager implements NukesUserManager {
-
- private static final Logger log = LogManager
- .getLogger(DbNukesUserManager.class);
-
- private NukesForumsDAO nukesForumsDAO;
-
- private UserManager userManager;
-
- private ProfileManager profileManager;
-
- private ProfileFieldManager profileFieldManager;
-
- public User createUserFromNukes(String username)
- throws UserAlreadyExistsException, EmailAlreadyExistsException {
- NukesUserBean nukeUser = nukesForumsDAO.getNukesUser(username);
-
- // Implementation taken from UserImporter service in cs-nukes-login module
- UserTemplate ut = new UserTemplate(username);
- ut.setFederated(true);
-
- ut = mapDetails(ut, nukeUser);
- userManager.createApplicationUser(ut);
-
- // try again to load the user from the details
- // service, this time it should work
- // UserDetails ud = userDetailsService.loadUserByUsername(username);
-
- // update profile
- User u;
- try {
- u = userManager.getUser(nukeUser.getUsername());
- } catch (UserNotFoundException e) {
- throw new RuntimeException(
- "Cannot get user which has been just created. Username: " + username,
- e);
- }
- Set<ProfileFieldValue> pfvSet = new HashSet<ProfileFieldValue>();
-
- Map<String, String> profile = nukeUser.getProfile();
- // map default fields
- mapProfile(profile, pfvSet, profileFieldManager.getDefaultFields());
-
- // map custom fields
- mapProfile(profile, pfvSet, profileFieldManager.getCustomFields());
-
- // create unexisting fields
- if (!profile.isEmpty()) {
-
- for (String key : profile.keySet()) {
- log.info("Couldn't set profile field: " + key);
- }
- }
-
- if (!pfvSet.isEmpty()) {
- profileManager.setProfile(u, pfvSet);
- }
-
- return u;
- }
-
- private void mapProfile(Map<String, String> profile,
- Collection<ProfileFieldValue> pfvSet, List<ProfileField> fields) {
- for (ProfileField pf : fields) {
-
- if (profile.get(pf.getName()) != null) {
- ProfileFieldValue pfv = new ProfileFieldValue(pf);
- pfv.setValue(profile.get(pf.getName()));
-
- pfvSet.add(pfv);
-
- // remove field as added (or not if it was null)
- profile.remove(pf.getName());
- }
- }
- }
-
- private UserTemplate mapDetails(UserTemplate ut, NukesUserBean nukeUser) {
- ut.setEmail(nukeUser.getEmail());
- ut.setFirstName(nukeUser.getFirstName());
- ut.setLastName(nukeUser.getLastName());
- ut.setName(nukeUser.getName());
- ut.setPasswordHash(nukeUser.getPasswordHash());
- ut.setProperties(nukeUser.getProperties());
- ut.setCreationDate(nukeUser.getCreationDate());
-
- return ut;
- }
-
- public void setNukesForumsDAO(NukesForumsDAO nukesForumsDAO) {
- this.nukesForumsDAO = nukesForumsDAO;
- }
-
- public void setUserManager(UserManager userManager) {
- this.userManager = userManager;
- }
-
- public void setProfileManager(ProfileManager profileManager) {
- this.profileManager = profileManager;
- }
-
- public void setProfileFieldManager(ProfileFieldManager profileFieldManager) {
- this.profileFieldManager = profileFieldManager;
- }
-
-}
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/NukesUserManager.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/NukesUserManager.java 2010-08-18 10:43:34 UTC (rev 34771)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/NukesUserManager.java 2010-08-18 10:44:04 UTC (rev 34772)
@@ -1,46 +0,0 @@
-/*
- * JBoss.org http://jboss.org/
- *
- * Copyright (c) 2009 Red Hat Middleware, LLC. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT A WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License, v.2.1 along with this distribution; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- * Red Hat Author(s): Libor Krzyzanek
- */
-package org.jboss.labs.clearspace.plugin.nfm;
-
-import com.jivesoftware.base.EmailAlreadyExistsException;
-import com.jivesoftware.base.User;
-import com.jivesoftware.base.UserAlreadyExistsException;
-
-/**
- * Manager of handling Nukes Users
- *
- * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
- */
-public interface NukesUserManager {
-
- /**
- * Create CS user from nukes user defined by username
- *
- * @param username
- * @return CS user
- * @throws UserAlreadyExistsException
- * @throws EmailAlreadyExistsException
- */
- public User createUserFromNukes(String username)
- throws UserAlreadyExistsException, EmailAlreadyExistsException;
-
-}
More information about the jboss-svn-commits
mailing list