Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManagerUtil.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManagerUtil.java?rev=737018&view=auto ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManagerUtil.java (added) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManagerUtil.java Fri Jan 23 04:46:36 2009 @@ -0,0 +1,229 @@ +/* + * 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.portlets.site; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.util.Iterator; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.jetspeed.exception.JetspeedException; +import org.apache.jetspeed.om.folder.Folder; +import org.apache.jetspeed.om.page.Link; +import org.apache.jetspeed.om.page.Page; +import org.apache.jetspeed.page.PageManager; +import org.apache.jetspeed.request.RequestContext; + +/** + * @author <a href="mailto:vku...@apache.org">Vivek Kumar</a> + * @version $Id: + */ +public class PortalSiteManagerUtil +{ + private static String pathSeprator = System.getProperty("file.separator"); + private static String pageRoot = System.getProperty("java.io.tmpdir"); + + public static String getDownloadLink(HttpServletRequest servletRequest, String ObjectName, String userName, String objectType) throws Exception + { + String link = ""; + String basePath = servletRequest.getContextPath() + "/fileserver/_content/"; + if (objectType.equalsIgnoreCase("folder")) + { + String sourcePath = getUserFolder(userName, false); + String target = sourcePath + ".zip"; + boolean success = zipObject(sourcePath, target); + if (!success) + throw new Exception("Error Occurered in zipping the file"); + link = basePath + ObjectName + ".zip"; + } + else + { + link = basePath + userName + "/" + ObjectName; + } + return link; + } + + public static Folder importFolder(PageManager castorPageManager, Folder srcFolder, String userName, String destination) throws JetspeedException + { + String newPath = ""; + Folder dstFolder = lookupFolder(castorPageManager,srcFolder.getPath()); + dstFolder = castorPageManager.copyFolder(srcFolder, getUserFolder(userName, true) + destination); + castorPageManager.updateFolder(dstFolder); + Iterator pages = srcFolder.getPages().iterator(); + while (pages.hasNext()) + { + Page srcPage = (Page) pages.next(); + Page dstPage = lookupPage(castorPageManager,srcPage.getPath()); + newPath = getUserFolder(userName, true) + destination + getRealPath(srcPage.getPath()); + dstPage = castorPageManager.copyPage(srcPage, newPath); + castorPageManager.updatePage(dstPage); + } + Iterator links = srcFolder.getLinks().iterator(); + while (links.hasNext()) + { + Link srcLink = (Link) links.next(); + Link dstLink = lookupLink(castorPageManager,srcLink.getPath()); + newPath = getUserFolder(userName, true) + destination + getRealPath(srcLink.getPath()); + dstLink = castorPageManager.copyLink(srcLink, newPath); + castorPageManager.updateLink(dstLink); + } + Iterator folders = srcFolder.getFolders().iterator(); + while (folders.hasNext()) + { + Folder folder = (Folder) folders.next(); + newPath = destination + getRealPath(folder.getPath()); + importFolder(castorPageManager,folder, userName, newPath); + } + return dstFolder; + } + + public static void zipFiles(File cpFile, String sourcePath, ZipOutputStream cpZipOutputStream) + { + if (cpFile.isDirectory()) + { + File[] fList = cpFile.listFiles(); + for (int i = 0; i < fList.length; i++) + { + zipFiles(fList[i], sourcePath, cpZipOutputStream); + } + } + else + { + try + { + String strAbsPath = cpFile.getAbsolutePath(); + String strZipEntryName = strAbsPath.substring(sourcePath.length() + 1, strAbsPath.length()); + byte[] b = new byte[(int) (cpFile.length())]; + FileInputStream cpFileInputStream = new FileInputStream(cpFile); + int i = cpFileInputStream.read(b, 0, (int) cpFile.length()); + ZipEntry cpZipEntry = new ZipEntry(strZipEntryName); + cpZipOutputStream.putNextEntry(cpZipEntry); + cpZipOutputStream.write(b, 0, (int) cpFile.length()); + cpZipOutputStream.closeEntry(); + cpFileInputStream.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + + public static String getUserFolder(String userName, boolean fullPath) + { + if (pathSeprator == null || pathSeprator.equals("")) + pathSeprator = "/"; + if (fullPath) + { + return userName + pathSeprator; + } + else + { + return pageRoot + pathSeprator + userName; + } + } + + private static boolean zipObject(String sourcePath, String target) + { + ZipOutputStream cpZipOutputStream = null; + try + { + File cpFile = new File(sourcePath); + if (!cpFile.isDirectory()) + { + return false; + } + cpZipOutputStream = new ZipOutputStream(new FileOutputStream(target)); + cpZipOutputStream.setLevel(9); + zipFiles(cpFile, sourcePath, cpZipOutputStream); + cpZipOutputStream.finish(); + cpZipOutputStream.close(); + } + catch (Exception e) + { + e.printStackTrace(); + return false; + } + finally + { + } + return true; + } + + private static Page lookupPage(PageManager castorPageManager, String path) + { + try + { + return castorPageManager.getPage(path); + } + catch (Exception e) + { + return null; + } + } + + private static Link lookupLink(PageManager castorPageManager, String path) + { + try + { + return castorPageManager.getLink(path); + } + catch (Exception e) + { + return null; + } + } + + private static Folder lookupFolder(PageManager castorPageManager, String path) + { + try + { + return castorPageManager.getFolder(path); + } + catch (Exception e) + { + return null; + } + } + + private static String getRealPath(String path) + { + int index = path.lastIndexOf("/"); + if (index > 0) + { + return path.substring(index); + } + return path; + } + + public static String getParentPath(String path) + { + int index = path.lastIndexOf("/"); + if (index == 0) + { + return "/"; + } + else + { + return path.substring(0, index); + } + } +}
Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManagerUtil.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/SiteTreeNode.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/SiteTreeNode.java?rev=737018&view=auto ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/SiteTreeNode.java (added) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/SiteTreeNode.java Fri Jan 23 04:46:36 2009 @@ -0,0 +1,170 @@ +/* + * 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.portlets.site; + +import java.io.Serializable; + +import org.apache.jetspeed.om.folder.Folder; +import org.apache.jetspeed.om.page.Link; +import org.apache.jetspeed.om.page.Page; + +/** + * @author <a href="mailto:vku...@apache.org">Vivek Kumar</a> + * @version $Id: + */ +public class SiteTreeNode implements Serializable +{ + /** + * + */ + private static final long serialVersionUID = 2349948500132928089L; + private String nodeName; + private String nodePath; + private boolean hasChildern; + private boolean loaded; + public enum FileType {Folder,Page,Link}; + private FileType docType; + + public SiteTreeNode(Folder folder) + { + this.nodeName = folder.getName(); + this.nodePath = folder.getPath(); + docType = FileType.Folder; + } + + public SiteTreeNode(Page page) + { + this.nodeName = page.getName(); + this.nodePath = page.getPath(); + docType = FileType.Page; + } + + public SiteTreeNode(Link link) + { + this.nodeName = link.getName(); + this.nodePath = link.getPath(); + docType = FileType.Link; + } + + + public SiteTreeNode(String name, String path,FileType type) + { + this.nodeName = name; + this.nodePath = path; + this.docType = type; + } + public SiteTreeNode(String name, String path,FileType type,boolean loaded) + { + this.nodeName = name; + this.nodePath = path; + this.docType = type; + this.loaded = loaded; + } + /** + * @return the nodeName + */ + public String getNodeName() + { + return nodeName; + } + + /** + * @param nodeName + * the nodeName to set + */ + public void setNodeName(String nodeName) + { + this.nodeName = nodeName; + } + + /** + * @return the nodePath + */ + public String getNodePath() + { + return nodePath; + } + + /** + * @param nodePath + * the nodePath to set + */ + public void setNodePath(String nodePath) + { + this.nodePath = nodePath; + } + + /** + * @return the hasChildern + */ + public boolean isHasChildern() + { + return hasChildern; + } + + /** + * @param hasChildern + * the hasChildern to set + */ + public void setHasChildern(boolean hasChildern) + { + this.hasChildern = hasChildern; + } + + /** + * @return the loaded + */ + public boolean isLoaded() + { + return loaded; + } + + /** + * @param loaded the loaded to set + */ + public void setLoaded(boolean loaded) + { + this.loaded = loaded; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() + { + return nodeName!=null?nodeName:super.toString(); + } + + /** + * @return the docType + */ + public FileType getDocType() + { + return docType; + } + + /** + * @param docType the docType to set + */ + public void setDocType(FileType docType) + { + this.docType = docType; + } + + +} Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/SiteTreeNode.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/images/folder.gif URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/images/folder.gif?rev=737018&view=auto ============================================================================== Binary file - no diff available. Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/images/folder.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/images/link.gif URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/images/link.gif?rev=737018&view=auto ============================================================================== Binary file - no diff available. Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/images/link.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/images/page.gif URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/images/page.gif?rev=737018&view=auto ============================================================================== Binary file - no diff available. Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/images/page.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Copied: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/resources/PortalSiteManager.properties (from r727324, portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/resources/SiteResources.properties) URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/resources/PortalSiteManager.properties?p2=portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/resources/PortalSiteManager.properties&p1=portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/resources/SiteResources.properties&r1=727324&r2=737018&rev=737018&view=diff ============================================================================== (empty) Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/resources/PortalSiteManager.properties ------------------------------------------------------------------------------ svn:eol-style = native Copied: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/resources/PortalSiteManager_en.properties (from r727324, portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/resources/SiteResources_en.properties) URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/resources/PortalSiteManager_en.properties?p2=portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/resources/PortalSiteManager_en.properties&p1=portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/resources/SiteResources_en.properties&r1=727324&r2=737018&rev=737018&view=diff ============================================================================== (empty) Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/resources/PortalSiteManager_en.properties ------------------------------------------------------------------------------ svn:eol-style = native Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/JavascriptEventConfirmation.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/JavascriptEventConfirmation.java?rev=737018&view=auto ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/JavascriptEventConfirmation.java (added) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/JavascriptEventConfirmation.java Fri Jan 23 04:46:36 2009 @@ -0,0 +1,43 @@ +/* + * 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.portlets.wicket.component; + +import org.apache.wicket.AttributeModifier; +import org.apache.wicket.model.Model; + +/** + * @author <a href="mailto:vku...@apache.org">Vivek Kumar</a> + * @version $Id: + */ +public class JavascriptEventConfirmation extends AttributeModifier +{ + public JavascriptEventConfirmation(String event, String msg) + { + super(event, true, new Model(msg)); + } + + protected String newValue(final String currentValue, final String replacementValue) + { + String prefix = "var conf = confirm('" + replacementValue + "'); " + "if (!conf) return false; "; + String result = prefix; + if (currentValue != null) + { + result = prefix + currentValue; + } + return result; + } +} \ No newline at end of file Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/JavascriptEventConfirmation.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml?rev=737018&r1=737017&r2=737018&view=diff ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml (original) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml Fri Jan 23 04:46:36 2009 @@ -1614,27 +1614,19 @@ <portlet-name>PortalSiteManager</portlet-name> <display-name>Portal Site Manager</display-name> <display-name xml:lang="ja">ãã¼ã¿ã«ãµã¤ãããã¼ã¸ã£</display-name> - <portlet-class>org.apache.jetspeed.portlets.site.PortalSiteManager</portlet-class> - <init-param> - <name>ViewPage</name> - <value>/WEB-INF/view/site/site-view.vm</value> - </init-param> - <init-param> - <name>EditPage</name> - <value>/WEB-INF/view/edit-prefs.vm</value> - </init-param> - <init-param> - <name>HeaderPage</name> - <value>/WEB-INF/view/site/site-view-header.vm</value> - </init-param> - <init-param> - <name>dojo.requires.core</name> - <value>dojo.lang.*;dojo.event.*;dojo.io.*;dojo.dnd.*;dojo.widget.*;dojo.widget.Tree;dojo.widget.Button;dojo.widget.Checkbox;dojo.widget.Dialog;dojo.widget.TabContainer;dojo.widget.ContentPane;dojo.widget.LayoutContainer;dojo.widget.TreeRPCController;dojo.widget.TreeSelector;dojo.widget.TreeNode;dojo.widget.TreeContextMenu;dojo.widget.validate;dojo.widget.ComboBox;</value> - </init-param> + <portlet-class>org.apache.jetspeed.portlets.wicket.AdminWicketPortlet</portlet-class> <init-param> <name>portlet-icon</name> <value>user-home.png</value> </init-param> + <init-param> + <name>wicketFilterPath</name> + <value>/portalSiteManager</value> + </init-param> + <init-param> + <name>serviceComponentNames</name> + <value>cps:PageManager,cps:PortletRegistryComponent,cps:DecorationFactory,cps:ImporterManager,cps:UserManager</value> + </init-param> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml?rev=737018&r1=737017&r2=737018&view=diff ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml (original) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml Fri Jan 23 04:46:36 2009 @@ -115,6 +115,22 @@ </init-param> </filter> + <filter> + <filter-name>PortalSiteManagerApplication</filter-name> + <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> + <init-param> + <param-name>applicationClassName</param-name> + <param-value>org.apache.jetspeed.portlets.site.PortalSiteManagerApplication</param-value> + </init-param> + </filter> + + <filter-mapping> + <filter-name>PortalSiteManagerApplication</filter-name> + <url-pattern>/portalSiteManager/*</url-pattern> + <dispatcher>REQUEST</dispatcher> + <dispatcher>INCLUDE</dispatcher> + </filter-mapping> + <filter-mapping> <filter-name>JetspeedPrincipalManagementPortlet</filter-name> <url-pattern>/jetspeedPrincipalmanagement/*</url-pattern> --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-dev-unsubscr...@portals.apache.org For additional commands, e-mail: jetspeed-dev-h...@portals.apache.org