svnno****@sourc*****
svnno****@sourc*****
2007年 8月 24日 (金) 10:43:19 JST
Revision: 463 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=463 Author: shinsuke Date: 2007-08-24 10:43:18 +0900 (Fri, 24 Aug 2007) Log Message: ----------- added document order controll. Modified Paths: -------------- pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SiteEditorLogic.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/SiteEditorService.java -------------- next part -------------- Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SiteEditorLogic.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SiteEditorLogic.java 2007-08-24 01:42:52 UTC (rev 462) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SiteEditorLogic.java 2007-08-24 01:43:18 UTC (rev 463) @@ -49,7 +49,9 @@ import org.apache.jetspeed.om.page.ContentFragment; import org.apache.jetspeed.om.page.ContentPage; import org.apache.jetspeed.om.page.Fragment; +import org.apache.jetspeed.om.page.Link; import org.apache.jetspeed.om.page.Page; +import org.apache.jetspeed.om.page.PageSecurity; import org.apache.jetspeed.om.page.SecurityConstraintsDef; import org.apache.jetspeed.page.FolderNotUpdatedException; import org.apache.jetspeed.page.PageManager; @@ -630,6 +632,22 @@ return list; } + public List<Map<String, String>> createDocumentOrderList(String path) + throws CommonException { + Folder folder = getFolder(getFolderOrPagePath(path)); + + List<Map<String, String>> list = new ArrayList<Map<String, String>>(); + for (Iterator<String> itr = folder.getDocumentOrder().iterator(); itr + .hasNext();) { + Map<String, String> map = new HashMap<String, String>(); + String value = itr.next(); + map.put("label", value); + map.put("value", value); + list.add(map); + } + return list; + } + public List<Map<String, String>> createPermissionsList() throws CommonException { List<Map<String, String>> list = new ArrayList<Map<String, String>>(); @@ -943,6 +961,181 @@ return parentPath; } + protected String getDocumentType(String name) { + if (name == null) { + return ""; + } else if (name.endsWith(Folder.FOLDER_TYPE)) { + return Folder.FOLDER_TYPE; + } else if (name.endsWith(Page.DOCUMENT_TYPE)) { + return Page.DOCUMENT_TYPE; + } else if (name.endsWith(Link.DOCUMENT_TYPE)) { + return Link.DOCUMENT_TYPE; + } else if (name.endsWith(PageSecurity.DOCUMENT_TYPE)) { + return PageSecurity.DOCUMENT_TYPE; + } + // folder is default type. + return Folder.FOLDER_TYPE; + } + + public void moveDocumentUp(String path, String documentName) + throws CommonException { + Folder folder = getFolder(getFolderOrPagePath(path)); + if (folder == null) { + throw new CommonException("could.not.find.folder", + "Could not find a folder: " + path); + } + List<String> orderList = folder.getDocumentOrder(); + if (orderList != null) { + int index = orderList.indexOf(documentName); + if (index > -1) { + String type = getDocumentType(documentName); + int i = index - 1; + while (i >= 0) { + String value = (String) orderList.get(i); + if (type.equals(getDocumentType(value))) { + orderList.remove(index); + orderList.add(i, documentName); + folder.setDocumentOrder(orderList); + break; + } + i--; + } + } else { + orderList.add(documentName); + folder.setDocumentOrder(orderList); + } + } else { + orderList = new ArrayList<String>(4); + orderList.add(documentName); + folder.setDocumentOrder(orderList); + } + + try { + getPageManager().updateFolder(folder); + getPageManager().reset(); + } catch (PageNotUpdatedException e) { + throw new CommonException("could.not.update.document.order", + "Could not update a folder: " + path, e); + } catch (NodeException e) { + throw new CommonException("could.not.update.document.order", + "Could not update a folder: " + path, e); + } + } + + public void moveDocumentDown(String path, String documentName) + throws CommonException { + Folder folder = getFolder(getFolderOrPagePath(path)); + if (folder == null) { + throw new CommonException("could.not.find.folder", + "Could not find a folder: " + path); + } + List<String> orderList = folder.getDocumentOrder(); + if (orderList != null) { + int index = orderList.indexOf(documentName); + if (index > -1) { + String type = getDocumentType(documentName); + int i = index + 1; + while (i < orderList.size()) { + String value = (String) orderList.get(i); + if (type.equals(getDocumentType(value))) { + orderList.remove(index); + orderList.add(i, documentName); + folder.setDocumentOrder(orderList); + break; + } + i++; + } + } else { + orderList.add(documentName); + folder.setDocumentOrder(orderList); + } + } else { + orderList = new ArrayList<String>(4); + orderList.add(documentName); + folder.setDocumentOrder(orderList); + } + + try { + getPageManager().updateFolder(folder); + getPageManager().reset(); + } catch (PageNotUpdatedException e) { + throw new CommonException("could.not.update.document.order", + "Could not update a folder: " + path, e); + } catch (NodeException e) { + throw new CommonException("could.not.update.document.order", + "Could not update a folder: " + path, e); + } + } + + public void addDocumentOrder(String path, String documentName) + throws CommonException { + Folder folder = getFolder(getFolderOrPagePath(path)); + if (folder == null) { + throw new CommonException("could.not.find.folder", + "Could not find a folder: " + path); + } + List<String> orderList = folder.getDocumentOrder(); + if (orderList != null) { + int index = orderList.indexOf(documentName); + if (index > -1) { + throw new CommonException("document.already.exists", + "The document already exists: " + path); + } else { + orderList.add(documentName); + folder.setDocumentOrder(orderList); + } + } else { + orderList = new ArrayList<String>(4); + orderList.add(documentName); + folder.setDocumentOrder(orderList); + } + + try { + getPageManager().updateFolder(folder); + getPageManager().reset(); + } catch (PageNotUpdatedException e) { + throw new CommonException("could.not.add.document.order", + "Could not update a folder: " + path, e); + } catch (NodeException e) { + throw new CommonException("could.not.add.document.order", + "Could not update a folder: " + path, e); + } + } + + public void deleteDocumentOrder(String path, String documentName) + throws CommonException { + Folder folder = getFolder(getFolderOrPagePath(path)); + if (folder == null) { + throw new CommonException("could.not.find.folder", + "Could not find a folder: " + path); + } + List<String> orderList = folder.getDocumentOrder(); + if (orderList != null) { + int index = orderList.indexOf(documentName); + if (index > -1) { + orderList.remove(documentName); + folder.setDocumentOrder(orderList); + } else { + throw new CommonException("document.does.not.exist", + "The document does not exist: " + path); + } + } else { + throw new CommonException("document.does.not.exist", + "The document does not exist: " + path); + } + + try { + getPageManager().updateFolder(folder); + getPageManager().reset(); + } catch (PageNotUpdatedException e) { + throw new CommonException("could.not.add.document.order", + "Could not update a folder: " + path, e); + } catch (NodeException e) { + throw new CommonException("could.not.add.document.order", + "Could not update a folder: " + path, e); + } + } + public void addFolder(String path, String folderName, String folderTitle, String folderShortTitle, String layoutName, String pageDecorator, String portletDecorator, String desktopTheme, boolean folderHidden) Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/SiteEditorService.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/SiteEditorService.java 2007-08-24 01:42:52 UTC (rev 462) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/SiteEditorService.java 2007-08-24 01:43:18 UTC (rev 463) @@ -14,6 +14,7 @@ import jp.sf.pal.admin.web.site.AbstractSiteSecurityEditorPage; import jp.sf.pal.admin.web.site.FolderAddFolderAndPageEditorPage; import jp.sf.pal.admin.web.site.FolderInfoEditorPage; +import jp.sf.pal.admin.web.site.FolderOrderEditorPage; import jp.sf.pal.admin.web.site.FolderSecurityEditorPage; import jp.sf.pal.admin.web.site.LayoutAddPortletEditorPage; import jp.sf.pal.admin.web.site.LayoutInfoEditorPage; @@ -137,6 +138,19 @@ } + public void loadPage(FolderOrderEditorPage page) throws CommonException { + if (!getSiteEditorLogic().checkFolderOrPageViewAccess(page.getPath())) { + throw new CommonException("could.not.access.path", + "Could not access a path: " + page.getPath()); + } + + loadTree(page); + + page.setDocumentItems(getSiteEditorLogic().createDocumentOrderList( + page.getPath())); + + } + public void loadPage(FolderSecurityEditorPage page) throws CommonException { if (!getSiteEditorLogic().checkFolderOrPageViewAccess(page.getPath())) { throw new CommonException("could.not.access.path", @@ -248,6 +262,29 @@ } } + public void moveDocumentUp(FolderOrderEditorPage page) + throws CommonException { + getSiteEditorLogic().moveDocumentUp(page.getPath(), page.getDocument()); + } + + public void moveDocumentDown(FolderOrderEditorPage page) + throws CommonException { + getSiteEditorLogic().moveDocumentDown(page.getPath(), + page.getDocument()); + } + + public void addDocumentOrder(FolderOrderEditorPage page) + throws CommonException { + getSiteEditorLogic().addDocumentOrder(page.getPath(), + page.getDocumentName()); + } + + public void deleteDocumentOrder(FolderOrderEditorPage page) + throws CommonException { + getSiteEditorLogic().deleteDocumentOrder(page.getPath(), + page.getDocument()); + } + public void updateLayout(LayoutInfoEditorPage page) throws CommonException { getSiteEditorLogic().updateLayout(page.getPath(), page.getLayoutName(), page.getDecorator(), page.getDesktopTheme());