svnno****@sourc*****
svnno****@sourc*****
2007年 7月 22日 (日) 22:39:28 JST
Revision: 324 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=324 Author: shinsuke Date: 2007-07-22 22:39:27 +0900 (Sun, 22 Jul 2007) Log Message: ----------- added page security configuration, and code alignment. Modified Paths: -------------- pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/filter/SiteEditorFilter.java 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 pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PALAdminUtil.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PortalComponentUtil.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/AbstractSiteEditorPage.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/FolderAddFolderAndPageEditorPage.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/FolderInfoEditorPage.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/LayoutAddPortletEditorPage.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/LayoutInfoEditorPage.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/PageInfoEditorPage.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/PortletInfoEditorPage.java pal-admin/trunk/src/main/resources/appMessages.properties pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/site/label.properties pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/site/label_ja.properties pal-admin/trunk/src/main/webapp/view/site/pageInfoEditor.html Added Paths: ----------- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/AbstractSiteSecurityEditorPage.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/PageSecurityEditorPage.java pal-admin/trunk/src/main/webapp/view/site/pageSecurityEditor.html -------------- next part -------------- Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java 2007-07-22 13:39:27 UTC (rev 324) @@ -1,18 +1,17 @@ /* - * 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 - * + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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. + * 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 jp.sf.pal.admin; @@ -46,6 +45,9 @@ public static final String PORTLET_REGISTRY_COMPONENT = PREFIX + "PortletRegistry"; + public static final String PERMISSION_MANAGER_COMPONENT = PREFIX + + "PermissionManager"; + public static final String PORTLET_FACTORY_COMPONENT = PREFIX + "PortletFactory"; @@ -145,4 +147,16 @@ public static final String SEPARATOR = "::"; public static final String SECRET_ANSWER_DISPLAY = "*****************"; + + public static final String SECURITY_CONSTRAINT = "securityConstraint"; + + public static final String SECURITY_CONSTRAINTS_REF = "securityConstraintsRef"; + + public static final String SECURITY_CONSTRAINT_NAME = "securityConstraintName"; + + public static final String SECURITY_CONSTRAINT_TYPE = "securityConstraintType"; + + public static final String SECURITY_CONSTRAINT_PERMISSION = "securityConstraintPermission"; + + public static final String SECURITY_CONSTRAINT_ORDER = "applyOrder"; } Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/filter/SiteEditorFilter.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/filter/SiteEditorFilter.java 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/filter/SiteEditorFilter.java 2007-07-22 13:39:27 UTC (rev 324) @@ -1,3 +1,18 @@ +/* + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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 jp.sf.pal.admin.filter; import java.io.IOException; @@ -17,6 +32,7 @@ import org.apache.jetspeed.decoration.DecorationFactory; import org.apache.jetspeed.page.PageManager; import org.apache.jetspeed.profiler.Profiler; +import org.apache.jetspeed.security.PermissionManager; import org.apache.portals.bridges.portletfilter.PortletFilter; import org.apache.portals.bridges.portletfilter.PortletFilterChain; import org.apache.portals.bridges.portletfilter.PortletFilterConfig; @@ -30,10 +46,14 @@ private PortletRegistry portletRegistry; + private PermissionManager permissionManager; + public void destroy() { pageManager = null; profiler = null; + decorationFactory = null; portletRegistry = null; + permissionManager = null; } public void init(PortletFilterConfig filterConfig) throws PortletException { @@ -72,6 +92,13 @@ "Failed to find the Profiler on portlet initialization"); } + // permissionManager + permissionManager = (PermissionManager) portletContext + .getAttribute(CommonPortletServices.CPS_PERMISSION_MANAGER); + if (null == permissionManager) { + throw new PortletException( + "Failed to find the Profiler on portlet initialization"); + } } public void processActionFilter(ActionRequest request, @@ -84,6 +111,8 @@ decorationFactory); request.setAttribute(PALAdminConstants.PORTLET_REGISTRY_COMPONENT, portletRegistry); + request.setAttribute(PALAdminConstants.PERMISSION_MANAGER_COMPONENT, + permissionManager); chain.processActionFilter(request, response); } @@ -97,6 +126,8 @@ decorationFactory); request.setAttribute(PALAdminConstants.PORTLET_REGISTRY_COMPONENT, portletRegistry); + request.setAttribute(PALAdminConstants.PERMISSION_MANAGER_COMPONENT, + permissionManager); chain.renderFilter(request, response); 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-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SiteEditorLogic.java 2007-07-22 13:39:27 UTC (rev 324) @@ -1,3 +1,18 @@ +/* + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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 jp.sf.pal.admin.logic; import java.io.Serializable; @@ -11,6 +26,7 @@ import jp.sf.pal.admin.PALAdminConstants; import jp.sf.pal.admin.entity.NodeInfo; +import jp.sf.pal.admin.util.PALAdminUtil; import jp.sf.pal.admin.util.PortalComponentUtil; import jp.sf.pal.common.CommonException; @@ -18,6 +34,8 @@ import org.apache.jetspeed.components.portletregistry.PortletRegistry; import org.apache.jetspeed.decoration.DecorationFactory; import org.apache.jetspeed.decoration.LayoutInfo; +import org.apache.jetspeed.om.common.SecurityConstraint; +import org.apache.jetspeed.om.common.SecurityConstraints; import org.apache.jetspeed.om.common.portlet.MutablePortletApplication; import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite; import org.apache.jetspeed.om.folder.Folder; @@ -25,15 +43,20 @@ import org.apache.jetspeed.om.folder.InvalidFolderException; import org.apache.jetspeed.om.page.Fragment; import org.apache.jetspeed.om.page.Page; +import org.apache.jetspeed.om.page.SecurityConstraintsDef; import org.apache.jetspeed.page.FolderNotUpdatedException; import org.apache.jetspeed.page.PageManager; import org.apache.jetspeed.page.PageNotFoundException; import org.apache.jetspeed.page.PageNotUpdatedException; import org.apache.jetspeed.page.document.DocumentException; +import org.apache.jetspeed.page.document.DocumentNotFoundException; import org.apache.jetspeed.page.document.Node; import org.apache.jetspeed.page.document.NodeException; +import org.apache.jetspeed.page.document.UnsupportedDocumentTypeException; import org.apache.jetspeed.profiler.Profiler; import org.apache.jetspeed.request.RequestContext; +import org.apache.jetspeed.security.PermissionManager; +import org.apache.jetspeed.security.om.InternalPermission; import org.seasar.framework.log.Logger; public class SiteEditorLogic implements Serializable { @@ -56,6 +79,8 @@ private transient DecorationFactory decorationFactory = null; + private transient PermissionManager permissionManager = null; + private transient RequestContext requestContext = null; /** @@ -110,7 +135,7 @@ } /** - * @return the profiler + * @return the decorationFactory */ public DecorationFactory getDecorationFactory() { if (decorationFactory == null) { @@ -120,13 +145,30 @@ } /** - * @param profiler the profiler to set + * @param decorationFactory the decorationFactory to set */ public void setDecorationFactory(DecorationFactory decorationFactory) { this.decorationFactory = decorationFactory; } /** + * @return the permissionManager + */ + public PermissionManager getPermissionManager() { + if (permissionManager == null) { + permissionManager = PortalComponentUtil.getPermissionManager(); + } + return permissionManager; + } + + /** + * @param permissionManager the permissionManager to set + */ + public void setPermissionManager(PermissionManager permissionManager) { + this.permissionManager = permissionManager; + } + + /** * @return the profiler */ public RequestContext getRequestContext() { @@ -453,6 +495,57 @@ return list; } + public List<Map<String, String>> createSecurityConstraintsRefsList() + throws CommonException { + List<Map<String, String>> list = new ArrayList<Map<String, String>>(); + try { + for (Iterator<SecurityConstraintsDef> itr = getPageManager() + .getPageSecurity().getSecurityConstraintsDefs().iterator(); itr + .hasNext();) { + Map<String, String> map = new HashMap<String, String>(); + SecurityConstraintsDef value = itr.next(); + map.put("label", value.getName()); + map.put("value", value.getName()); + list.add(map); + } + } catch (UnsupportedDocumentTypeException e) { + logger.error("Could not access a page security. ", e); + throw new CommonException("could.not.access.page.security", + "Could not access a page security. ", e); + } catch (DocumentNotFoundException e) { + logger.error("Could not access a page security. ", e); + throw new CommonException("could.not.access.page.security", + "Could not access a page security. ", e); + } catch (NodeException e) { + logger.error("Could not access a page security. ", e); + throw new CommonException("could.not.access.page.security", + "Could not access a page security. ", e); + } + return list; + } + + public List<Map<String, String>> createPermissionsList() + throws CommonException { + List<Map<String, String>> list = new ArrayList<Map<String, String>>(); + //TODO + Map<String, String> map = null; + + map = new HashMap<String, String>(); + map.put("label", "View"); + map.put("value", "view"); + list.add(map); + map = new HashMap<String, String>(); + map.put("label", "Edit"); + map.put("value", "edit"); + list.add(map); + map = new HashMap<String, String>(); + map.put("label", "Help"); + map.put("value", "help"); + list.add(map); + + return list; + } + public Map<String, Object> getPageInfo(String path) throws CommonException { Map<String, Object> map = new HashMap<String, Object>(); @@ -1020,7 +1113,7 @@ throws CommonException { Page page = getPage(getFolderOrPagePath(path)); if (page == null) { - throw new CommonException("could.not.find.portlet", + throw new CommonException("could.not.find.page", "Could not find a page: " + path); } String fid = getFragmentId(path); @@ -1044,4 +1137,177 @@ "Could not update a page: " + path, e); } } + + public List<Map<String, Object>> getSecurityConstraints(String path) + throws CommonException { + path = getFolderOrPagePath(path); + + List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); + if (path.endsWith(".psml")) { + // page + Page page = getPage(path); + SecurityConstraints constraints = page.getSecurityConstraints(); + if (constraints != null) { + List<SecurityConstraint> scs = constraints + .getSecurityConstraints(); + for (int i = 0; i < scs.size(); i++) { + SecurityConstraint constraint = scs.get(i); + Map<String, Object> map = new HashMap<String, Object>(); + + List<String> users = constraint.getUsers(); + List<String> groups = constraint.getGroups(); + List<String> roles = constraint.getRoles(); + + StringBuffer cname = new StringBuffer(); + if (users != null && !users.isEmpty()) { + cname.append("users(").append( + PALAdminUtil.formatCSVList(users)).append(") "); + } + if (groups != null && !groups.isEmpty()) { + cname.append("groups(").append( + PALAdminUtil.formatCSVList(groups)) + .append(") "); + } + if (roles != null && !roles.isEmpty()) { + cname.append("roles(").append( + PALAdminUtil.formatCSVList(roles)).append(") "); + } + map.put(PALAdminConstants.SECURITY_CONSTRAINT_NAME, cname + .toString()); + + List<String> permissions = constraint.getPermissions(); + map.put(PALAdminConstants.SECURITY_CONSTRAINT_PERMISSION, + PALAdminUtil.formatCSVList(permissions)); + + map.put(PALAdminConstants.SECURITY_CONSTRAINT_TYPE, + PALAdminConstants.SECURITY_CONSTRAINT); + map.put(PALAdminConstants.SECURITY_CONSTRAINT_ORDER, i); + list.add(map); + } + + List<String> scrs = constraints.getSecurityConstraintsRefs(); + for (int i = 0; i < scrs.size(); i++) { + Map<String, Object> map = new HashMap<String, Object>(); + map.put(PALAdminConstants.SECURITY_CONSTRAINT_NAME, scrs + .get(i)); + map.put(PALAdminConstants.SECURITY_CONSTRAINT_TYPE, + PALAdminConstants.SECURITY_CONSTRAINTS_REF); + map.put(PALAdminConstants.SECURITY_CONSTRAINT_ORDER, i); + list.add(map); + } + } + } else { + // TODO folder + } + return list; + } + + public void addConstraint(String path, List<String> users, + List<String> roles, List<String> groups, List<String> permissions) + throws CommonException { + Page page = getPage(getFolderOrPagePath(path)); + if (page == null) { + throw new CommonException("could.not.find.page", + "Could not find a page: " + path); + } + SecurityConstraint sc = getPageManager().newPageSecurityConstraint(); + sc.setUsers(users); + sc.setRoles(roles); + sc.setGroups(groups); + sc.setPermissions(permissions); + + if (page.getSecurityConstraints() == null) { + page.setSecurityConstraints(getPageManager() + .newSecurityConstraints()); + } + page.getSecurityConstraints().getSecurityConstraints().add(sc); + + try { + getPageManager().updatePage(page); + } catch (PageNotUpdatedException e) { + throw new CommonException("could.not.update.page", + "Could not update a page: " + path, e); + } catch (NodeException e) { + throw new CommonException("could.not.update.page", + "Could not update a page: " + path, e); + } + } + + public void addConstraintRef(String path, String constraintRef) + throws CommonException { + Page page = getPage(getFolderOrPagePath(path)); + if (page == null) { + throw new CommonException("could.not.find.page", + "Could not find a page: " + path); + } + + if (page.getSecurityConstraints() == null) { + page.setSecurityConstraints(getPageManager() + .newSecurityConstraints()); + } + page.getSecurityConstraints().getSecurityConstraintsRefs().add( + constraintRef); + + try { + getPageManager().updatePage(page); + } catch (PageNotUpdatedException e) { + throw new CommonException("could.not.update.page", + "Could not update a page: " + path, e); + } catch (NodeException e) { + throw new CommonException("could.not.update.page", + "Could not update a page: " + path, e); + } + } + + public void removeConstraint(String path, int applyOrder) + throws CommonException { + Page page = getPage(getFolderOrPagePath(path)); + if (page == null) { + throw new CommonException("could.not.find.page", + "Could not find a page: " + path); + } + + if (page.getSecurityConstraints() == null) { + throw new CommonException("could.not.find.page.security", + "Could not find a page security: " + path); + } + page.getSecurityConstraints().getSecurityConstraints().remove( + applyOrder); + + try { + getPageManager().updatePage(page); + } catch (PageNotUpdatedException e) { + throw new CommonException("could.not.update.page", + "Could not update a page: " + path, e); + } catch (NodeException e) { + throw new CommonException("could.not.update.page", + "Could not update a page: " + path, e); + } + } + + public void removeConstraintRef(String path, int applyOrder) + throws CommonException { + Page page = getPage(getFolderOrPagePath(path)); + if (page == null) { + throw new CommonException("could.not.find.page", + "Could not find a page: " + path); + } + + if (page.getSecurityConstraints() == null) { + throw new CommonException("could.not.find.page.security", + "Could not find a page security: " + path); + } + page.getSecurityConstraints().getSecurityConstraintsRefs().remove( + applyOrder); + + try { + getPageManager().updatePage(page); + } catch (PageNotUpdatedException e) { + throw new CommonException("could.not.update.page", + "Could not update a page: " + path, e); + } catch (NodeException e) { + throw new CommonException("could.not.update.page", + "Could not update a page: " + path, e); + } + } } 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-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/SiteEditorService.java 2007-07-22 13:39:27 UTC (rev 324) @@ -7,12 +7,15 @@ import jp.sf.pal.admin.dxo.SiteEditorDxo; import jp.sf.pal.admin.entity.NodeInfo; import jp.sf.pal.admin.logic.SiteEditorLogic; +import jp.sf.pal.admin.util.PALAdminUtil; import jp.sf.pal.admin.web.site.AbstractSiteEditorPage; +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.LayoutAddPortletEditorPage; import jp.sf.pal.admin.web.site.LayoutInfoEditorPage; import jp.sf.pal.admin.web.site.PageInfoEditorPage; +import jp.sf.pal.admin.web.site.PageSecurityEditorPage; import jp.sf.pal.admin.web.site.PortletInfoEditorPage; import jp.sf.pal.common.CommonException; @@ -54,6 +57,12 @@ this.siteEditorDxo = siteEditorDxo; } + protected void loadSecurityConstraints(AbstractSiteSecurityEditorPage page) + throws CommonException { + page.setSecurityConstraintItems(getSiteEditorLogic() + .getSecurityConstraints(page.getPath())); + } + public void loadPage(PageInfoEditorPage page) throws CommonException { loadTree(page); @@ -68,6 +77,15 @@ getSiteEditorLogic().getPageInfo(page.getPath()), page); } + public void loadPage(PageSecurityEditorPage page) throws CommonException { + loadTree(page); + loadSecurityConstraints(page); + + page.setPermissionsItems(getSiteEditorLogic().createPermissionsList()); + page.setSecurityConstraintsRefItems(getSiteEditorLogic() + .createSecurityConstraintsRefsList()); + } + public void loadPage(FolderInfoEditorPage page) throws CommonException { loadTree(page); @@ -270,4 +288,52 @@ page.getPortletDecorator(), page.getDesktopTheme(), page.isFolderOrPageHidden()); } + + public void addConstraint(PageSecurityEditorPage page) + throws CommonException { + List<String> users = PALAdminUtil.parseCSVList(page.getUsers()); + List<String> roles = PALAdminUtil.parseCSVList(page.getRoles()); + List<String> groups = PALAdminUtil.parseCSVList(page.getGroups()); + if (users.isEmpty() && roles.isEmpty() && groups.isEmpty()) { + throw new CommonException("need.to.specify.users.roles.groups", + "users, roles and groups are empty"); + } + + if (page.getPermissions() == null || page.getPermissions().length == 0) { + throw new CommonException("need.to.specify.permissions", + "permissions are empty"); + } + String[] p = page.getPermissions(); + List<String> permissions = new ArrayList<String>(); + for (int i = 0; i < p.length; i++) { + permissions.add(p[i]); + } + + getSiteEditorLogic().addConstraint(page.getPath(), users, roles, + groups, permissions); + } + + public void addConstraintRef(PageSecurityEditorPage page) + throws CommonException { + if (page.getSecurityConstraintsRef() == null) { + throw new CommonException( + "need.to.specify.security.constraint.ref", + "Security ConstraintRef is empty"); + } + + getSiteEditorLogic().addConstraintRef(page.getPath(), + page.getSecurityConstraintsRef()); + } + + public void removeConstraint(PageSecurityEditorPage page) + throws CommonException { + getSiteEditorLogic().removeConstraint(page.getPath(), + page.getApplyOrder().intValue()); + } + + public void removeConstraintRef(PageSecurityEditorPage page) + throws CommonException { + getSiteEditorLogic().removeConstraintRef(page.getPath(), + page.getApplyOrder().intValue()); + } } Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PALAdminUtil.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PALAdminUtil.java 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PALAdminUtil.java 2007-07-22 13:39:27 UTC (rev 324) @@ -1,18 +1,17 @@ /* - * 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 - * + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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. + * 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 jp.sf.pal.admin.util; @@ -25,6 +24,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.StringTokenizer; import javax.faces.context.FacesContext; import javax.portlet.PortletConfig; @@ -32,18 +32,15 @@ import jp.sf.pal.admin.PALAdminConstants; -public class PALAdminUtil -{ +public class PALAdminUtil { /** * @return the facesContext */ - private static FacesContext getFacesContext() - { + private static FacesContext getFacesContext() { return FacesContext.getCurrentInstance(); } - public static boolean isEmpty(String s) - { + public static boolean isEmpty(String s) { if (s == null) return true; @@ -53,15 +50,12 @@ return false; } - public static Principal getPrincipal(Subject subject, Class cls) - { + public static Principal getPrincipal(Subject subject, Class cls) { Principal principal = null; Iterator principals = subject.getPrincipals().iterator(); - while (principals.hasNext()) - { + while (principals.hasNext()) { Principal p = (Principal) principals.next(); - if (cls.isInstance(p)) - { + if (cls.isInstance(p)) { principal = p; break; } @@ -69,119 +63,127 @@ return principal; } - public static Map<String, String> createItem(String label, String value) - { + public static Map<String, String> createItem(String label, String value) { Map<String, String> map = new HashMap<String, String>(); map.put("label", label); map.put("value", value); return map; } - public static List<Map<String, String>> createItems(Iterator<String> items) - { + public static List<Map<String, String>> createItems(Iterator<String> items) { ArrayList<Map<String, String>> list = new ArrayList<Map<String, String>>(); - while (items.hasNext()) - { + while (items.hasNext()) { String value = items.next(); list.add(PALAdminUtil.createItem(value, value)); } return list; } - public static String toStringFromList(List<String> list) - { + public static String toStringFromList(List<String> list) { StringBuffer buf = new StringBuffer(); - for (Iterator<String> ite = list.iterator(); ite.hasNext();) - { + for (Iterator<String> ite = list.iterator(); ite.hasNext();) { buf.append(ite.next()); - if (ite.hasNext()) - { + if (ite.hasNext()) { buf.append(", "); } } return buf.toString(); } - public static String toStringFromArray(Object[] strs) - { + public static String toStringFromArray(Object[] strs) { StringBuffer buf = new StringBuffer(); - for (int i = 0; i < strs.length; i++) - { + for (int i = 0; i < strs.length; i++) { buf.append(strs[i].toString()); - if (i + 1 < strs.length) - { + if (i + 1 < strs.length) { buf.append(", "); } } return buf.toString(); } - public static void drain(InputStream in, OutputStream out) throws IOException - { - try - { + public static void drain(InputStream in, OutputStream out) + throws IOException { + try { byte[] buf = new byte[8192]; int len = in.read(buf); - while (len != -1) - { + while (len != -1) { out.write(buf, 0, len); len = in.read(buf); } out.flush(); - } - catch (IOException e) - { + } catch (IOException e) { throw e; - } - finally - { - try - { + } finally { + try { out.close(); + } catch (IOException e) { } - catch (IOException e) - { - } - try - { + try { in.close(); + } catch (IOException e) { } - catch (IOException e) - { - } } } - public static void setPasswordToSession(String value) - { - getFacesContext().getExternalContext().getSessionMap().put(PALAdminConstants.PASSWORD, value); + public static void setPasswordToSession(String value) { + getFacesContext().getExternalContext().getSessionMap().put( + PALAdminConstants.PASSWORD, value); } - public static String getPasswordFromSession() - { - return (String) getFacesContext().getExternalContext().getSessionMap().get(PALAdminConstants.PASSWORD); + public static String getPasswordFromSession() { + return (String) getFacesContext().getExternalContext().getSessionMap() + .get(PALAdminConstants.PASSWORD); } - public static void removePasswordFromSession() - { - getFacesContext().getExternalContext().getSessionMap().remove(PALAdminConstants.PASSWORD); + public static void removePasswordFromSession() { + getFacesContext().getExternalContext().getSessionMap().remove( + PALAdminConstants.PASSWORD); } - public static String getContextRealPath(String path) - { + public static String getContextRealPath(String path) { return getPortletConfig().getPortletContext().getRealPath(path); } - public static PortletConfig getPortletConfig() - { + public static PortletConfig getPortletConfig() { String name = "javax.portlet.PortletConfig"; FacesContext context = FacesContext.getCurrentInstance(); - if (context == null) - { - throw new IllegalStateException("Could not find FacesContext instance."); + if (context == null) { + throw new IllegalStateException( + "Could not find FacesContext instance."); } - return (PortletConfig) context.getExternalContext().getRequestMap().get(name); + return (PortletConfig) context.getExternalContext().getRequestMap() + .get(name); } + public static String formatCSVList(List<String> list) { + if ((list != null) && !list.isEmpty()) { + StringBuffer csv = new StringBuffer(); + Iterator<String> listIter = list.iterator(); + while (listIter.hasNext()) { + if (csv.length() > 0) { + csv.append(","); + } + csv.append((String) listIter.next()); + } + return csv.toString(); + } + return ""; + } + + public static List<String> parseCSVList(String csv) { + List<String> csvList = new ArrayList<String>(); + if (csv != null) { + if (csv.indexOf(',') != -1) { + StringTokenizer csvTokens = new StringTokenizer(csv, ","); + while (csvTokens.hasMoreTokens()) { + csvList.add(csvTokens.nextToken().trim()); + } + } else { + csvList.add(csv); + } + } + return csvList; + } + } Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PortalComponentUtil.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PortalComponentUtil.java 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PortalComponentUtil.java 2007-07-22 13:39:27 UTC (rev 324) @@ -1,18 +1,17 @@ /* - * 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 - * + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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. + * 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 jp.sf.pal.admin.util; @@ -28,86 +27,91 @@ import org.apache.jetspeed.page.PageManager; import org.apache.jetspeed.profiler.Profiler; import org.apache.jetspeed.security.GroupManager; +import org.apache.jetspeed.security.PermissionManager; import org.apache.jetspeed.security.RoleManager; import org.apache.jetspeed.security.SecurityProvider; import org.apache.jetspeed.security.UserManager; import org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager; -public class PortalComponentUtil -{ +public class PortalComponentUtil { /** * @return the facesContext */ - private static FacesContext getFacesContext() - { + private static FacesContext getFacesContext() { return FacesContext.getCurrentInstance(); } - public static UserManager getUserManager() - { - return (UserManager) getFacesContext().getExternalContext().getRequestMap().get(PALAdminConstants.USER_MANAGER_COMPONENT); + public static UserManager getUserManager() { + return (UserManager) getFacesContext().getExternalContext() + .getRequestMap().get(PALAdminConstants.USER_MANAGER_COMPONENT); } - public static RoleManager getRoleManager() - { - return (RoleManager) getFacesContext().getExternalContext().getRequestMap().get(PALAdminConstants.ROLE_MANAGER_COMPONENT); + public static RoleManager getRoleManager() { + return (RoleManager) getFacesContext().getExternalContext() + .getRequestMap().get(PALAdminConstants.ROLE_MANAGER_COMPONENT); } - public static GroupManager getGroupManager() - { - return (GroupManager) getFacesContext().getExternalContext().getRequestMap().get(PALAdminConstants.GROUP_MANAGER_COMPONENT); + public static GroupManager getGroupManager() { + return (GroupManager) getFacesContext().getExternalContext() + .getRequestMap().get(PALAdminConstants.GROUP_MANAGER_COMPONENT); } - public static Profiler getProfiler() - { - return (Profiler) getFacesContext().getExternalContext().getRequestMap().get(PALAdminConstants.PROFILER_COMPONENT); + public static Profiler getProfiler() { + return (Profiler) getFacesContext().getExternalContext() + .getRequestMap().get(PALAdminConstants.PROFILER_COMPONENT); } - public static PageManager getPageManager() - { - return (PageManager) getFacesContext().getExternalContext().getRequestMap().get(PALAdminConstants.PAGE_MANAGER_COMPONENT); + public static PageManager getPageManager() { + return (PageManager) getFacesContext().getExternalContext() + .getRequestMap().get(PALAdminConstants.PAGE_MANAGER_COMPONENT); } - public static SecurityProvider getSecurityProvider() - { - return (SecurityProvider) getFacesContext().getExternalContext().getRequestMap().get( - PALAdminConstants.SECURITY_PROVIDER_COMPONENT); + public static SecurityProvider getSecurityProvider() { + return (SecurityProvider) getFacesContext().getExternalContext() + .getRequestMap().get( + PALAdminConstants.SECURITY_PROVIDER_COMPONENT); } - public static ApplicationServerManager getApplicationServerManager() - { - return (ApplicationServerManager) getFacesContext().getExternalContext().getRequestMap().get( - PALAdminConstants.APPLICATION_SERVER_MANAGER_COMPONENT); + public static ApplicationServerManager getApplicationServerManager() { + return (ApplicationServerManager) getFacesContext() + .getExternalContext().getRequestMap().get( + PALAdminConstants.APPLICATION_SERVER_MANAGER_COMPONENT); } - public static PortletRegistry getPortletRegistry() - { - return (PortletRegistry) getFacesContext().getExternalContext().getRequestMap().get( - PALAdminConstants.PORTLET_REGISTRY_COMPONENT); + public static PortletRegistry getPortletRegistry() { + return (PortletRegistry) getFacesContext().getExternalContext() + .getRequestMap().get( + PALAdminConstants.PORTLET_REGISTRY_COMPONENT); } - public static PortletFactory getPortletFactory() - { - return (PortletFactory) getFacesContext().getExternalContext().getRequestMap().get( - PALAdminConstants.PORTLET_FACTORY_COMPONENT); + public static PortletFactory getPortletFactory() { + return (PortletFactory) getFacesContext().getExternalContext() + .getRequestMap().get( + PALAdminConstants.PORTLET_FACTORY_COMPONENT); } - public static DeploymentManager getDeploymentManager() - { - return (DeploymentManager) getFacesContext().getExternalContext().getRequestMap().get( - PALAdminConstants.DEPLOYMENT_MANAGER_COMPONENT); + public static DeploymentManager getDeploymentManager() { + return (DeploymentManager) getFacesContext().getExternalContext() + .getRequestMap().get( + PALAdminConstants.DEPLOYMENT_MANAGER_COMPONENT); } - public static PortalAdministration getPortalAdministration() - { - return (PortalAdministration) getFacesContext().getExternalContext().getRequestMap().get( - PALAdminConstants.PORTAL_ADMINISTRATION_COMPONENT); + public static PortalAdministration getPortalAdministration() { + return (PortalAdministration) getFacesContext().getExternalContext() + .getRequestMap().get( + PALAdminConstants.PORTAL_ADMINISTRATION_COMPONENT); } - public static DecorationFactory getDecorationFactory() - { - return (DecorationFactory) getFacesContext().getExternalContext().getRequestMap().get( - PALAdminConstants.DECORATION_FACTORY_COMPONENT); + public static DecorationFactory getDecorationFactory() { + return (DecorationFactory) getFacesContext().getExternalContext() + .getRequestMap().get( + PALAdminConstants.DECORATION_FACTORY_COMPONENT); } + public static PermissionManager getPermissionManager() { + return (PermissionManager) getFacesContext().getExternalContext() + .getRequestMap().get( + PALAdminConstants.PERMISSION_MANAGER_COMPONENT); + } + } Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/AbstractSiteEditorPage.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/AbstractSiteEditorPage.java 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/AbstractSiteEditorPage.java 2007-07-22 13:39:27 UTC (rev 324) @@ -1,3 +1,18 @@ +/* + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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 jp.sf.pal.admin.web.site; import java.util.List; @@ -4,6 +19,8 @@ import javax.faces.context.FacesContext; +import org.seasar.teeda.extension.util.LabelHelper; + import jp.sf.pal.admin.entity.NodeInfo; import jp.sf.pal.admin.service.SiteEditorService; @@ -20,7 +37,23 @@ private SiteEditorService siteEditorService; + private LabelHelper labelHelper; + /** + * @return the labelHelper + */ + public LabelHelper getLabelHelper() { + return labelHelper; + } + + /** + * @param labelHelper the labelHelper to set + */ + public void setLabelHelper(LabelHelper labelHelper) { + this.labelHelper = labelHelper; + } + + /** * @return the name */ public String getName() { Added: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/AbstractSiteSecurityEditorPage.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/AbstractSiteSecurityEditorPage.java 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/AbstractSiteSecurityEditorPage.java 2007-07-22 13:39:27 UTC (rev 324) @@ -0,0 +1,217 @@ +/* + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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 jp.sf.pal.admin.web.site; + +import java.util.List; +import java.util.Map; + +import jp.sf.pal.admin.PALAdminConstants; + +public abstract class AbstractSiteSecurityEditorPage extends + AbstractSiteEditorPage { + + private String securityConstraintName; + + private String groups; + + private String roles; + + private int securityConstraintIndex; + + private List<Map<String, Object>> securityConstraintItems; + + private String securityConstraintsRef; + + private List<Map<String, String>> securityConstraintsRefItems; + + private String users; + + private Integer applyOrder; + + private String securityConstraintType; + + private String action; + + private String[] permissions; + + private List<Map<String, String>> permissionsItems; + + /** + * @return the action + */ + public String getAction() { + return action; + } + + /** + * @param action the action to set + */ + public void setAction(String action) { + this.action = action; + } + + /** + * @return the permissions + */ + public String[] getPermissions() { + return permissions; + } + + /** + * @param permissions the permissions to set + */ + public void setPermissions(String[] permissions) { + this.permissions = permissions; + } + + /** + * @return the permissionsItems + */ + public List<Map<String, String>> getPermissionsItems() { + return permissionsItems; + } + + /** + * @param permissionsItems the permissionsItems to set + */ + public void setPermissionsItems(List<Map<String, String>> permissionsItems) { + this.permissionsItems = permissionsItems; + } + + public String getSecurityConstraintName() { + return securityConstraintName; + } + + public void setSecurityConstraintName(String constraintName) { + this.securityConstraintName = constraintName; + } + + public String getSecurityConstraintTypeName() { + if (securityConstraintItems == null + || securityConstraintItems.isEmpty() + || securityConstraintIndex >= securityConstraintItems.size()) { + return null; + } + Map<String, Object> map = securityConstraintItems + .get(securityConstraintIndex); + return getLabelHelper().getLabelValue( + (String) map.get(PALAdminConstants.SECURITY_CONSTRAINT_TYPE) + + "Type"); + } + + public String getSecurityConstraintPermissionName() { + if (securityConstraintItems == null + || securityConstraintItems.isEmpty() + || securityConstraintIndex >= securityConstraintItems.size()) { + return null; + } + Map<String, Object> map = securityConstraintItems + .get(securityConstraintIndex); + String permission = (String) map + .get(PALAdminConstants.SECURITY_CONSTRAINT_PERMISSION); + if (permission != null) { + return permission; + } + return "-"; + } + + public String getGroups() { + return groups; + } + + public void setGroups(String groups) { + this.groups = groups; + } + + public String getRoles() { + return roles; + } + + public void setRoles(String roles) { + this.roles = roles; + } + + public int getSecurityConstraintIndex() { + return securityConstraintIndex; + } + + public void setSecurityConstraintIndex(int securityConstraintIndex) { + this.securityConstraintIndex = securityConstraintIndex; + } + + public List<Map<String, Object>> getSecurityConstraintItems() { + return securityConstraintItems; + } + + public void setSecurityConstraintItems( + List<Map<String, Object>> securityConstraintItems) { + this.securityConstraintItems = securityConstraintItems; + } + + public String getSecurityConstraintsRef() { + return securityConstraintsRef; + } + + public void setSecurityConstraintsRef(String securityConstraintsRef) { + this.securityConstraintsRef = securityConstraintsRef; + } + + public List<Map<String, String>> getSecurityConstraintsRefItems() { + return securityConstraintsRefItems; + } + + public void setSecurityConstraintsRefItems( + List<Map<String, String>> securityConstraintsRefItems) { + this.securityConstraintsRefItems = securityConstraintsRefItems; + } + + public String getUsers() { + return users; + } + + public void setUsers(String users) { + this.users = users; + } + + /** + * @return the applyOrder + */ + public Integer getApplyOrder() { + return applyOrder; + } + + /** + * @param applyOrder the applyOrder to set + */ + public void setApplyOrder(Integer applyOrder) { + this.applyOrder = applyOrder; + } + + /** + * @return the securityConstraintType + */ + public String getSecurityConstraintType() { + return securityConstraintType; + } + + /** + * @param securityConstraintType the securityConstraintType to set + */ + public void setSecurityConstraintType(String securityConstraintType) { + this.securityConstraintType = securityConstraintType; + } + +} Property changes on: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/AbstractSiteSecurityEditorPage.java ___________________________________________________________________ Name: svn:eol-style + native Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/FolderAddFolderAndPageEditorPage.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/FolderAddFolderAndPageEditorPage.java 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/FolderAddFolderAndPageEditorPage.java 2007-07-22 13:39:27 UTC (rev 324) @@ -1,3 +1,18 @@ +/* + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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 jp.sf.pal.admin.web.site; import java.io.Serializable; Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/FolderInfoEditorPage.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/FolderInfoEditorPage.java 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/FolderInfoEditorPage.java 2007-07-22 13:39:27 UTC (rev 324) @@ -1,3 +1,18 @@ +/* + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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 jp.sf.pal.admin.web.site; import java.io.Serializable; Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/LayoutAddPortletEditorPage.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/LayoutAddPortletEditorPage.java 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/LayoutAddPortletEditorPage.java 2007-07-22 13:39:27 UTC (rev 324) @@ -1,3 +1,18 @@ +/* + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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 jp.sf.pal.admin.web.site; import java.io.Serializable; Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/LayoutInfoEditorPage.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/LayoutInfoEditorPage.java 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/LayoutInfoEditorPage.java 2007-07-22 13:39:27 UTC (rev 324) @@ -1,3 +1,18 @@ +/* + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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 jp.sf.pal.admin.web.site; import java.io.Serializable; Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/PageInfoEditorPage.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/PageInfoEditorPage.java 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/PageInfoEditorPage.java 2007-07-22 13:39:27 UTC (rev 324) @@ -1,3 +1,18 @@ +/* + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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 jp.sf.pal.admin.web.site; import java.io.Serializable; Added: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/PageSecurityEditorPage.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/PageSecurityEditorPage.java 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/PageSecurityEditorPage.java 2007-07-22 13:39:27 UTC (rev 324) @@ -0,0 +1,145 @@ +/* + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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 jp.sf.pal.admin.web.site; + +import java.io.Serializable; + +import javax.faces.internal.FacesMessageUtil; + +import jp.sf.pal.admin.PALAdminConstants; +import jp.sf.pal.common.CommonException; + +import org.seasar.framework.log.Logger; +import org.seasar.teeda.extension.annotation.takeover.TakeOver; +import org.seasar.teeda.extension.annotation.takeover.TakeOverType; + +public class PageSecurityEditorPage extends AbstractSiteSecurityEditorPage + implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 5074641483347337061L; + + /** + * Logger for this class + */ + private static final Logger logger = Logger + .getLogger(PageSecurityEditorPage.class); + + public Class<?> initialize() { + return null; + } + + public Class<?> prerender() { + if (getPath() == null) { + setPath("/default-page.psml"); + return PageInfoEditorPage.class; + } + + if (getReturnPath() == null) { + setReturnPath("/"); + } + + if (getApplyOrder() != null && getSecurityConstraintType() != null + && "delete".equals(getAction())) { + // delete + if (PALAdminConstants.SECURITY_CONSTRAINT + .equals(getSecurityConstraintType())) { + doRemoveConstraint(); + } else if (PALAdminConstants.SECURITY_CONSTRAINTS_REF + .equals(getSecurityConstraintType())) { + doRemoveConstraintRef(); + } + + setApplyOrder(null); + setSecurityConstraintType(null); + } + + try { + getSiteEditorService().loadPage(this); + } catch (CommonException e) { + FacesMessageUtil.addErrorMessage(e.getMessageId()); + logger.log("EPA0001", new Object[] { this.toString() }, e); + } + return null; + } + + @TakeOver(type = TakeOverType.INCLUDE, properties = "path,returnPath") + public Class<?> doAddConstraint() { + try { + getSiteEditorService().addConstraint(this); + FacesMessageUtil.addInfoMessage("added.page.security"); + return PageSecurityEditorPage.class; + } catch (CommonException e) { + FacesMessageUtil.addErrorMessage(e.getMessageId()); + logger.log("EPA0002", new Object[] { this.toString() }, e); + } catch (Exception e) { + FacesMessageUtil.addErrorMessage("could.not.add.page.security"); + logger.log("EPA0002", new Object[] { this.toString() }, e); + } + return null; + } + + @TakeOver(type = TakeOverType.INCLUDE, properties = "path,returnPath") + public Class<?> doAddConstraintRef() { + try { + getSiteEditorService().addConstraintRef(this); + FacesMessageUtil.addInfoMessage("added.page.security"); + return PageSecurityEditorPage.class; + } catch (CommonException e) { + FacesMessageUtil.addErrorMessage(e.getMessageId()); + logger.log("EPA0002", new Object[] { this.toString() }, e); + } catch (Exception e) { + FacesMessageUtil.addErrorMessage("could.not.add.page.security"); + logger.log("EPA0002", new Object[] { this.toString() }, e); + } + return null; + } + + @TakeOver(type = TakeOverType.INCLUDE, properties = "path,returnPath") + public Class<?> doRemoveConstraint() { + try { + getSiteEditorService().removeConstraint(this); + FacesMessageUtil.addInfoMessage("removed.page.security"); + return PageSecurityEditorPage.class; + } catch (CommonException e) { + FacesMessageUtil.addErrorMessage(e.getMessageId()); + logger.log("EPA0002", new Object[] { this.toString() }, e); + } catch (Exception e) { + FacesMessageUtil.addErrorMessage("could.not.remove.page.security"); + logger.log("EPA0002", new Object[] { this.toString() }, e); + } + return null; + } + + @TakeOver(type = TakeOverType.INCLUDE, properties = "path,returnPath") + public Class<?> doRemoveConstraintRef() { + try { + getSiteEditorService().removeConstraintRef(this); + FacesMessageUtil.addInfoMessage("removed.page.security"); + return PageSecurityEditorPage.class; + } catch (CommonException e) { + FacesMessageUtil.addErrorMessage(e.getMessageId()); + logger.log("EPA0002", new Object[] { this.toString() }, e); + } catch (Exception e) { + FacesMessageUtil.addErrorMessage("could.not.remove.page.security"); + logger.log("EPA0002", new Object[] { this.toString() }, e); + } + return null; + } + +} Property changes on: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/PageSecurityEditorPage.java ___________________________________________________________________ Name: svn:eol-style + native Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/PortletInfoEditorPage.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/PortletInfoEditorPage.java 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/PortletInfoEditorPage.java 2007-07-22 13:39:27 UTC (rev 324) @@ -1,3 +1,18 @@ +/* + * Copyright 2005-2007 Portal Application Laboratory and the Others. + * + * Licensed 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 jp.sf.pal.admin.web.site; import java.io.Serializable; Modified: pal-admin/trunk/src/main/resources/appMessages.properties =================================================================== --- pal-admin/trunk/src/main/resources/appMessages.properties 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/resources/appMessages.properties 2007-07-22 13:39:27 UTC (rev 324) @@ -145,4 +145,16 @@ could.not.delete.portlet=Could not delete the portlet. Please try again. If you see this error message again, please contact a site administrator. deleted.portlet=Deleted portlet. -could.not.encode.secret.password=System error occurs. Please contact a site administrator. \ No newline at end of file +could.not.encode.secret.password=System error occurs. Please contact a site administrator. + +could.not.access.page.security=System error occurs. Please contact a site administrator. + +need.to.specify.users.roles.groups=Need to specify users, roles or groups. +need.to.specify.permissions=Need to specify permissions. +added.page.security=Added page security. +could.not.add.page.security=Could not add a page security. Please try again. If you see this error message again, please contact a site administrator. +could.not.find.page.security=Could not find a page security. Please try again. If you see this error message again, please contact a site administrator. +removed.page.security=Added page security. +could.not.remove.page.security=Could not add a page security. Please try again. If you see this error message again, please contact a site administrator. +need.to.specify.security.constraint.ref=Need to specify a security constraint ref. + Modified: pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/site/label.properties =================================================================== --- pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/site/label.properties 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/site/label.properties 2007-07-22 13:39:27 UTC (rev 324) @@ -3,6 +3,9 @@ metadataTab=Metadata addTab=Add +securityConstraintType=Definition +securityConstraintsRefType=Reference + pageInfoEditor.pageTitle=Title: pageInfoEditor.pageShortTitle=Short Title: pageInfoEditor.pageDecorator=Page Decorator: @@ -38,3 +41,15 @@ folderAddFolderAndPageEditor.portletDecorator=Portlet Decorator: folderAddFolderAndPageEditor.desktopTheme=Desktop Theme: folderAddFolderAndPageEditor.folderOrPageHidden=Hide This Folder/Page?: + +pageSecurityEditor.securityConstraint= Security Constraint +pageSecurityEditor.type= Type +pageSecurityEditor.permission= Permission +pageSecurityEditor.action=Action +pageSecurityEditor.delete=Delete +pageSecurityEditor.users=Users: +pageSecurityEditor.groups=Groups: +pageSecurityEditor.roles=Roles: +pageSecurityEditor.permissions=Permissions: +pageSecurityEditor.securityConstraintsRef=Constraint Ref: + Modified: pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/site/label_ja.properties =================================================================== --- pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/site/label_ja.properties 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/site/label_ja.properties 2007-07-22 13:39:27 UTC (rev 324) @@ -3,6 +3,9 @@ metadataTab=\u30e1\u30bf\u30c7\u30fc\u30bf addTab=\u8ffd\u52a0 +securityConstraintType=\u5b9a\u7fa9 +securityConstraintsRefType=\u53c2\u7167 + pageInfoEditor.pageTitle=\u30bf\u30a4\u30c8\u30eb: pageInfoEditor.pageShortTitle=\u77ed\u3044\u30bf\u30a4\u30c8\u30eb: pageInfoEditor.pageDecorator=\u30da\u30fc\u30b8\u30c7\u30b3\u30ec\u30fc\u30bf:: @@ -28,4 +31,24 @@ portletInfoEditor.desktopTheme=\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u30c6\u30fc\u30de: layoutAddPortletEditor.layoutName=\u30ec\u30a4\u30a2\u30a6\u30c8: -layoutAddPortletEditor.portletName=\u30dd\u30fc\u30c8\u30ec\u30c3\u30c8: \ No newline at end of file +layoutAddPortletEditor.portletName=\u30dd\u30fc\u30c8\u30ec\u30c3\u30c8: + +folderAddFolderAndPageEditor.folderOrPageName=\u540d\u524d: +folderAddFolderAndPageEditor.folderOrPageTitle=\u30bf\u30a4\u30c8\u30eb: +folderAddFolderAndPageEditor.folderOrPageShortTitle=\u77ed\u3044\u30bf\u30a4\u30c8\u30eb: +folderAddFolderAndPageEditor.layoutName=\u30ec\u30a4\u30a2\u30a6\u30c8: +folderAddFolderAndPageEditor.pageDecorator=\u30da\u30fc\u30b8\u30c7\u30b3\u30ec\u30fc\u30bf: +folderAddFolderAndPageEditor.portletDecorator=\u30dd\u30fc\u30c8\u30ec\u30c3\u30c8\u30c7\u30b3\u30ec\u30fc\u30bf: +folderAddFolderAndPageEditor.desktopTheme=\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u30c6\u30fc\u30de: +folderAddFolderAndPageEditor.folderOrPageHidden=\u30d5\u30a9\u30eb\u30c0/\u30da\u30fc\u30b8\u3092\u975e\u8868\u793a: + +pageSecurityEditor.securityConstraint=\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5236\u9650 +pageSecurityEditor.type= \u7a2e\u985e +pageSecurityEditor.permission= \u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3 +pageSecurityEditor.action=\u30a2\u30af\u30b7\u30e7\u30f3 +pageSecurityEditor.delete=\u524a\u9664 +pageSecurityEditor.users=\u30e6\u30fc\u30b6\u30fc: +pageSecurityEditor.groups=\u30b0\u30eb\u30fc\u30d7: +pageSecurityEditor.roles=\u30ed\u30fc\u30eb: +pageSecurityEditor.permissions=\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3: +pageSecurityEditor.securityConstraintsRef=\u5236\u9650\u53c2\u7167: Modified: pal-admin/trunk/src/main/webapp/view/site/pageInfoEditor.html =================================================================== --- pal-admin/trunk/src/main/webapp/view/site/pageInfoEditor.html 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/webapp/view/site/pageInfoEditor.html 2007-07-22 13:39:27 UTC (rev 324) @@ -43,10 +43,10 @@ <dir style="width: 500px;float: left;padding: 5px;margin: 0px;"> <div style="padding: 0px 0px 3px 10px; margin:5px 0px;border-bottom:1px solid #000000;"> <label id="infoTabLabel" style="border-top:1px solid #000000;border-right:1px solid #000000;border-bottom:1px solid #ffffff;border-left:1px solid #000000;padding: 3px 5px 3px 5px; margin: 0px 0px;">Information</label> -<!-- - <a id="jumpPageSecurityEditor-tab" href="pageSecurityEditor.html" style="text-decoration: none;"> + <a id="jumpPageSecurityEditor-tab" href="pageSecurityEditor.html?path=a&returnPath=b" style="text-decoration: none;"> <span id="securityTabLabel" style="font-weight: bold;color:#ffffff;background-color:#999999;border:1px solid #000000; padding: 3px 5px 3px 5px; margin: 0px 0px;">Security</span> </a> +<!-- <a id="jumpPageMetadataEditor-tab" href="pageMetadataEditor.html" style="text-decoration: none;"> <span id="metadataTabLabel" style="font-weight: bold;color:#ffffff;background-color:#999999;border:1px solid #000000; padding: 3px 5px 3px 5px; margin: 0px 0px;">Metadata</span> </a> Added: pal-admin/trunk/src/main/webapp/view/site/pageSecurityEditor.html =================================================================== --- pal-admin/trunk/src/main/webapp/view/site/pageSecurityEditor.html 2007-07-22 13:37:17 UTC (rev 323) +++ pal-admin/trunk/src/main/webapp/view/site/pageSecurityEditor.html 2007-07-22 13:39:27 UTC (rev 324) @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:te="http://www.seasar.org/teeda/extension"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <link rel="stylesheet" type="text/css" href="../../css/global.css" /> + </head> + <body> + <form id="pageSecurityEditorForm"> + <input id="path" type="hidden"/> + <input id="returnPath" type="hidden"/> +<!-- tree: BEGIN --> + <div style="width: 200px;height: 400px;float: left;border: 1px solid #666666;overflow: auto;"> + <div id="nodeItems"> + <div id="isFolder" style="white-space: nowrap;"> + <a id="jumpFolderInfoEditor" href="folderInfoEditor.html?path=a&returnPath=b" style=""> + <img id="folderIcon" src="" border="0" style="vertical-align:middle;" /> + <span id="name-folder">Name</span> + </a> + </div> + <div id="isPage" style="white-space: nowrap;"> + <a id="jumpPageInfoEditor" href="pageInfoEditor.html?path=a&returnPath=b" style=""> + <img id="pageIcon" src="" border="0" style="vertical-align:middle;" /> + <span id="name-page">Name</span> + </a> + </div> + <div id="isPageLayout" style="white-space: nowrap;"> + <a id="jumpLayoutInfoEditor" href="layoutInfoEditor.html?path=a&returnPath=b" style=""> + <img id="layoutIcon" src="" border="0" style="vertical-align:middle;" /> + <span id="name-layout">Name</span> + </a> + </div> + <div id="isPortlet" style="white-space: nowrap;"> + <a id="jumpPortletInfoEditor" href="portletInfoEditor.html?path=a&returnPath=b" style=""> + <img id="portletIcon" src="" border="0" style="vertical-align:middle;" /> + <span id="name-portlet">Name</span> + </a> + </div> + </div> + </div> +<!-- tree: END --> +<!-- content: BEGIN --> + <dir style="width: 500px;float: left;padding: 5px;margin: 0px;"> + <div style="padding: 0px 0px 3px 10px; margin:5px 0px;border-bottom:1px solid #000000;"> + <a id="jumpPageInfoEditor-tab" href="pageInfoEditor.html?path=a&returnPath=b" style="text-decoration: none;"> + <span id="infoTabLabel" style="font-weight: bold;color:#ffffff;background-color:#999999;border:1px solid #000000; padding: 3px 5px 3px 5px; margin: 0px 0px;">Info</span> + </a> + <label id="securityTabLabel" style="border-top:1px solid #000000;border-right:1px solid #000000;border-bottom:1px solid #ffffff;border-left:1px solid #000000;padding: 3px 5px 3px 5px; margin: 0px 0px;">Security</label> +<!-- + <a id="jumpPageMetadataEditor-tab" href="pageMetadataEditor.html" style="text-decoration: none;"> + <span id="metadataTabLabel" style="font-weight: bold;color:#ffffff;background-color:#999999;border:1px solid #000000; padding: 3px 5px 3px 5px; margin: 0px 0px;">Metadata</span> + </a> + --> + </div> + <div> + <span id="allMessages" fatalClass="portlet-msg-error" errorClass="portlet-msg-error" warnClass="portlet-msg-alert" infoClass="portlet-msg-info"></span> + </div> + <div> + <table> + <thead> + <tr> + <td style="width: 300px;"><label id="securityConstraintLabel"></label></td> + <td style="width: 70px;"><label id="permissionLabel"></label></td> + <td style="width: 70px;"><label id="typeLabel"></label></td> + <td style="width: 60px;"><label id="actionLabel"></label></td> + </tr> + </thead> + <tbody id="securityConstraintItems"> + <tr> + <td><span id="securityConstraintName">Constraint</span></td> + <td><span id="securityConstraintPermissionName">Permission</span></td> + <td><span id="securityConstraintTypeName">Type</span></td> + <td> + <a id="goPageSecurityEditor-delete" href="pageSecurityEditor.html?path=a&returnPath=b&applyOrder=c&securityConstraintType=d&fixed_action=delete"> + <span id="deleteLabel">Delete</span> + </a> + </td> + </tr> + </tbody> + </table> + + <br/> + + <div style="clear:both;"> + <div style="width:120px;float: left;"><label id="usersLabel" for="users">Users:</label></div> + <input id="users" type="text" size="30"/> + </div> + <div style="clear:both;"> + <div style="width:120px;float: left;"><label id="rolesLabel" for="roles">Roles:</label></div> + <input id="roles" type="text" size="30"/> + </div> + <div style="clear:both;"> + <div style="width:120px;float: left;"><label id="groupsLabel" for="groups">Groups:</label></div> + <input id="groups" type="text" size="30"/> + </div> + <div style="clear:both;"> + <div style="width:120px;float: left;"><label id="permissionsLabel" for="permissions">Permissions:</label></div> + <span id="permissions"> + <input type="checkbox" name="permissions" value="0" checked="checked"/>aaa + </span> + </div> + <div style="margin-top: 5px;text-align: center;"> + <input id="doAddConstraint" type="button" value="Add Constraint"/> + </div> + + <br/> + + <div style="clear:both;"> + <div style="width:120px;float: left;"><label id="securityConstraintsRefLabel" for="securityConstraintsRef" style="width:100px;">Constraint Ref:</label></div> + <select id="securityConstraintsRef"> + <option value="hoge">HOGE</option> + </select> + </div> + <div style="margin-top: 5px;text-align: center;"> + <input id="doAddConstraintRef" type="button" value="Add Constraint Ref"/> + </div> + </div> + </dir> + <br style="clear: both;" /> +<!-- content: END --> + </form> + </body> +</html> Property changes on: pal-admin/trunk/src/main/webapp/view/site/pageSecurityEditor.html ___________________________________________________________________ Name: svn:eol-style + native