You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2007/08/19 23:06:42 UTC
svn commit: r567471 [2/4] - in /portals/jetspeed-2/trunk:
components/jetspeed-capability/src/main/java/org/apache/jetspeed/
components/jetspeed-capability/src/main/java/org/apache/jetspeed/serializer/
components/jetspeed-profiler/src/main/java/org/apac...
Added: portals/jetspeed-2/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java?rev=567471&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java (added)
+++ portals/jetspeed-2/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java Sun Aug 19 14:06:38 2007
@@ -0,0 +1,920 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.serializer;
+
+import java.lang.reflect.Constructor;
+import java.security.Permission;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.prefs.Preferences;
+
+import javax.security.auth.Subject;
+
+import org.apache.commons.logging.Log;
+import org.apache.jetspeed.security.BasePrincipal;
+import org.apache.jetspeed.security.FolderPermission;
+import org.apache.jetspeed.security.FragmentPermission;
+import org.apache.jetspeed.security.Group;
+import org.apache.jetspeed.security.GroupManager;
+import org.apache.jetspeed.security.PagePermission;
+import org.apache.jetspeed.security.PasswordCredential;
+import org.apache.jetspeed.security.PermissionManager;
+import org.apache.jetspeed.security.PortalResourcePermission;
+import org.apache.jetspeed.security.PortletPermission;
+import org.apache.jetspeed.security.Role;
+import org.apache.jetspeed.security.RoleManager;
+import org.apache.jetspeed.security.User;
+import org.apache.jetspeed.security.UserManager;
+import org.apache.jetspeed.security.om.InternalPermission;
+import org.apache.jetspeed.security.om.InternalPrincipal;
+import org.apache.jetspeed.security.spi.PasswordCredentialProvider;
+import org.apache.jetspeed.serializer.objects.JSGroup;
+import org.apache.jetspeed.serializer.objects.JSGroups;
+import org.apache.jetspeed.serializer.objects.JSNVPElements;
+import org.apache.jetspeed.serializer.objects.JSPermission;
+import org.apache.jetspeed.serializer.objects.JSRole;
+import org.apache.jetspeed.serializer.objects.JSRoles;
+import org.apache.jetspeed.serializer.objects.JSSnapshot;
+import org.apache.jetspeed.serializer.objects.JSUser;
+import org.apache.jetspeed.serializer.objects.JSUserAttributes;
+import org.apache.jetspeed.serializer.objects.JSUserGroups;
+import org.apache.jetspeed.serializer.objects.JSUserRoles;
+import org.apache.jetspeed.serializer.objects.JSUserUsers;
+import org.apache.jetspeed.serializer.objects.JSUsers;
+
+/**
+ * JetspeedSecuritySerializer - Security component serializer
+ *
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id$
+ */
+public class JetspeedSecuritySerializer extends AbstractJetspeedComponentSerializer
+{
+ private static String ENCODING_STRING = "JETSPEED 2.1 - 2006";
+
+ private static String JETSPEED = "JETSPEED";
+
+ private static class Refs
+ {
+ private HashMap roleMap = new HashMap();
+
+ private HashMap groupMap = new HashMap();
+
+ private HashMap userMap = new HashMap();
+
+ private HashMap permissionMap = new HashMap();
+ }
+
+ protected GroupManager groupManager;
+
+ protected RoleManager roleManager;
+
+ protected UserManager userManager;
+
+ protected PasswordCredentialProvider pcp;
+
+ protected PermissionManager pm;
+
+ public JetspeedSecuritySerializer(GroupManager groupManager, RoleManager roleManager, UserManager userManager,
+ PasswordCredentialProvider pcp, PermissionManager pm)
+ {
+ this.groupManager = groupManager;
+ this.roleManager = roleManager;
+ this.userManager = userManager;
+ this.pcp = pcp;
+ this.pm = pm;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jetspeed.serializer.JetspeedComponentSerializer#processExport(org.apache.jetspeed.serializer.objects.JSSnapshot,
+ * java.util.Map, org.apache.commons.logging.Log)
+ */
+ protected void processExport(JSSnapshot snapshot, Map settings, Log log) throws SerializerException
+ {
+ if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_USERS))
+ {
+ log.info("collecting users/roles/groups and permissions");
+ Refs refs = new Refs();
+ exportRolesGroupsUsers(refs, snapshot, settings, log);
+ exportPermissions(refs, snapshot, settings, log);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jetspeed.serializer.JetspeedComponentSerializer#processImport(org.apache.jetspeed.serializer.objects.JSSnapshot,
+ * java.util.Map, org.apache.commons.logging.Log)
+ */
+ protected void processImport(JSSnapshot snapshot, Map settings, Log log) throws SerializerException
+ {
+ if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_USERS))
+ {
+ log.info("creating users/roles/groups and permissions");
+ Refs refs = new Refs();
+ recreateRolesGroupsUsers(refs, snapshot, settings, log);
+ recreatePermissions(refs, snapshot, settings, log);
+ }
+ }
+
+ protected void deleteData(Map settings, Log log) throws SerializerException
+ {
+ if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_USERS))
+ {
+ log.info("deleting users/roles/groups and permissions");
+ try
+ {
+ Iterator _it = pm.getPermissions().iterator();
+ while ( _it.hasNext() )
+ {
+ InternalPermission ip = (InternalPermission)_it.next();
+ Class permissionClass = Class.forName(ip.getClassname());
+ Class[] parameterTypes = { String.class, String.class };
+ Constructor permissionConstructor = permissionClass.getConstructor(parameterTypes);
+ Object[] initArgs = { ip.getName(), ip.getActions() };
+ Permission permission = (Permission) permissionConstructor.newInstance(initArgs);
+ pm.removePermission(permission);
+ }
+
+ String anonymousUser = userManager.getAnonymousUser();
+ _it = userManager.getUserNames("");
+ while (_it.hasNext())
+ {
+ String userName = (String)_it.next();
+ if ( !anonymousUser.equals(userName) )
+ {
+ userManager.removeUser((String)_it.next());
+ }
+ }
+
+ _it = groupManager.getGroups("");
+ while (_it.hasNext())
+ {
+ groupManager.removeGroup(((Group)_it.next()).getPrincipal().getName());
+ }
+
+ _it = roleManager.getRoles("");
+ while (_it.hasNext())
+ {
+ roleManager.removeRole(((Role)_it.next()).getPrincipal().getName());
+ }
+ }
+ catch (Exception e)
+ {
+ throw new SerializerException(e);
+ }
+ }
+ }
+
+ /**
+ * import the groups, roles and finally the users to the current environment
+ *
+ * @throws SerializerException
+ */
+ private void recreateRolesGroupsUsers(Refs refs, JSSnapshot snapshot, Map settings, Log log)
+ throws SerializerException
+ {
+ log.debug("recreateRolesGroupsUsers");
+
+ JSGroups groups = null;
+ JSRoles roles = null;
+
+ groups = snapshot.getGroups();
+
+ Iterator _it = groups.iterator();
+ while (_it.hasNext())
+ {
+ String name = ((JSGroup) _it.next()).getName();
+
+ try
+ {
+ if (!(groupManager.groupExists(name)))
+ groupManager.addGroup(name);
+ Group group = groupManager.getGroup(name);
+ refs.groupMap.put(name, group.getPrincipal());
+ }
+ catch (Exception e)
+ {
+ throw new SerializerException(SerializerException.CREATE_OBJECT_FAILED.create(new String[] { "Group",
+ e.getMessage() }));
+ }
+ }
+ log.debug("recreateGroups - done");
+ log.debug("processing roles");
+
+ roles = snapshot.getRoles();
+
+ _it = roles.iterator();
+ while (_it.hasNext())
+ {
+ String name = ((JSRole) _it.next()).getName();
+
+ try
+ {
+ if (!(roleManager.roleExists(name)))
+ roleManager.addRole(name);
+ Role role = roleManager.getRole(name);
+ refs.roleMap.put(name, role.getPrincipal());
+ }
+ catch (Exception e)
+ {
+ throw new SerializerException(SerializerException.CREATE_OBJECT_FAILED.create(new String[] { "Role",
+ e.getMessage() }));
+ }
+ }
+ log.debug("recreateRoles - done");
+ log.debug("processing users");
+
+ /** determine whether passwords can be reconstructed or not */
+ int passwordEncoding = compareCurrentSecurityProvider(snapshot);
+ JSUsers users = null;
+ users = snapshot.getUsers();
+
+ _it = users.iterator();
+ while (_it.hasNext())
+ {
+
+ JSUser jsuser = (JSUser) _it.next();
+
+ try
+ {
+ User user = null;
+ if (userManager.userExists(jsuser.getName()))
+ {
+ user = userManager.getUser(jsuser.getName());
+ }
+ if ((isSettingSet(settings, JetspeedSerializer.KEY_OVERWRITE_EXISTING)) || (user == null))
+ {
+ if (user == null) // create new one
+ {
+ String password = recreatePassword(jsuser.getPassword());
+ log.debug("add User " + jsuser.getName() + " with password " + password);
+ userManager.importUser(jsuser.getName(), password,
+ (passwordEncoding == JetspeedSerializer.PASSTHRU_REQUIRED));
+ log.debug("add User done ");
+ user = userManager.getUser(jsuser.getName());
+ }
+ try
+ {
+ userManager.setPasswordEnabled(jsuser.getName(), jsuser.getPwEnabled());
+ userManager.setPasswordUpdateRequired(jsuser.getName(), jsuser.getPwRequiredUpdate());
+ java.sql.Date d = jsuser.getPwExpirationDate();
+ if (d != null)
+ userManager.setPasswordExpiration(jsuser.getName(), d);
+ }
+ catch (Exception e)
+ {
+ // most likely caused by protected users (like "guest")
+ log.debug("setting userinfo for " + jsuser.getName() + " failed because of "
+ + e.getLocalizedMessage());
+ }
+
+ // credentials
+ Subject subject = user.getSubject();
+
+ ArrayList listTemp = jsuser.getPrivateCredentials();
+ if ((listTemp != null) && (listTemp.size() > 0))
+ {
+ Iterator _itTemp = listTemp.iterator();
+ while (_itTemp.hasNext())
+ {
+ subject.getPrivateCredentials().add(_itTemp.next());
+ }
+ }
+ listTemp = jsuser.getPublicCredentials();
+ if ((listTemp != null) && (listTemp.size() > 0))
+ {
+ Iterator _itTemp = listTemp.iterator();
+ while (_itTemp.hasNext())
+ {
+ subject.getPublicCredentials().add(_itTemp.next());
+ }
+ }
+ JSUserGroups jsUserGroups = jsuser.getGroupString();
+ if (jsUserGroups != null)
+ listTemp = getTokens(jsUserGroups.toString());
+ else
+ listTemp = null;
+ if ((listTemp != null) && (listTemp.size() > 0))
+ {
+ Iterator _itTemp = listTemp.iterator();
+ while (_itTemp.hasNext())
+ {
+ groupManager.addUserToGroup(jsuser.getName(), (String) _itTemp.next());
+ }
+ }
+ JSUserRoles jsUserRoles = jsuser.getRoleString();
+ if (jsUserRoles != null)
+ listTemp = getTokens(jsUserRoles.toString());
+ else
+ listTemp = null;
+ if ((listTemp != null) && (listTemp.size() > 0))
+ {
+ Iterator _itTemp = listTemp.iterator();
+ while (_itTemp.hasNext())
+ {
+ roleManager.addRoleToUser(jsuser.getName(), (String) _itTemp.next());
+ }
+ }
+ JSUserAttributes attributes = jsuser.getUserInfo();
+ if (attributes != null)
+ {
+ Preferences userAttributes = user.getUserAttributes();
+ HashMap map = attributes.getMyMap();
+ if (map != null)
+ {
+ Iterator _itTemp = map.keySet().iterator();
+ while (_itTemp.hasNext())
+ {
+ String userAttrName = (String) _itTemp.next();
+ // if ( userAttributes.get(userAttrName,
+ // "").equals("")
+ String userAttrValue = (String) map.get(userAttrName);
+ userAttributes.put(userAttrName, userAttrValue);
+ }
+ }
+
+ }
+
+ JSNVPElements jsNVP = jsuser.getPreferences();
+ if ((jsNVP != null) && (jsNVP.getMyMap() != null))
+ {
+ Preferences preferences = user.getPreferences();
+ Iterator _itTemp = jsNVP.getMyMap().keySet().iterator();
+ while (_itTemp.hasNext())
+ {
+ String prefKey = (String) _itTemp.next();
+ String prefValue = (String) (jsNVP.getMyMap().get(prefKey));
+ preferences.put(prefKey, prefValue);
+ }
+ }
+
+ refs.userMap.put(jsuser.getName(), getUserPrincipal(user));
+
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new SerializerException(SerializerException.CREATE_OBJECT_FAILED.create(new String[] { "User",
+ e.getMessage() }));
+ }
+ }
+ log.debug("recreateUsers - done");
+ }
+
+ /**
+ * recreates all permissions from the current snapshot
+ *
+ * @throws SerializerException
+ */
+ private void recreatePermissions(Refs refs, JSSnapshot snapshot, Map settings, Log log) throws SerializerException
+ {
+ log.debug("recreatePermissions - started");
+
+ Iterator list = null;
+ try
+ {
+ list = snapshot.getPermissions().iterator();
+ }
+ catch (Exception e)
+ {
+ throw new SerializerException(SerializerException.GET_EXISTING_OBJECTS.create(new String[] { "Permissions",
+ e.getMessage() }));
+ }
+
+ while (list.hasNext())
+ {
+ JSPermission _js = (JSPermission) list.next();
+ PortalResourcePermission perm = getPermissionForType(_js);
+ if ((perm != null) && (perm instanceof PortalResourcePermission))
+ {
+ try
+ {
+ pm.addPermission(perm);
+ ArrayList listTemp = null;
+ JSUserGroups jsUserGroups = _js.getGroupString();
+ if (jsUserGroups != null)
+ listTemp = getTokens(jsUserGroups.toString());
+ else
+ listTemp = null;
+ if ((listTemp != null) && (listTemp.size() > 0))
+ {
+ Iterator _itTemp = listTemp.iterator();
+ while (_itTemp.hasNext())
+ {
+ Principal p = (Principal) refs.groupMap.get((String) _itTemp.next());
+ if (p != null)
+ pm.grantPermission(p, perm);
+ }
+ }
+ JSUserRoles jsUserRoles = _js.getRoleString();
+ if (jsUserRoles != null)
+ listTemp = getTokens(jsUserRoles.toString());
+ else
+ listTemp = null;
+ if ((listTemp != null) && (listTemp.size() > 0))
+ {
+ Iterator _itTemp = listTemp.iterator();
+ while (_itTemp.hasNext())
+ {
+ Principal p = (Principal) refs.roleMap.get((String) _itTemp.next());
+ if (p != null)
+ pm.grantPermission(p, perm);
+ }
+ }
+ JSUserUsers jsUserUsers = _js.getUserString();
+ if (jsUserUsers != null)
+ listTemp = getTokens(jsUserUsers.toString());
+ else
+ listTemp = null;
+ if ((listTemp != null) && (listTemp.size() > 0))
+ {
+ Iterator _itTemp = listTemp.iterator();
+ while (_itTemp.hasNext())
+ {
+ Principal p = (Principal) refs.userMap.get((String) _itTemp.next());
+ if (p != null)
+ pm.grantPermission(p, perm);
+ }
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new SerializerException(SerializerException.CREATE_SERIALIZED_OBJECT_FAILED
+ .create(new String[] { "Permissions", e.getMessage() }));
+ }
+ }
+ }
+ log.debug("recreatePermissions - done");
+ }
+
+ private PortalResourcePermission getPermissionForType(JSPermission _js)
+ {
+ PortalResourcePermission newPermission = null;
+ if ((_js.getType() == null) || (_js.getType() == JSPermission.TYPE_UNKNOWN))
+ return null;
+ try
+ {
+ if (_js.getType().equals(JSPermission.TYPE_FOLDER))
+ newPermission = new FolderPermission(_js.getResource(),_js.getActions());
+ else if (_js.getType().equals(JSPermission.TYPE_FRAGMENT))
+ newPermission = new FragmentPermission(_js.getResource(),_js.getActions());
+ else if (_js.getType().equals(JSPermission.TYPE_PAGE))
+ newPermission = new PagePermission(_js.getResource(),_js.getActions());
+ else if (_js.getType().equals(JSPermission.TYPE_PORTAL))
+ newPermission = new PortletPermission(_js.getResource(),_js.getActions());
+ else return null;
+ return newPermission;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * Establish whether incoming passwords are "clear" text or whether they are
+ * to be decoded. That however depends on whether the passwords were encoded
+ * with the current active provider or not.
+ *
+ * @return
+ */
+ protected int compareCurrentSecurityProvider(JSSnapshot snapshot)
+ {
+ String _fileEncryption = snapshot.getEncryption();
+ if ((_fileEncryption == null) || (_fileEncryption.length() == 0))
+ return JetspeedSerializer.NO_DECODING; // passwords are in clear
+ // text
+
+ if (_fileEncryption.equals(getEncryptionString()))
+ return JetspeedSerializer.PASSTHRU_REQUIRED;
+ else
+ return JetspeedSerializer.NO_DECODING;
+ }
+
+ private String getEncryptionString()
+ {
+ if (pcp == null)
+ {
+ System.err.println("Error!!! PasswordCredentialProvider not available");
+ return ENCODING_STRING;
+ }
+ try
+ {
+ PasswordCredential credential = pcp.create(JETSPEED, ENCODING_STRING);
+ if ((credential != null) && (credential.getPassword() != null))
+ return new String(credential.getPassword());
+ else
+ return ENCODING_STRING;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ return ENCODING_STRING;
+ }
+ }
+
+ protected String recreatePassword(char[] savedPassword)
+ {
+ if (savedPassword == null)
+ return null;
+ return new String(savedPassword);
+ }
+
+ private Principal getUserPrincipal(User user)
+ {
+ Subject subject = user.getSubject();
+ // get the user principal
+ Set principals = subject.getPrincipals();
+ Iterator list = principals.iterator();
+ while (list.hasNext())
+ {
+ BasePrincipal principal = (BasePrincipal) list.next();
+ String path = principal.getFullPath();
+ if (path.startsWith("/user/"))
+ return principal;
+ }
+ return null;
+ }
+
+ /**
+ * Collect all the roles, groups and users from the current environment.
+ * Include the current SecurityProvider to understand, whether the password
+ * collected can be used upon import
+ *
+ * @throws SerializerException
+ */
+ private void exportRolesGroupsUsers(Refs refs, JSSnapshot snapshot, Map settings, Log log)
+ throws SerializerException
+ {
+ /** set the security provider info in the snapshot file */
+ snapshot.setEncryption(getEncryptionString());
+ /** get the roles */
+
+ Iterator list = null;
+ try
+ {
+ list = roleManager.getRoles("");
+ }
+ catch (Exception e)
+ {
+ throw new SerializerException(SerializerException.GET_EXISTING_OBJECTS.create(new String[] { "Role",
+ e.getMessage() }));
+ }
+ while (list.hasNext())
+ {
+ try
+ {
+ Role role = (Role) list.next();
+ JSRole _tempRole = (JSRole) getObjectBehindPrinicpal(refs.roleMap,
+ (BasePrincipal) (role.getPrincipal()));
+ if (_tempRole == null)
+ {
+ _tempRole = createJSRole(role);
+ refs.roleMap.put(_tempRole.getName(), _tempRole);
+ snapshot.getRoles().add(_tempRole);
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new SerializerException(SerializerException.CREATE_SERIALIZED_OBJECT_FAILED.create(new String[] {
+ "Role", e.getMessage() }));
+ }
+ }
+
+ /** get the groups */
+ try
+ {
+ list = groupManager.getGroups("");
+ }
+ catch (Exception e)
+ {
+ throw new SerializerException(SerializerException.GET_EXISTING_OBJECTS.create(new String[] { "Group",
+ e.getMessage() }));
+ }
+ while (list.hasNext())
+ {
+
+ try
+ {
+ Group group = (Group) list.next();
+ JSGroup _tempGroup = (JSGroup) getObjectBehindPrinicpal(refs.groupMap, (BasePrincipal) (group
+ .getPrincipal()));
+ if (_tempGroup == null)
+ {
+ _tempGroup = createJSGroup(group);
+ refs.groupMap.put(_tempGroup.getName(), _tempGroup);
+ snapshot.getGroups().add(_tempGroup);
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new SerializerException(SerializerException.CREATE_SERIALIZED_OBJECT_FAILED.create(new String[] {
+ "Group", e.getMessage() }));
+ }
+ }
+
+ /** users */
+ try
+ {
+ list = userManager.getUsers("");
+ }
+ catch (Exception e)
+ {
+ throw new SerializerException(SerializerException.GET_EXISTING_OBJECTS.create(new String[] { "User",
+ e.getMessage() }));
+ }
+ while (list.hasNext())
+ {
+
+ try
+ {
+ User _user = (User) list.next();
+ JSUser _tempUser = createJSUser(refs, _user);
+ refs.userMap.put(_tempUser.getName(), _tempUser);
+ snapshot.getUsers().add(_tempUser);
+ }
+ catch (Exception e)
+ {
+ throw new SerializerException(SerializerException.CREATE_SERIALIZED_OBJECT_FAILED.create(new String[] {
+ "User", e.getMessage() }));
+ }
+
+ }
+ return;
+
+ }
+
+ /**
+ * extract all permissions from the current environment
+ *
+ * @throws SerializerException
+ */
+ private void exportPermissions(Refs refs, JSSnapshot snapshot, Map settings, Log log) throws SerializerException
+ {
+ Object o = null;
+
+ Iterator list = null;
+ try
+ {
+ list = pm.getPermissions().iterator();
+ }
+ catch (Exception e)
+ {
+ throw new SerializerException(SerializerException.GET_EXISTING_OBJECTS.create(new String[] { "Permissions",
+ e.getMessage() }));
+ }
+
+ while (list.hasNext())
+ {
+ try
+ {
+ JSPermission _js = new JSPermission();
+
+ InternalPermission p = (InternalPermission) list.next();
+ _js.setResource(p.getName());
+ _js.setActions(p.getActions());
+ _js.setId(p.getPermissionId());
+ _js.setType(_js.getTypeForClass(p.getClassname()));
+
+ Iterator list2 = p.getPrincipals().iterator();
+ while (list2.hasNext())
+ {
+ o = list2.next();
+ InternalPrincipal principal = (InternalPrincipal) o;
+ String path = principal.getFullPath();
+ if (path.startsWith("/role/"))
+ {
+ JSRole _tempRole = (JSRole) this.getObjectBehindPath(refs.roleMap, removeFromString(path,
+ "/role/"));
+ if (_tempRole != null)
+ {
+ _js.addRole(_tempRole);
+ }
+
+ }
+ else
+ {
+ if (path.startsWith("/group/"))
+ {
+ JSGroup _tempGroup = (JSGroup) this.getObjectBehindPath(refs.groupMap, removeFromString(
+ path, "/group/"));
+ if (_tempGroup != null)
+ {
+ _js.addGroup(_tempGroup);
+ }
+
+ }
+ else
+ {
+ if (path.startsWith("/user/"))
+ {
+ JSUser _tempUser = (JSUser) this.getObjectBehindPath(refs.userMap, removeFromString(
+ path, "/user/"));
+ if (_tempUser != null)
+ {
+ _js.addUser(_tempUser);
+ }
+
+ }
+
+ }
+
+ }
+ }
+ refs.permissionMap.put(_js.getType(), _js);
+ snapshot.getPermissions().add(_js);
+
+ }
+ catch (Exception e)
+ {
+ throw new SerializerException(SerializerException.CREATE_SERIALIZED_OBJECT_FAILED.create(new String[] {
+ "Permissions", e.getMessage() }));
+ }
+ }
+ return;
+
+ }
+
+ /**
+ * simple lookup for principal object from a map
+ *
+ * @param map
+ * @param _fullPath
+ * @return
+ */
+
+ private Object getObjectBehindPrinicpal(Map map, BasePrincipal _principal)
+ {
+ return getObjectBehindPath(map, _principal.getFullPath());
+ }
+
+ /**
+ * simple lookup for object from a map
+ *
+ * @param map
+ * @param _fullPath
+ * @return
+ */
+ protected final Object getObjectBehindPath(Map map, String _fullPath)
+ {
+ return map.get(_fullPath);
+ }
+
+ /**
+ * remove a given sequence from the beginning of a string
+ */
+ protected final String removeFromString(String base, String excess)
+ {
+ return base.replaceFirst(excess, "").trim();
+ }
+
+ /**
+ * create a serializable wrapper for role
+ *
+ * @param role
+ * @return
+ */
+ private JSRole createJSRole(Role role)
+ {
+ JSRole _role = new JSRole();
+ _role.setName(role.getPrincipal().getName());
+ return _role;
+ }
+
+ /**
+ * create a wrapper JSGroup object
+ */
+ private JSGroup createJSGroup(Group group)
+ {
+ JSGroup _group = new JSGroup();
+ _group.setName(group.getPrincipal().getName());
+ return _group;
+ }
+
+ /**
+ * Add the credentials to the JSUser object.
+ * <p>
+ * If the credential provided is a PasswordCredential, userid and password
+ * are extracted and set explcitely
+ *
+ * @param isPublic
+ * public or private credential
+ * @param newUser
+ * the JS user object reference
+ * @param credential
+ * the credential object
+ */
+
+ private void addJSUserCredentials(boolean isPublic, JSUser newUser, Object credential)
+ {
+ if (credential == null)
+ return;
+ if (credential instanceof PasswordCredential)
+ {
+ PasswordCredential pw = (PasswordCredential) credential;
+ newUser.setUserCredential(pw.getUserName(), pw.getPassword(), pw.getExpirationDate(), pw.isEnabled(), pw
+ .isExpired(), pw.isUpdateRequired());
+ return;
+ }
+ else if (isPublic)
+ newUser.addPublicCredential(credential);
+ else
+ newUser.addPrivateCredential(credential);
+ }
+
+ /**
+ * create a new JSUser object
+ *
+ * @param user
+ * @return a new JSUser object
+ */
+ private JSUser createJSUser(Refs refs, User user)
+ {
+ JSUser _newUser = new JSUser();
+
+ Subject subject = user.getSubject();
+ // get the user principal
+ Set principals = subject.getPrincipals();
+ Iterator list = principals.iterator();
+ while (list.hasNext())
+ {
+ BasePrincipal principal = (BasePrincipal) list.next();
+ String path = principal.getFullPath();
+ if (path.startsWith("/role/"))
+ {
+ JSRole _tempRole = (JSRole) this.getObjectBehindPath(refs.roleMap, principal.getName());
+ if (_tempRole != null)
+ {
+ _newUser.addRole(_tempRole);
+ }
+
+ }
+ else
+ {
+ if (path.startsWith("/group/"))
+ {
+ JSGroup _tempGroup = (JSGroup) this.getObjectBehindPath(refs.groupMap, principal.getName());
+ if (_tempGroup != null)
+ {
+ _newUser.addGroup(_tempGroup);
+ }
+
+ }
+ else if (path.startsWith("/user/"))
+ _newUser.setPrincipal(principal);
+
+ }
+
+ }
+ // System.out.println("User Public Credentials");
+ Set credentials = subject.getPublicCredentials();
+ list = credentials.iterator();
+ while (list.hasNext())
+ {
+ Object credential = list.next();
+ addJSUserCredentials(true, _newUser, credential);
+ }
+ // System.out.println("User Private Credentials");
+ credentials = subject.getPrivateCredentials();
+ list = credentials.iterator();
+ while (list.hasNext())
+ {
+ Object credential = list.next();
+ addJSUserCredentials(false, _newUser, credential);
+ }
+
+ Preferences preferences = user.getPreferences();
+ _newUser.setPreferences(preferences);
+ preferences = user.getUserAttributes();
+ _newUser.setUserInfo(preferences);
+ // TODO: HJB, fix preferences...userinfo doesn't return values in
+ // prefs_property_value (in fact preferences.keys() is []
+ return _newUser;
+ }
+}
Propchange: portals/jetspeed-2/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/jetspeed-2/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: portals/jetspeed-2/trunk/components/jetspeed-serializer/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-serializer/pom.xml?rev=567471&r1=567470&r2=567471&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-serializer/pom.xml (original)
+++ portals/jetspeed-2/trunk/components/jetspeed-serializer/pom.xml Sun Aug 19 14:06:38 2007
@@ -74,15 +74,6 @@
<groupId>ddlutils</groupId>
<artifactId>ddlutils</artifactId>
</dependency>
- <!-- TODO Ate: these deps need to go away -->
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>jetspeed-rdbms</artifactId>
- </dependency>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>jetspeed-registry</artifactId>
- </dependency>
<!-- Runtime Dependencies -->
<dependency>
Propchange: portals/jetspeed-2/trunk/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Aug 19 14:06:38 2007
@@ -1,2 +1,2 @@
-target
+target
surefire*.properties
Added: portals/jetspeed-2/trunk/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/AbstractJetspeedComponentSerializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/AbstractJetspeedComponentSerializer.java?rev=567471&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/AbstractJetspeedComponentSerializer.java (added)
+++ portals/jetspeed-2/trunk/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/AbstractJetspeedComponentSerializer.java Sun Aug 19 14:06:38 2007
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.serializer;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.apache.commons.logging.Log;
+import org.apache.jetspeed.serializer.objects.JSSnapshot;
+
+/**
+ * Base class for JetspeedComponentSerializer implementations
+ *
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id$
+ */
+public abstract class AbstractJetspeedComponentSerializer implements JetspeedComponentSerializer
+{
+ public void deleteData(Map settings) throws SerializerException
+ {
+ deleteData(settings, (Log)settings.get(JetspeedSerializer.KEY_LOGGER));
+ }
+
+ public void processExport(JetspeedSerializedData data, Map settings) throws SerializerException
+ {
+ processExport((JSSnapshot)data, settings, (Log)settings.get(JetspeedSerializer.KEY_LOGGER));
+ }
+
+ public void processImport(JetspeedSerializedData data, Map settings) throws SerializerException
+ {
+ processImport((JSSnapshot)data, settings, (Log)settings.get(JetspeedSerializer.KEY_LOGGER));
+ }
+
+ protected abstract void deleteData(Map settings, Log log) throws SerializerException;
+
+ protected abstract void processExport(JSSnapshot data, Map settings, Log log) throws SerializerException;
+
+ protected abstract void processImport(JSSnapshot data, Map settings, Log log) throws SerializerException;
+
+ /**
+ * returns if the key for a particular setting is true. False if the key
+ * doesn't exist.
+ *
+ * @param key
+ * @return
+ */
+ protected static boolean isSettingSet(Map settings, String key)
+ {
+ if ( settings != null )
+ {
+ Object o = settings.get(key);
+ if ( o != null && o instanceof Boolean )
+ {
+ return ((Boolean)o).booleanValue();
+ }
+ }
+ return false;
+ }
+
+ /**
+ * convert a list of elements in a string, seperated by ',' into an
+ * arraylist of strings
+ *
+ * @param _line
+ * Strinbg containing one or more elements seperated by ','
+ * @return list of elements of null
+ */
+ protected static final ArrayList getTokens(String _line)
+ {
+ if ((_line == null) || (_line.length() == 0))
+ return null;
+
+ StringTokenizer st = new StringTokenizer(_line, ",");
+ ArrayList list = new ArrayList();
+
+ while (st.hasMoreTokens())
+ list.add(st.nextToken());
+ return list;
+ }
+}
Propchange: portals/jetspeed-2/trunk/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/AbstractJetspeedComponentSerializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/trunk/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/AbstractJetspeedComponentSerializer.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/jetspeed-2/trunk/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/AbstractJetspeedComponentSerializer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: portals/jetspeed-2/trunk/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializerApplication.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializerApplication.java?rev=567471&r1=567470&r2=567471&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializerApplication.java (original)
+++ portals/jetspeed-2/trunk/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializerApplication.java Sun Aug 19 14:06:38 2007
@@ -16,17 +16,6 @@
*/
package org.apache.jetspeed.serializer;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.jetspeed.components.jndi.SpringJNDIStarter;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
/**
* Jetspeed Serializer Application
*
@@ -70,447 +59,11 @@
* </p>
*
* @author <a href="mailto:hajo@bluesunrise.com">Hajo Birthelmer</a>
- * @version $Id: $
+ * @version $Id$
*/
public class JetspeedSerializerApplication
{
- public static final String JNDI_DS_NAME = "jetspeed";
-
- public static void main(String[] args)
- {
- String propertyFileName = null;
-
- String fileName = null; // XML filename - mandatory on command line
- String applicationPath = null; // configuration.getProperties("applicationPath");
- String bootConfigFiles = null; // configuration.getProperties("bootConfigFiles");
- String configFiles = null; // configuration.getProperties("configFiles");
-
- String name = null;
-
- String options = null;
-
- PropertiesConfiguration configuration = null;
-
- String defaultIndent = null;
-
- String driverClass = null; // jdbc driver
- String url = null; // jdbc url to database
- String user = null; // user
- String password = null; // password
-
- String logLevel = null;
-
- boolean doImport = false;
- boolean doExport = false;
-
- if (args == null)
- throw new IllegalArgumentException("Either import or export have to be defined (-I or -E follwoed by the filename");
-
-
- // Parse all the command-line arguments
- for (int n = 0; n < args.length; n++)
- {
- if (args[n].equals("-p"))
- propertyFileName = args[++n];
- else if (args[n].equals("-a"))
- applicationPath = args[++n];
- else if (args[n].equals("-b"))
- bootConfigFiles = args[++n];
- else if (args[n].equals("-c"))
- configFiles = args[++n];
- else if (args[n].equals("-E"))
- {
- doExport = true;
- fileName = args[++n];
- }
- else if (args[n].equals("-I"))
- {
- doImport = true;
- fileName = args[++n];
- }
- else if (args[n].equals("-N"))
- {
- name = args[++n];
- }
- else if (args[n].equals("-l"))
- logLevel = args[++n];
- else if (args[n].equals("-O"))
- options = args[++n];
- else if (args[n].equals("-dc"))
- driverClass = args[++n];
- else if (args[n].equals("-ds"))
- url = args[++n];
- else if (args[n].equals("-du"))
- {
- if (((n + 1) >= args.length) || args[n + 1].startsWith("-d"))
- {
- user = "";
- } else
- {
- user = args[++n];
- }
- }
- else if (args[n].equals("-dp"))
- {
- if (((n + 1) >= args.length) || args[n + 1].startsWith("-d"))
- {
- password = "";
- } else
- {
- password = args[++n];
- }
- }
- else
- {
- throw new IllegalArgumentException("Unknown argument: "
- + args[n]);
- }
- }
-
- /** The only required argument is the filename for either export or import*/
- if ((!doImport) && (!doExport))
- throw new IllegalArgumentException("Either import or export have to be defined (-I or -E follwoed by the filename");
-
- /** But not both*/
- if ((doImport) && (doExport))
- throw new IllegalArgumentException("Only one - either import or export - can be requested");
-
- if (name == null) name = fileName;
-
- /** get system property definition */
- if (propertyFileName == null)
- propertyFileName = System.getProperty(
- "org.apache.jetspeed.xml.importer.configuration",
- null);
-
- if (propertyFileName != null)
- {
- try
- {
- configuration = new PropertiesConfiguration(propertyFileName);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- System.exit(1);
- }
- if (configuration != null)
- {
- /** only read what was not defined on the command line */
-
- if (applicationPath == null)
- applicationPath = configuration.getString("applicationPath");
- if (bootConfigFiles == null)
- bootConfigFiles = configuration.getString("bootConfigFiles");
- if (configFiles == null)
- configFiles = configuration.getString("configFiles");
- if (options == null)
- options = configuration.getString("options");
- if (defaultIndent == null)
- defaultIndent = configuration.getString("defaultIndent");
-
- if (driverClass == null)
- driverClass = configuration.getString("driverClass");
- if (url == null)
- url = configuration.getString("url");
- if (user == null)
- user = configuration.getString("user");
- if (password == null)
- password = configuration.getString("password");
- if (logLevel == null)
- logLevel = configuration.getString("loglevel");
-
-
- }
- }
-
- // if we still miss some settings, use hardoced defaults
- if (applicationPath == null)
- applicationPath = "./";
- if (bootConfigFiles == null)
- bootConfigFiles = "assembly/boot/";
- if (configFiles == null)
- configFiles = "assembly/";
- if (logLevel == null)
- logLevel = "ERROR";
-
-
- bootConfigFiles = bootConfigFiles + "*.xml";
- configFiles = configFiles + "*.xml";
-
- // ok - we are ready to rumble....
-
- /** create the instruction map */
-
- Map settings = null;
- int processHelper = 1; // default process SEED
- if (options != null)
- {
- settings = new HashMap();
- settings.put(JetspeedSerializer.KEY_PROCESS_USERS, Boolean.FALSE);
- settings.put(JetspeedSerializer.KEY_PROCESS_CAPABILITIES, Boolean.FALSE);
- settings.put(JetspeedSerializer.KEY_PROCESS_PROFILER, Boolean.FALSE);
- settings.put(JetspeedSerializer.KEY_PROCESS_USER_PREFERENCES, Boolean.FALSE);
- settings.put(JetspeedSerializer.KEY_OVERWRITE_EXISTING, Boolean.TRUE);
- settings.put(JetspeedSerializer.KEY_BACKUP_BEFORE_PROCESS, Boolean.FALSE);
- String[] optionSet = getTokens(options);
-
- processHelper = 0;
-
- for (int i = 0; i < optionSet.length; i++)
- {
- String o = optionSet[i];
- if (o.equalsIgnoreCase("all"))
- {
- settings.put(JetspeedSerializer.KEY_PROCESS_USERS, Boolean.TRUE);
- settings.put(JetspeedSerializer.KEY_PROCESS_CAPABILITIES, Boolean.TRUE);
- settings.put(JetspeedSerializer.KEY_PROCESS_PROFILER, Boolean.TRUE);
- settings.put(JetspeedSerializer.KEY_PROCESS_USER_PREFERENCES, Boolean.FALSE);
- processHelper = 1;
- }
- else
- if (o.equalsIgnoreCase("user"))
- {
- settings.put(JetspeedSerializer.KEY_PROCESS_USERS, Boolean.TRUE);
- processHelper = 1;
- }
- else
- if (o.equalsIgnoreCase("PREFS"))
- {
- settings.put(JetspeedSerializer.KEY_PROCESS_USER_PREFERENCES, Boolean.TRUE);
- processHelper = 2;
- }
- else
- if (o.equalsIgnoreCase("CAPABILITIES"))
- {
- settings.put(JetspeedSerializer.KEY_PROCESS_CAPABILITIES, Boolean.TRUE);
- processHelper = 1;
- }
- else
- if (o.equalsIgnoreCase("PROFILE"))
- {
- settings.put(JetspeedSerializer.KEY_PROCESS_PROFILER, Boolean.TRUE);
- processHelper = 1;
- }
- else
- if (o.equalsIgnoreCase("NOOVERWRITE"))
- settings.put(JetspeedSerializer.KEY_OVERWRITE_EXISTING, Boolean.FALSE);
- else
- if (o.equalsIgnoreCase("BACKUP"))
- settings.put(JetspeedSerializer.KEY_BACKUP_BEFORE_PROCESS, Boolean.TRUE);
-
- }
-
- }
- JetspeedSerializer serializer = null;
-
- if (driverClass == null)
- driverClass = System.getProperty(
- "org.apache.jetspeed.database.driverClass",
- "com.mysql.jdbc.Driver");
- if (url == null)
- url = System.getProperty("org.apache.jetspeed.database.url",
- "jdbc:mysql://localhost/j2test");
- if (user == null)
- user = System.getProperty("org.apache.jetspeed.database.user",
- "user");
- if (password == null)
- password = System.getProperty(
- "org.apache.jetspeed.database.password", "password");
-
- if (driverClass == null)
- throw new IllegalArgumentException(
- "Can't proceed without a valid driver");
- if (url == null)
- throw new IllegalArgumentException(
- "Can't proceed without a valid url to the target database");
- if (user == null)
- throw new IllegalArgumentException(
- "Can't proceed without a valid database user");
-
-
-
- HashMap context = new HashMap();
-
- context.put(SpringJNDIStarter.DATASOURCE_DRIVER, driverClass);
- context.put(SpringJNDIStarter.DATASOURCE_URL, url);
- context.put(SpringJNDIStarter.DATASOURCE_USERNAME, user);
- context.put(SpringJNDIStarter.DATASOURCE_PASSWORD, password);
-
- Logger logger = Logger.getLogger("org.springframework");
- Level level = logger.getLevel();
- if (logLevel.equalsIgnoreCase("INFO"))
- logger.setLevel(Level.INFO);
- else
- if (logLevel.equalsIgnoreCase("WARN"))
- logger.setLevel(Level.WARN);
- else
- logger.setLevel(Level.ERROR);
-
-/**
- * set the application root
- */
- System.out.println("APP ROOT is " + applicationPath);
- System.setProperty("applicationRoot",applicationPath);
- System.setProperty("portal.name","jetspped");
- SpringJNDIStarter starter = new SpringJNDIStarter(context,applicationPath,getTokens(bootConfigFiles),getTokens(configFiles));
-
- System.out.println("starter framework created " + starter);
-
-
- try
- {
- starter.setUp();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- System.exit(1);
- }
- System.out.println("starter framework established " + starter);
- String[] importList = null;
-
- if (doImport)
- importList = parseFiles(fileName);
-
- if ((doImport) && (importList != null) && (importList.length > 0))
- {
- for (int i = 0; i < importList.length; i++)
- {
- try
- {
- System.out.println("processing import " + importList[i]);
- if (processHelper == 2)
- {
- serializer = new JetspeedSerializerSecondaryImpl(starter.getComponentManager());
- }
- else
- serializer = new JetspeedSerializerImpl(starter.getComponentManager());
- serializer.importData(importList[i], settings);
- System.out.println("processing import " + importList[i] + " done");
-
- }
- catch (Exception e)
- {
- System.err.println("Failed to process XML import for " + importList[i] + ":" + e);
- e.printStackTrace();
- }
- finally
- {
- if (serializer != null)
- serializer.closeUp();
- }
- }
- }
- if (doExport)
- {
- try
- {
- System.out.println("processing export to " + fileName);
- if (processHelper == 2)
- {
- serializer = new JetspeedSerializerSecondaryImpl(starter.getComponentManager());
- }
- else
- serializer = new JetspeedSerializerImpl(starter.getComponentManager());
-
- serializer.exportData(name, fileName, settings);
- }
- catch (Exception e)
- {
- System.err.println("Failed to process XML export of " + fileName + ": " + e);
- e.printStackTrace();
- }
- finally
- {
- if (serializer != null)
- serializer.closeUp();
- }
-
- }
- try
- {
- starter.tearDown();
- logger.setLevel(level);;
- }
- catch (Exception e1)
- {
- System.out.println("starter framework teardown caused exception " + e1.getLocalizedMessage());
- e1.printStackTrace();
-
- }
- System.out.println("DONE performing " + (doExport?"export":"import")+ " with " + fileName);
- }
-
-
-
- /**
- * process provided filename or directory name
- *
- * @return one or more files to be processed
- */
- static private String[] parseFiles(String schemaDirectory)
- {
- String[] fileList = null;
- try
- {
- File dir = new File(schemaDirectory);
- if (!(dir.exists()))
- {
- return fileList;
- }
- if (!(dir.isDirectory()))
- {
- fileList = new String[1];
- fileList[0] = schemaDirectory;
- return fileList;
- }
- // Handling a directory
- File[] files = dir.listFiles(
- new FilenameFilter() {
- public boolean accept(File dir, String name)
- {String n = name.toLowerCase();
- return n.endsWith("seed.xml");
- }
- });
- if (files == null)
- return fileList;
-
- fileList = new String[files.length];
- for (int i = 0; i < files.length; i++)
- {
- fileList[i] = files[i].getAbsolutePath();
- }
- return fileList;
- }
- catch (Exception e)
- {
- e.printStackTrace();
- throw new IllegalArgumentException(
- "Processing the schema-directory " + schemaDirectory
- + " caused exception "
- + e.getLocalizedMessage());
- }
-
-
- }
-
-
- private static String[] getTokens(String _line)
- {
- if ((_line == null) || (_line.length() == 0))
- return null;
-
- StringTokenizer st = new StringTokenizer(_line, ",");
- ArrayList list = new ArrayList();
-
- while (st.hasMoreTokens())
- list.add(st.nextToken());
- String[] s = new String[list.size()];
- for (int i=0; i<list.size(); i++)
- s[i] = (String)list.get(i);
- return s;
- }
-
-
+ // This class needs to be reimplemented after the JetspeedSerializer refactoring is completed
+ // and the main part of the new maven-2 build environment is setup.
+ // See: JS2-770 & JS2-771
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org