portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r652635 - in /portals/jetspeed-2/portal/trunk: components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/ components/jetspeed-registry/src/main/java/org/apache/jetspeed/serializer/ components/jetspeed-security/src/main/java/o...
Date Thu, 01 May 2008 19:54:45 GMT
Author: ate
Date: Thu May  1 12:54:43 2008
New Revision: 652635

URL: http://svn.apache.org/viewvc?rev=652635&view=rev
Log:
Fixes and improvements to the serializer and exporter

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/ExportJetspeedSchema.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/serializer/JetspeedRegistrySerializer.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializer.java
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/serializer.xml

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/ExportJetspeedSchema.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/ExportJetspeedSchema.java?rev=652635&r1=652634&r2=652635&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/ExportJetspeedSchema.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/ExportJetspeedSchema.java
Thu May  1 12:54:43 2008
@@ -29,7 +29,6 @@
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.serializer.JetspeedSerializer;
-//import org.apache.jetspeed.serializer.JetspeedSerializerFactory;
 
 /**
  * Exporting the object using Ajax command
@@ -38,55 +37,42 @@
  * @version $Id$
  */
 /*
- TODO: commenting out this class for now as it is still based upon the 2.1.3 JetspeedSerialzer
-       while in trunk the JetspeedSerializer has been refactored largely so it doesn't even
compile.
-       Additionally, some related new 2.1.3 features haven't been ported over to trunk yet
either (e.g. r592266 and more)
-       Will revisit this class and the JetspeedSerializer enhancements once 2.1.3 is released
-*/       
-public class ExportJetspeedSchema extends BaseGetResourceAction implements
-        AjaxAction, AjaxBuilder, Constants
+ * TODO: commenting out this class for now as it is still based upon the 2.1.3 JetspeedSerialzer
while in trunk the
+ * JetspeedSerializer has been refactored largely so it doesn't even compile. Additionally,
some related new 2.1.3
+ * features haven't been ported over to trunk yet either (e.g. r592266 and more) Will revisit
this class and the
+ * JetspeedSerializer enhancements once 2.1.3 is released
+ */
+public class ExportJetspeedSchema extends BaseGetResourceAction implements AjaxAction, AjaxBuilder,
Constants
 {
-/*    
-
     protected Log log = LogFactory.getLog(GetFolderAction.class);
-
     protected PageManager castorPageManager;
-
-    protected JetspeedSerializerFactory serializerFactory;
-
+    protected JetspeedSerializer serializer;
     protected String pageRoot;
-
     // categories of export
     private static final String USERS = "users";
-    private static final String GROUPS = "groups";
-    private static final String ROLES = "roles";
     private static final String PERMISSIONS = "permissions";
     private static final String PROFILES = "profiles";
     private static final String CAPABILITIES = "capabilities";
-    private static final String PREFS = "prefs";
-
+    private static final String USER_PREFS = "uprefs";
+    private static final String ENTITIES = "entities";
     String pathSeprator = System.getProperty("file.separator");
-*/
-    public ExportJetspeedSchema(String template, String errorTemplate,
-            PageManager pageManager,
-            PortletActionSecurityBehavior securityBehavior,
-            JetspeedSerializer serializer,
-            String dir)
+
+    public ExportJetspeedSchema(String template, String errorTemplate, PageManager pageManager,
+                                PortletActionSecurityBehavior securityBehavior, JetspeedSerializer
serializer,
+                                String dir)
     {
         super(template, errorTemplate, pageManager, securityBehavior);
-//        this.serializerFactory = serializerFactory;
-//        this.pageRoot = dir;
+        this.serializer = serializer;
+        this.pageRoot = dir;
     }
 
     public boolean run(RequestContext requestContext, Map resultMap)
     {
         boolean success = true;
-        /*        
         String status = "success";
         String userName = requestContext.getUserPrincipal().toString();
         Map settings = new HashMap();
-        String exportFileName = getUserFolder(userName, false) + pathSeprator
-                + "ldapExport.xml";
+        String exportFileName = getUserFolder(userName, false) + pathSeprator + "ldapExport.xml";
         try
         {
             resultMap.put(ACTION, "export");
@@ -96,64 +82,64 @@
                 resultMap.put(REASON, "Insufficient access to get portlets");
                 return success;
             }
-            boolean processPrefs = getNonNullActionParameter(requestContext, PREFS).equalsIgnoreCase("y")
? true : false;
-            if (!processPrefs)
-            {
-                settings.put(JetspeedSerializer.KEY_PROCESS_USERS, 
-                        getNonNullActionParameter(requestContext, USERS).equalsIgnoreCase("y")
? Boolean.TRUE : Boolean.FALSE);
-                settings.put(JetspeedSerializer.KEY_PROCESS_PERMISSIONS, 
-                        getNonNullActionParameter(requestContext, PERMISSIONS).equalsIgnoreCase("y")
? Boolean.TRUE : Boolean.FALSE);
-                settings.put(JetspeedSerializer.KEY_PROCESS_PROFILER, 
-                        getNonNullActionParameter(requestContext, PROFILES).equalsIgnoreCase("y")
? Boolean.TRUE : Boolean.FALSE);
-                settings.put(JetspeedSerializer.KEY_PROCESS_CAPABILITIES, 
-                        getNonNullActionParameter(requestContext, CAPABILITIES).equalsIgnoreCase("y")
? Boolean.TRUE : Boolean.FALSE);
-            }
-            else
+            settings.put(JetspeedSerializer.KEY_PROCESS_USERS,
+                         getNonNullActionParameter(requestContext, USERS).equalsIgnoreCase("y")
? Boolean.TRUE
+                                                                                        
      : Boolean.FALSE);
+            Boolean value = getNonNullActionParameter(requestContext, PERMISSIONS).equalsIgnoreCase("y")
? Boolean.TRUE
+                                                                                        
               : Boolean.FALSE;
+            settings.put(JetspeedSerializer.KEY_PROCESS_PERMISSIONS, value);
+            if (value.booleanValue())
+            {
+                // export of permissions requires export of USERS too
+                settings.put(JetspeedSerializer.KEY_PROCESS_USERS, Boolean.TRUE);
+            }
+            settings.put(JetspeedSerializer.KEY_PROCESS_PROFILER,
+                         getNonNullActionParameter(requestContext, PROFILES).equalsIgnoreCase("y")
? Boolean.TRUE
+                                                                                        
         : Boolean.FALSE);
+            settings.put(JetspeedSerializer.KEY_PROCESS_CAPABILITIES,
+                         getNonNullActionParameter(requestContext, CAPABILITIES).equalsIgnoreCase("y")
? Boolean.TRUE
+                                                                                        
             : Boolean.FALSE);
+            settings.put(JetspeedSerializer.KEY_PROCESS_ENTITIES,
+                         getNonNullActionParameter(requestContext, ENTITIES).equalsIgnoreCase("y")
? Boolean.TRUE
+                                                                                        
         : Boolean.FALSE);
+            value = getNonNullActionParameter(requestContext, USER_PREFS).equalsIgnoreCase("y")
? Boolean.TRUE : Boolean.FALSE;
+            settings.put(JetspeedSerializer.KEY_PROCESS_USER_PREFERENCES, value);
+            if (value.booleanValue())
             {
-                settings.put(JetspeedSerializer.KEY_PROCESS_PREFERENCES, Boolean.TRUE);
+                // export of user preferences requires export of ENTITIES too
+                settings.put(JetspeedSerializer.KEY_PROCESS_ENTITIES, Boolean.TRUE);
             }
-            if (!cleanUserFolder(userName)) 
+            if (!cleanUserFolder(userName))
             {
                 resultMap.put(STATUS, "failure");
                 resultMap.put(REASON, "Could not create temp files on disk.");
                 success = false;
                 return success;
             }
-            settings.put(JetspeedSerializer.KEY_OVERWRITE_EXISTING,
-                    Boolean.TRUE);
-            settings.put(JetspeedSerializer.KEY_BACKUP_BEFORE_PROCESS,
-                    Boolean.FALSE);
-            JetspeedSerializer serializer = null;
-            if (processPrefs)
-                serializer = serializerFactory.create(JetspeedSerializerFactory.SECONDARY);
-            else
-                serializer = serializerFactory.create(JetspeedSerializerFactory.PRIMARY);
-            serializer.setDefaultIndent("\t");
+            settings.put(JetspeedSerializer.KEY_EXPORT_INDENTATION, "\t");
+            settings.put(JetspeedSerializer.KEY_OVERWRITE_EXISTING, Boolean.TRUE);
+            settings.put(JetspeedSerializer.KEY_BACKUP_BEFORE_PROCESS, Boolean.FALSE);
             serializer.exportData("jetspeedadmin_export_process", exportFileName, settings);
             requestContext.getRequest().getSession().setAttribute("file", userName + "_ldapExport.xml");
             resultMap.put("link", getDownloadLink(requestContext, "tmpExport.xml", userName));
-
             resultMap.put(STATUS, status);
-        } catch (Exception e)
+        }
+        catch (Exception e)
         {
             // Log the exception
-            e.printStackTrace();
             log.error("exception while getting folder info", e);
             resultMap.put(STATUS, "failure");
             resultMap.put(REASON, e.getMessage());
             // Return a failure indicator
             success = false;
         }
-*/        
         return success;
     }
-/*
-    private String getDownloadLink(RequestContext requestContext,
-            String ObjectName, String userName) throws Exception
+
+    private String getDownloadLink(RequestContext requestContext, String ObjectName, String
userName) throws Exception
     {
         String link = "";
-        String basePath = requestContext.getRequest().getContextPath()
-                + "/fileserver/_content/";
+        String basePath = requestContext.getRequest().getContextPath() + "/fileserver/_content/";
         link = basePath + userName + "/" + ObjectName;
         return link;
     }
@@ -165,8 +151,8 @@
         {
             String folder = getUserFolder(userName, false);
             File dir = new File(pageRoot + pathSeprator + userName + ".zip");
-            if (dir.exists()) dir.delete();
-
+            if (dir.exists())
+                dir.delete();
             dir = new File(folder);
             if (dir.exists())
             {
@@ -187,7 +173,8 @@
                 if (files[i].isDirectory())
                 {
                     deleteDir(files[i]);
-                } else
+                }
+                else
                 {
                     files[i].delete();
                 }
@@ -203,10 +190,10 @@
         if (fullPath)
         {
             return userName + pathSeprator;
-        } else
+        }
+        else
         {
             return pageRoot + pathSeprator + userName;
         }
     }
-*/
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/serializer/JetspeedRegistrySerializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/serializer/JetspeedRegistrySerializer.java?rev=652635&r1=652634&r2=652635&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/serializer/JetspeedRegistrySerializer.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/serializer/JetspeedRegistrySerializer.java
Thu May  1 12:54:43 2008
@@ -206,7 +206,7 @@
 
     private void importEntityPref(JSEntity entity, MutablePortletEntity portletEntity, Map
settings, Log log)
     {
-        if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_PREFERENCES) &&
isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_USER_PREFERENCES))
+        if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_USER_PREFERENCES))
         {
             // do I carry any preferences?
             JSEntityPreferences preferences = entity.getEntityPreferences();
@@ -306,7 +306,11 @@
                 MutablePortletApplication pa = (MutablePortletApplication) list.next();
                 // PortletApplicationDefinition pa =
                 // (PortletApplicationDefinition)list.next();
-                snapshot.getApplications().add(exportPA(pa, settings, log));
+                JSApplication app = exportPA(pa, settings, log);
+                if (app != null)
+                {
+                    snapshot.getApplications().add(app);
+                }
             }
             catch (Exception e)
             {
@@ -318,11 +322,6 @@
 
     private JSApplication exportPA(MutablePortletApplication pa, Map settings, Log log) throws
SerializerException
     {
-
-        JSApplication app = new JSApplication();
-        log.debug("--processed PA " + pa.getName() + " with id=" + pa.getId());
-        app.setID(pa.getId().toString());
-        app.setName(pa.getName());
         /**
          * while more PAs for each portletDef
          * list:entityMan:getPortletEntity(pd)
@@ -353,20 +352,25 @@
                         "PortletDefinition", e.getMessage() }));
             }
         }
-        app.setPortlets(portlets);
-        return app;
+        if (!portlets.isEmpty())
+        {
+            JSApplication app = new JSApplication();
+            log.debug("--exporting PA " + pa.getName() + " with id=" + pa.getId());
+            app.setID(pa.getId().toString());
+            app.setName(pa.getName());
+            app.setPortlets(portlets);
+            return app;
+        }
+        return null;
     }
 
     private JSPortlet exportPD(PortletDefinition pd, Map settings, Log log) throws SerializerException
     {
-
         try
         {
             Collection col = entityAccess.getPortletEntities(pd);
             if ((col == null) || (col.size() == 0))
                 return null;
-            JSPortlet portlet = new JSPortlet();
-            portlet.setName(pd.getName());
             Iterator list = null;
             try
             {
@@ -387,10 +391,15 @@
                     entities.add(jsEntity);
 
             }
-            log.debug("-----processedAnyEntities for PD=" + pd.getName());
-            portlet.setEntities(entities);
-            return portlet;
-
+            if (!entities.isEmpty())
+            {
+                JSPortlet portlet = new JSPortlet();
+                portlet.setName(pd.getName());
+                log.debug("-----exporting for PD=" + pd.getName());
+                portlet.setEntities(entities);
+                return portlet;
+            }
+            return null;
         }
         catch (Exception e)
         {
@@ -403,7 +412,10 @@
     {
         JSEntity jsEntity = null;
         
-        if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_PREFERENCES) &&
isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_USER_PREFERENCES))
+        jsEntity = new JSEntity();
+        jsEntity.setId(entity.getId().toString());
+        
+        if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_USER_PREFERENCES))
         {
             String rootForEntity = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/" + entity.getId();
             try
@@ -414,18 +426,21 @@
                     String[] children = prefNode.childrenNames();
                     if ((children != null) && (children.length > 0))
                     {
-                        jsEntity = new JSEntity();
-                        jsEntity.setId(entity.getId().toString());
-                        JSEntityPreferences permissions = new JSEntityPreferences();
+                        JSEntityPreferences preferences = new JSEntityPreferences();
 
                         for (int i = 0; i < children.length; i++)
                         {
-                            JSEntityPreference permission = exportPreferenceNode(entity,
children[i], settings, log);
-                            if (permission != null)
-                                permissions.add(permission);
+                            JSEntityPreference preference = exportPreferenceNode(entity,
children[i], settings, log);
+                            if (preference != null)
+                            {
+                                preferences.add(preference);
+                            }
+                        }
+                        if (!preferences.isEmpty())
+                        {
+                            log.debug("processed preferences for entity=" + entity.getId());
+                            jsEntity.setEntityPreferences(preferences);
                         }
-                        log.debug("processed preferences for entity=" + entity.getId());
-                        jsEntity.setEntityPreferences(permissions);
                     }
                 }
             }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java?rev=652635&r1=652634&r2=652635&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
Thu May  1 12:54:43 2008
@@ -113,10 +113,14 @@
     {
         if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_USERS))
         {
-            log.info("collecting users/roles/groups and permissions");
+            log.info("collecting users/roles/groups");
             Refs refs = new Refs();
             exportRolesGroupsUsers(refs, snapshot, settings, log);
-            exportPermissions(refs, snapshot, settings, log);
+            if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_PERMISSIONS))
+            {
+                log.info("collecting permissions");
+                exportPermissions(refs, snapshot, settings, log);
+            }
         }
     }
 
@@ -133,7 +137,11 @@
             log.info("creating users/roles/groups and permissions");
             Refs refs = new Refs();
             recreateRolesGroupsUsers(refs, snapshot, settings, log);
-            recreatePermissions(refs, snapshot, settings, log);
+            if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_PERMISSIONS))
+            {
+                log.info("creating permissions");
+                recreatePermissions(refs, snapshot, settings, log);
+            }
         }
     }
 

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializer.java?rev=652635&r1=652634&r2=652635&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializer.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializer.java
Thu May  1 12:54:43 2008
@@ -67,10 +67,10 @@
     String KEY_PROCESS_USERS = "process_users";
     String KEY_PROCESS_CAPABILITIES = "process_capabilities";
     String KEY_PROCESS_PROFILER = "process_profiler";
+    String KEY_PROCESS_PERMISSIONS = "process_permissions";
     String KEY_PROCESS_USER_PREFERENCES = "process_user_preferences";
     String KEY_PROCESS_PORTAL_PREFERENCES = "process_portal_preferences";
     String KEY_PROCESS_ENTITIES = "process_entities";
-    String KEY_PROCESS_PREFERENCES = "process_preferences";
     String KEY_LOGGER = "logger";
     String KEY_OVERWRITE_EXISTING = "overwrite_existing";
     String KEY_BACKUP_BEFORE_PROCESS = "backup_before_process";

Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/serializer.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/serializer.xml?rev=652635&r1=652634&r2=652635&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/serializer.xml
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/serializer.xml
Thu May  1 12:54:43 2008
@@ -36,6 +36,10 @@
         <entry key="process_users">
           <value type="java.lang.Boolean">true</value>
         </entry>
+        <!-- process_permissions depends on process_users being enabled, otherwise ignored
-->
+        <entry key="process_permissions">
+          <value type="java.lang.Boolean">true</value>
+        </entry>
         <entry key="process_profiler">
           <value type="java.lang.Boolean">true</value>
         </entry>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message