portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r652637 - in /portals/jetspeed-2/applications/j2-admin/trunk/src: main/java/org/apache/jetspeed/portlets/admin/JetspeedDataImporter.java webapp/WEB-INF/jetspeed-portlet.xml webapp/WEB-INF/view/admin/importer-view.vm
Date Thu, 01 May 2008 19:57:38 GMT
Author: ate
Date: Thu May  1 12:57:38 2008
New Revision: 652637

URL: http://svn.apache.org/viewvc?rev=652637&view=rev
Log:
Reimplement (and enhance) the JetspeedDataImporter

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/admin/JetspeedDataImporter.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/jetspeed-portlet.xml
    portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/admin/importer-view.vm

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/admin/JetspeedDataImporter.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/admin/JetspeedDataImporter.java?rev=652637&r1=652636&r2=652637&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/admin/JetspeedDataImporter.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/admin/JetspeedDataImporter.java
Thu May  1 12:57:38 2008
@@ -24,8 +24,7 @@
 import org.apache.jetspeed.security.GroupManager;
 import org.apache.jetspeed.security.RoleManager;
 import org.apache.jetspeed.security.UserManager;
-//import org.apache.jetspeed.serializer.JetspeedSerializer;
-//import org.apache.jetspeed.serializer.JetspeedSerializerFactory;
+import org.apache.jetspeed.serializer.JetspeedSerializer;
 import org.apache.portals.gems.dojo.AbstractDojoVelocityPortlet;
 
 /**
@@ -47,35 +46,9 @@
 
     protected RoleManager roleManager;
 
-    private HashMap roleMap = new HashMap();
-
-    private HashMap groupMap = new HashMap();
-
-    private HashMap userMap = new HashMap();
-
-    private HashMap mimeMap = new HashMap();
-
-    private HashMap mimeMapInt = new HashMap();
-
-    private HashMap mediaMap = new HashMap();
-
-    private HashMap capabilityMap = new HashMap();
-
-    private HashMap capabilityMapInt = new HashMap();
-
-    private HashMap clientMap = new HashMap();
-
-    private HashMap permissionMap = new HashMap();
-
-    private HashMap rulesMap = new HashMap();
-
     int refCouter = 0;
 
-    private static String ENCODING_STRING = "JETSPEED 2.1 - 2006";
-
-    private static String JETSPEED = "JETSPEED";
-    
-    // protected JetspeedSerializerFactory serializerFactory;    
+    protected JetspeedSerializer serializer;    
 
     protected void includeHeaderContent(HeaderResource headerResource)
     {
@@ -92,61 +65,49 @@
         headerResource.dojoAddCoreLibraryRequire("dojo.widget.LayoutContainer");
 
         headerResource.dojoAddCoreLibraryRequire("dojo.widget.Tree");
-        headerResource
-                .dojoAddCoreLibraryRequire("dojo.widget.TreeRPCController");
+        headerResource.dojoAddCoreLibraryRequire("dojo.widget.TreeRPCController");
         headerResource.dojoAddCoreLibraryRequire("dojo.widget.TreeSelector");
         headerResource.dojoAddCoreLibraryRequire("dojo.widget.TreeNode");
         headerResource.dojoAddCoreLibraryRequire("dojo.widget.TreeContextMenu");
 
-        headerResource
-                .dojoAddCoreLibraryRequire("dojo.widget.ValidationTextbox");
+        headerResource.dojoAddCoreLibraryRequire("dojo.widget.ValidationTextbox");
         headerResource.dojoAddCoreLibraryRequire("dojo.widget.ComboBox");
         headerResource.dojoAddCoreLibraryRequire("dojo.widget.Checkbox");
         headerResource.dojoAddCoreLibraryRequire("dojo.widget.Dialog");
         headerResource.dojoAddCoreLibraryRequire("dojo.widget.Button");
 
         headerResource.dojoAddModuleLibraryRequire("jetspeed.desktop.core");
-        headerResource
-                .dojoAddModuleLibraryRequire("jetspeed.widget.EditorTable");
+        headerResource.dojoAddModuleLibraryRequire("jetspeed.widget.EditorTable");
     }
 
     public void init(PortletConfig config) throws PortletException
     {
         super.init(config);
-        userManager = (UserManager) getPortletContext().getAttribute(
-                CommonPortletServices.CPS_USER_MANAGER_COMPONENT);
+        userManager = (UserManager) getPortletContext().getAttribute(CommonPortletServices.CPS_USER_MANAGER_COMPONENT);
         if (null == userManager)
         {
-            PortletException pe = new PortletException(
-                    "Failed to find the User Manager on SiteViewController initialization");
+            PortletException pe = new PortletException("Failed to find the User Manager on
SiteViewController initialization");
             throw new RuntimeException(pe);
         }
-        groupManager = (GroupManager) getPortletContext().getAttribute(
-                CommonPortletServices.CPS_GROUP_MANAGER_COMPONENT);
+        groupManager = (GroupManager) getPortletContext().getAttribute(CommonPortletServices.CPS_GROUP_MANAGER_COMPONENT);
         if (null == groupManager)
         {
             PortletException pe = new PortletException(
                     "Failed to find the Group Manager on SiteViewController initialization");
             throw new RuntimeException(pe);
         }
-        roleManager = (RoleManager) getPortletContext().getAttribute(
-                CommonPortletServices.CPS_ROLE_MANAGER_COMPONENT);
+        roleManager = (RoleManager) getPortletContext().getAttribute(CommonPortletServices.CPS_ROLE_MANAGER_COMPONENT);
         if (null == roleManager)
         {
-            PortletException pe = new PortletException(
-                    "Failed to find the Group Manager on SiteViewController initialization");
+            PortletException pe = new PortletException("Failed to find the Group Manager
on SiteViewController initialization");
             throw new RuntimeException(pe);
         }
-        /*
-        serializerFactory = (JetspeedSerializerFactory) getPortletContext().getAttribute(
-                CommonPortletServices.CPS_JETSPEED_SERIALIZER_FACTORY);
-        if (null == serializerFactory)
+        serializer = (JetspeedSerializer)getPortletContext().getAttribute(CommonPortletServices.CPS_JETSPEED_SERIALIZER);
+        if (null == serializer)
         {
-            PortletException pe = new PortletException(
-                    "Failed to find the SerializerFactory on SiteViewController initialization");
+            PortletException pe = new PortletException("Failed to find the Serializer on
SiteViewController initialization");
             throw new RuntimeException(pe);
         }
-        */
     }
 
     public void doView(RenderRequest request, RenderResponse response)
@@ -161,10 +122,7 @@
             ActionResponse actionResponse) throws PortletException,
             java.io.IOException
     {
-        String export = request.getParameter("export");
         String fileName = "";
-        String destPath = "";
-        String fileType = "";
         String path = "";
         String usrFolder = "";
         boolean success = false;
@@ -177,8 +135,7 @@
                     diskFileItemFactory);
             if (PortletFileUpload.isMultipartContent(request))
             {
-                Iterator fileIt = portletFileUpload.parseRequest(request)
-                        .iterator();
+                Iterator fileIt = portletFileUpload.parseRequest(request).iterator();
                 while (fileIt.hasNext())
                 {
                     FileItem fileItem = (FileItem) fileIt.next();
@@ -190,8 +147,7 @@
                             usrFolder = getTempFolder(request);
                             path = System.getProperty("file.separator");
                             filePath = usrFolder + path + fileItem.getName();
-                            FileOutputStream out = new FileOutputStream(
-                                    filePath);
+                            FileOutputStream out = new FileOutputStream(filePath);
                             out.write(fileItem.get());
                             out.close();
                         }
@@ -214,46 +170,30 @@
         {
             request.getPortletSession().setAttribute("status", "false");
             request.getPortletSession().setAttribute("msg", e.getMessage());            
               
-            // throw new PortletException("Error occured in file uplodad");
         }
     }
 
     private boolean importJetspeedData(String filePath)
     {
-        /*
-         *  TODO : replace SerializerFactory with newer (to be built) version
-         try
+        try
         {
             Map settings = new HashMap();
             settings.put(JetspeedSerializer.KEY_PROCESS_USERS, Boolean.TRUE);
-            settings.put(JetspeedSerializer.KEY_PROCESS_CAPABILITIES,
-                    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.TRUE);
-            settings.put(JetspeedSerializer.KEY_OVERWRITE_EXISTING,
-                    Boolean.TRUE);
-            settings.put(JetspeedSerializer.KEY_BACKUP_BEFORE_PROCESS,
-                    Boolean.FALSE);
-            JetspeedSerializer serializer = serializerFactory.create(JetspeedSerializerFactory.PRIMARY);
-            try
-            {
-                serializer.importData(filePath, settings);
-            }
-            catch (Exception e)
-            {
-                serializer = serializerFactory.create(JetspeedSerializerFactory.SECONDARY);
-                serializer.importData(filePath, settings);                
-            }
+            settings.put(JetspeedSerializer.KEY_PROCESS_USER_PREFERENCES, Boolean.TRUE);
+            settings.put(JetspeedSerializer.KEY_PROCESS_PORTAL_PREFERENCES, Boolean.TRUE);
+            settings.put(JetspeedSerializer.KEY_PROCESS_ENTITIES, Boolean.TRUE);
+            settings.put(JetspeedSerializer.KEY_OVERWRITE_EXISTING, Boolean.TRUE);
+            settings.put(JetspeedSerializer.KEY_BACKUP_BEFORE_PROCESS, Boolean.FALSE);
+
+            serializer.importData(filePath, settings);
             return true;
         } 
         catch (Exception e)
         {
             return false;
         }
-* 
-         */
-    	return false;
     }
 
     private boolean cleanUserFolder(String userName)

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/jetspeed-portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/jetspeed-portlet.xml?rev=652637&r1=652636&r2=652637&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/jetspeed-portlet.xml
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/jetspeed-portlet.xml
Thu May  1 12:57:38 2008
@@ -144,6 +144,7 @@
         <js:service name='PortalConfiguration'/>
         <js:service name='ImporterManager'/>
         <js:service name='AuditActivity'/>
+        <js:service name='JetspeedSerializer'/>
 	</js:services>
 
 </portlet-app>

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/admin/importer-view.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/admin/importer-view.vm?rev=652637&r1=652636&r2=652637&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/admin/importer-view.vm
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/admin/importer-view.vm
Thu May  1 12:57:38 2008
@@ -61,23 +61,25 @@
 		{
 			permissions.value='n';
 		}						
-		var names = new Array("users", "profiles","capabilities", "permissions");
-		var values = new Array(users.value,profiling.value,capabilities.value,permissions.value);
-		ajaxInvoke("jetspeedexport", names, values, new exportHandler() );     		
-	}
-	function buildPrefsquery()
-	{
-		var prefs = document.getElementById('prefs');
-		if(prefs.checked)
+		var entities = document.getElementById('entities');
+		if(entities.checked)
 		{
-			prefs = 'y';
+			entities.value = 'y';
 		}else
 		{
-			prefs = 'n';
+			entities.value = 'n';
 		}
-		var names = new Array("prefs");
-		var values = new Array(prefs);
-		ajaxInvoke("jetspeedexport", names, values, new exportHandler());     		
+		var uprefs = document.getElementById('uprefs');
+		if(uprefs.checked)
+		{
+			uprefs.value = 'y';
+		}else
+		{
+			uprefs.value = 'n';
+		}
+		var names = new Array("users", "profiles","capabilities", "permissions","entities","uprefs");
+		var values = new Array(users.value,profiling.value,capabilities.value,permissions.value,entities.value,uprefs.value);
+		ajaxInvoke("jetspeedexport", names, values, new exportHandler() );     		
 	}
 	function exportHandler()
 	{
@@ -187,26 +189,21 @@
 	  </tr>
       <tr>
         <td colspan="2"><input type="checkbox" name="permissions"  id="permissions"
value="n">
-          Permissions</td>
+          Permissions (enables exporting of Users/Groups/Roles)</td>
       </tr>	  
-	  <tr>
-		  <td><input type="button" value="Export" onClick="javascript:buildExportquery();"></td>
-		  <td id='exportAns'></td>
-      </tr>
-    </table>
-	<table width="97%" border="1">
       <tr>
-        <td colspan="2"><div align="left"><b>Export Preferences</b></div></td>
+        <td colspan="2"><input type="checkbox" name="entities" id="entities" value="n">
+          Portlet Entities</td>
       </tr>
       <tr>
-        <td colspan="2"><input type="checkbox" name="prefs" id="prefs" value="n">
-          Preferences</td>
+        <td colspan="2"><input type="checkbox" name="uprefs" id="uprefs" value="n">
+          User Preferences (enables exporting Portlet Entities)</td>
       </tr>
 	  <tr>
-		  <td><input type="button" value="Export Prefs" onClick="javascript:buildPrefsquery();"></td>
-		  <td id='exportPrefsAns'></td>
+		  <td><input type="button" value="Export" onClick="javascript:buildExportquery();"></td>
+		  <td id='exportAns'></td>
       </tr>
-    </table>    
+    </table>
 	</td>
     </form>
     <td width="60%">
@@ -239,4 +236,4 @@
       </tr>
     </table></form></td>
   </tr>
-</table>
+</table>
\ No newline at end of file



---------------------------------------------------------------------
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