unico 2004/07/17 10:57:25
Modified: src/blocks/slide/samples/screens users.jx locks.jx
permissions.jx
src/blocks/slide/samples flow.js
Added: src/blocks/slide/java/org/apache/cocoon/slide/util
AdminHelper.java
Removed: src/blocks/slide/java/org/apache/cocoon/samples/slide
AdminHelper.java
Log:
fix the slide samples again after stephan's refactorings of a few months ago
apparently
broke half of them. I find it unexceptable that I would have to loose half a
day to fix the
fumbling failures of people that apparently don't take the time to test their
dubious refactorings.
goddammit.
Revision Changes Path
1.5 +13 -9 cocoon-2.1/src/blocks/slide/samples/screens/users.jx
Index: users.jx
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/slide/samples/screens/users.jx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- users.jx 13 Apr 2004 14:25:24 -0000 1.4
+++ users.jx 17 Jul 2004 17:57:24 -0000 1.5
@@ -55,7 +55,7 @@
</form>
</td>
<form action="changepwd.do" method="post">
- <input type="hidden" name="username" value="${user}"/>
+ <input type="hidden" name="useruri" value="${user}"/>
<td align="left">
<input type="password" name="password" size="10"
maxlength="40"/>
</td>
@@ -67,11 +67,15 @@
<input type="hidden" name="subjecturi" value="${user}"/>
<td align="left">
<select name="objecturi">
- <jx:forEach var="role" items="#{roles[member = $user]}">
- <option value="{$role.uri}">
- ${role.uri}
- </option>
- </jx:forEach>
+ <jx:forEach var="role" items="${roles}">
+ <jx:forEach var="member" items="${role.members}">
+ <jx:if test="${member == user}">
+ <option value="${role.uri}">
+ ${role.uri}
+ </option>
+ </jx:if>
+ </jx:forEach>
+ </jx:forEach>
</select>
</td>
<td align="left">
@@ -82,11 +86,11 @@
<tr>
<td colspan="4"/>
<form action="addmember.do" method="post">
- <input type="hidden" name="subjecturi" value="{$user}"/>
+ <input type="hidden" name="subjecturi" value="${user}"/>
<td align="left">
<select name="objecturi" size="1">
<jx:forEach var="role" items="${roles}">
- <option value="{$role.uri}">
+ <option value="${role.uri}">
${role.uri}
</option>
</jx:forEach>
@@ -127,7 +131,7 @@
<jx:forEach var="role" items="${roles}">
<tr>
<form action="removeobject.do" method="post">
- <input type="hidden" name="objecturi" value="{$roleuri}"/>
+ <input type="hidden" name="objecturi" value="${role.uri}"/>
<td align="left">
${role.uri}
</td>
1.4 +17 -17 cocoon-2.1/src/blocks/slide/samples/screens/locks.jx
Index: locks.jx
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/slide/samples/screens/locks.jx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- locks.jx 13 Apr 2004 14:25:24 -0000 1.3
+++ locks.jx 17 Jul 2004 17:57:24 -0000 1.4
@@ -60,7 +60,7 @@
<b>Type</b>
</td>
<td align="left">
- <b>Expiration (mins)</b>
+ <b>Expiration</b>
</td>
<td align="left">
<b>Inheritable</b>
@@ -70,16 +70,16 @@
</td>
<td align="right"/>
</tr>
- <jx:forEach var="lock" items="${source.locks}">
+ <jx:forEach var="lock" items="${locks}">
<tr bgcolor="#eeeeee">
<td align="left">
- ${lock.subject}
+ ${lock.subjectUri}
</td>
<td align="left">
- ${lock.type}
+ ${lock.typeUri}
</td>
<td align="left">
- ${lock.expiration}
+ ${lock.expirationDate}
</td>
<td align="left">
${lock.inheritable}
@@ -90,8 +90,8 @@
<td align="right">
<form action="removelock.do" method="post">
<input type="hidden" name="resourcePath"
value="${source.path}"/>
- <input type="hidden" name="objectUri"
value="${lock.object}"/>
- <input type="hidden" name="lockId" value="${lock.id}"/>
+ <input type="hidden" name="objectUri"
value="${lock.objectUri}"/>
+ <input type="hidden" name="lockId" value="${lock.lockId}"/>
<input type="submit" name="doRemoveLock" value="Delete"/>
</form>
</td>
@@ -102,18 +102,18 @@
<input type="hidden" name="resourcePath"
value="${source.path}"/>
<td align="left">
<select name="subject">
- <option>self</option>
- <option>owner</option>
- <option>authenticated</option>
- <option>unauthenticated</option>
- <option>all</option>
+ <option value="self">self</option>
+ <option value="owner">owner</option>
+ <option value="authenticated">authenticated</option>
+ <option value="unauthenticated">unauthenticated</option>
+ <option value="all">all</option>
<jx:forEach var="role" items="${roles}">
- <option value="{$role.uri}">
+ <option value="${role.uri}">
role: ${role.uri}
</option>
</jx:forEach>
<jx:forEach var="user" items="${users}">
- <option value="{$user}">
+ <option value="${user}">
user: ${user}
</option>
</jx:forEach>
@@ -121,10 +121,10 @@
</td>
<td align="left">
<select name="type">
- <option>all</option>
- <option>default</option>
+ <option value="all">all</option>
+ <option value="default">default</option>
<jx:forEach var="privilege" items="${privileges}">
- <option value="{$privilege}">
+ <option value="${privilege}">
${privilege}
</option>
</jx:forEach>
1.5 +10 -10
cocoon-2.1/src/blocks/slide/samples/screens/permissions.jx
Index: permissions.jx
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/slide/samples/screens/permissions.jx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- permissions.jx 13 Apr 2004 14:25:24 -0000 1.4
+++ permissions.jx 17 Jul 2004 17:57:24 -0000 1.5
@@ -67,13 +67,13 @@
</td>
<td align="right"/>
</tr>
- <jx:forEach var="permission" items="${source.permissions}">
+ <jx:forEach var="permission" items="${permissions}">
<tr>
<td align="left">
- ${permission.subject}
+ ${permission.subjectUri}
</td>
<td align="left">
- ${permission.privilege}
+ ${permission.actionUri}
</td>
<td align="left">
${permission.inheritable}
@@ -84,10 +84,10 @@
<td align="right">
<form action="removePermission.do" method="post">
<input type="hidden" name="resourcePath"
value="${source.path}"/>
- <input type="hidden" name="subject"
value="${permission.subject}"/>
- <input type="hidden" name="privilege"
value="{permission.privilege}"/>
- <input type="hidden" name="inheritable"
value="{permission.inheritable}"/>
- <input type="hidden" name="negative"
value="{permission.negative}"/>
+ <input type="hidden" name="subject"
value="${permission.subjectUri}"/>
+ <input type="hidden" name="action"
value="${permission.actionUri}"/>
+ <input type="hidden" name="inheritable"
value="${permission.inheritable}"/>
+ <input type="hidden" name="negative"
value="${permission.negative}"/>
<input type="submit" name="doRemovePermission"
value="Delete"/>
</form>
</td>
@@ -104,12 +104,12 @@
<option>unauthenticated</option>
<option>all</option>
<jx:forEach var="role" items="${roles}">
- <option value="{$role.uri}">
+ <option value="${role.uri}">
role: ${role.uri}
</option>
</jx:forEach>
<jx:forEach var="user" items="${users}">
- <option value="{$user}">
+ <option value="${user}">
user: ${user}
</option>
</jx:forEach>
@@ -120,7 +120,7 @@
<option>all</option>
<option>default</option>
<jx:forEach var="privilege" items="${privileges}">
- <option value="{$privilege}">
+ <option value="${privilege}">
${privilege}
</option>
</jx:forEach>
1.1
cocoon-2.1/src/blocks/slide/java/org/apache/cocoon/slide/util/AdminHelper.java
Index: AdminHelper.java
===================================================================
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* 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 org.apache.cocoon.slide.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import org.apache.slide.authenticate.CredentialsToken;
import org.apache.slide.common.NamespaceAccessToken;
import org.apache.slide.common.SlideToken;
import org.apache.slide.common.SlideTokenImpl;
import org.apache.slide.content.Content;
import org.apache.slide.content.NodeProperty;
import org.apache.slide.content.NodeRevisionDescriptor;
import org.apache.slide.content.NodeRevisionDescriptors;
import org.apache.slide.lock.Lock;
import org.apache.slide.lock.NodeLock;
import org.apache.slide.macro.Macro;
import org.apache.slide.macro.MacroParameters;
import org.apache.slide.security.NodePermission;
import org.apache.slide.security.Security;
import org.apache.slide.structure.ObjectNode;
import org.apache.slide.structure.ObjectNotFoundException;
import org.apache.slide.structure.Structure;
import org.apache.slide.structure.SubjectNode;
/**
* Helper class for the slide samples administration application.
*/
public class AdminHelper {
private static final SlideToken ROOT = new SlideTokenImpl(new
CredentialsToken("root"));
public static boolean login(NamespaceAccessToken nat,
String userId,
String password) throws Exception {
String usersPath = nat.getNamespaceConfig().getUsersPath();
String userUri = usersPath + "/" + userId;
Content content = nat.getContentHelper();
try {
NodeRevisionDescriptors revisions =
content.retrieve(ROOT,userUri);
NodeRevisionDescriptor revision =
content.retrieve(ROOT,revisions);
NodeProperty property = revision.getProperty(
"password",NodeProperty.SLIDE_NAMESPACE);
return property.getValue().equals(password);
}
catch (Exception e) {
e.printStackTrace();
throw e;
}
}
public static void addUser(NamespaceAccessToken nat,
String caller,
String username,
String password) throws Exception {
String usersPath = nat.getNamespaceConfig().getUsersPath();
String userUri = usersPath + "/" + username;
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Structure structure = nat.getStructureHelper();
Content content = nat.getContentHelper();
try {
nat.begin();
ObjectNode user = new SubjectNode();
structure.create(slideToken,user,userUri);
// create the user descriptor
NodeRevisionDescriptor descriptor = new NodeRevisionDescriptor();
descriptor.setCreationDate(new Date());
descriptor.setLastModified(new Date());
descriptor.setProperty(new NodeProperty(
"password",password,NodeProperty.SLIDE_NAMESPACE));
content.create(slideToken,userUri,descriptor,null);
nat.commit();
}
catch (Exception e) {
try {
nat.rollback();
}
catch (Exception f) {
f.printStackTrace();
}
throw e;
}
}
public static void addGroup(NamespaceAccessToken nat,
String caller,
String groupname) throws Exception {
String groupsPath = nat.getNamespaceConfig().getGroupsPath();
String groupUri = groupsPath + "/" + groupname;
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Structure structure = nat.getStructureHelper();
Content content = nat.getContentHelper();
try {
nat.begin();
ObjectNode group = new SubjectNode();
structure.create(slideToken,group,groupUri);
NodeRevisionDescriptor descriptor = new NodeRevisionDescriptor();
descriptor.setCreationDate(new Date());
descriptor.setLastModified(new Date());
content.create(slideToken,groupUri,descriptor,null);
nat.commit();
}
catch (Exception e) {
try {
nat.rollback();
}
catch (Exception f) {
f.printStackTrace();
}
throw e;
}
}
public static void addRole(NamespaceAccessToken nat,
String caller,
String rolename) throws Exception {
String rolesPath = nat.getNamespaceConfig().getRolesPath();
String roleUri = rolesPath + "/" + rolename;
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Structure structure = nat.getStructureHelper();
Content content = nat.getContentHelper();
try {
nat.begin();
ObjectNode role = new SubjectNode();
structure.create(slideToken,role,roleUri);
NodeRevisionDescriptor descriptor = new NodeRevisionDescriptor();
descriptor.setCreationDate(new Date());
descriptor.setLastModified(new Date());
content.create(slideToken,roleUri,descriptor,null);
nat.commit();
}
catch (Exception e) {
try {
nat.rollback();
}
catch (Exception f) {
f.printStackTrace();
}
throw e;
}
}
public static void removeObject(NamespaceAccessToken nat,
String caller,
String objectUri) throws Exception {
String usersPath = nat.getNamespaceConfig().getUsersPath();
String callerUri = usersPath + "/" + caller;
// user cannot delete itself
if (callerUri.equals(objectUri)) {
return;
}
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Macro macro = nat.getMacroHelper();
try {
nat.begin();
boolean recursive = true;
boolean overwrite = false;
MacroParameters parameters = new
MacroParameters(recursive,overwrite);
macro.delete(slideToken,objectUri,parameters);
nat.commit();
}
catch (Exception e) {
try {
nat.rollback();
}
catch (Exception f) {
f.printStackTrace();
}
throw e;
}
}
public static void addMember(NamespaceAccessToken nat,
String caller,
String objectUri,
String subjectUri) throws Exception {
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Structure structure = nat.getStructureHelper();
Content content = nat.getContentHelper();
try {
// check if the subject exists
structure.retrieve(slideToken,subjectUri);
NodeRevisionDescriptors descriptors =
content.retrieve(slideToken,objectUri);
NodeRevisionDescriptor descriptor =
content.retrieve(slideToken,descriptors);
NodeProperty property =
descriptor.getProperty("group-member-set","DAV:");
String value = null;
if (property != null) {
value = (String) property.getValue();
if (value.indexOf(subjectUri) != -1) {
// user already a member of this group
return;
}
}
else {
value = "";
}
value = value + "<D:href xmlns:D='DAV:'>" + subjectUri +
"</D:href>";
descriptor.setProperty("group-member-set","DAV:",value);
nat.begin();
content.store(slideToken,objectUri,descriptor,null);
nat.commit();
}
catch (ObjectNotFoundException e) {
// no such user or group
}
catch (Exception e) {
try {
nat.rollback();
}
catch (Exception f) {
f.printStackTrace();
}
throw e;
}
}
public static void removeMember(NamespaceAccessToken nat,
String caller,
String objectUri,
String subjectUri) throws Exception {
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Content content = nat.getContentHelper();
try {
NodeRevisionDescriptors revisions =
content.retrieve(slideToken,objectUri);
NodeRevisionDescriptor revision =
content.retrieve(slideToken,revisions);
NodeProperty property =
revision.getProperty("group-member-set","DAV:");
if (property == null) {
// group has no members
return;
}
String value = (String) property.getValue();
int index = value.indexOf(subjectUri);
if (index == -1) {
// subject is not a member of this group
return;
}
// looking for the end of </D:href> after subjectUri
int end = index + subjectUri.length();
do {
end++;
}
while (value.charAt(end) != '>');
// looking for the start of <D:href> before subjectUri
int from = index;
do {
from--;
}
while(value.charAt(from) != '<');
// snip out the user
String before = value.substring(0,from);
String after = value.substring(end+1);
value = before + after;
revision.setProperty("group-member-set","DAV:",value);
nat.begin();
content.store(slideToken,objectUri,revision,null);
nat.commit();
}
catch (ObjectNotFoundException e) {
// no such user or group
}
catch (Exception e) {
try {
nat.rollback();
}
catch (Exception f) {
f.printStackTrace();
}
throw e;
}
}
public static void changePassword(NamespaceAccessToken nat,
String caller,
String userUri,
String password) throws Exception {
String usersPath = nat.getNamespaceConfig().getUsersPath();
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Content content = nat.getContentHelper();
try {
nat.begin();
NodeRevisionDescriptors revisions = content.retrieve(slideToken,
userUri);
NodeRevisionDescriptor revision = content.retrieve(slideToken,
revisions);
revision.setLastModified(new Date());
revision.setProperty(new NodeProperty("password", password,
NodeProperty.SLIDE_NAMESPACE));
content.store(slideToken, userUri, revision, null);
nat.commit();
}
catch (Exception e) {
try {
nat.rollback();
}
catch (Exception f) {
f.printStackTrace();
}
throw e;
}
}
public static List listPermissions(NamespaceAccessToken nat,
String caller,
String path) throws Exception {
String uri = getUriFromPath(nat,path);
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Security security = nat.getSecurityHelper();
List result = new ArrayList();
try {
nat.begin();
Enumeration permissions =
security.enumeratePermissions(slideToken,uri,false);
while (permissions.hasMoreElements()) {
result.add(permissions.nextElement());
}
nat.commit();
return result;
}
catch (Exception e) {
try {
nat.rollback();
}
catch (Exception f) {
f.printStackTrace();
}
throw e;
}
}
public static List listLocks(NamespaceAccessToken nat,
String caller,
String path) throws Exception {
String uri = getUriFromPath(nat,path);
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Lock lock = nat.getLockHelper();
List result = new ArrayList();
try {
nat.begin();
Enumeration locks = lock.enumerateLocks(slideToken,uri,false);
while(locks.hasMoreElements()) {
result.add(locks.nextElement());
}
nat.commit();
return result;
} catch (Exception e) {
try {
nat.rollback();
}
catch (Exception f) {
f.printStackTrace();
}
throw e;
}
}
public static List listGroups(NamespaceAccessToken nat, String caller,
String path) throws Exception {
List result = new ArrayList();
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Structure structure = nat.getStructureHelper();
Content content = nat.getContentHelper();
ObjectNode object = structure.retrieve(slideToken,path);
Enumeration enum = structure.getChildren(slideToken,object);
while (enum.hasMoreElements()) {
String uri = ((ObjectNode) enum.nextElement()).getUri();
NodeRevisionDescriptors revisions = content.retrieve(slideToken,
uri);
NodeRevisionDescriptor revision = content.retrieve(slideToken,
revisions);
NodeProperty property =
revision.getProperty("group-member-set","DAV:");
List members;
if (property != null) {
String value = (String) property.getValue();
members = new ArrayList(10);
int start = value.indexOf('>'), end = 0;
while (start != -1) {
end = value.indexOf('<',start);
if (end != -1) {
members.add(value.substring(start+1,end));
}
end = value.indexOf('>',start+1);
start = value.indexOf('>',end+1);
}
}
else {
members = Collections.EMPTY_LIST;
}
result.add(new Group(uri,members));
}
return result;
}
public static List listUsers(NamespaceAccessToken nat,
String caller) throws Exception {
return
listObjects(nat,caller,nat.getNamespaceConfig().getUsersPath());
}
public static List listPrivileges(NamespaceAccessToken nat,
String caller) throws Exception {
return
listObjects(nat,caller,nat.getNamespaceConfig().getActionsPath());
}
private static List listObjects(NamespaceAccessToken nat,
String caller,
String path) throws Exception {
List result = new ArrayList();
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Structure structure = nat.getStructureHelper();
ObjectNode object = structure.retrieve(slideToken,path);
Enumeration enum = structure.getChildren(slideToken,object);
while (enum.hasMoreElements()) {
result.add(((ObjectNode) enum.nextElement()).getUri());
}
return result;
}
public static void removePermission(NamespaceAccessToken nat,
String caller,
String path,
String subject,
String action) throws Exception {
String uri = getUriFromPath(nat,path);
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Security security = nat.getSecurityHelper();
try {
NodePermission permission = new NodePermission(uri, subject,
action);
nat.begin();
security.revokePermission(slideToken, permission);
nat.commit();
}
catch (Exception e) {
try {
nat.rollback();
}
catch (Exception f) {
f.printStackTrace();
}
throw e;
}
}
public static void addPermission(NamespaceAccessToken nat,
String caller,
String path,
String subject,
String action,
String inheritable,
String negative) throws Exception {
String uri = getUriFromPath(nat,path);
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Security security = nat.getSecurityHelper();
boolean isInheritable = Boolean.valueOf(inheritable).booleanValue();
boolean isNegative = Boolean.valueOf(negative).booleanValue();
try {
NodePermission permission = new
NodePermission(uri,subject,action,isInheritable,isNegative);
nat.begin();
if (isNegative) {
security.denyPermission(slideToken,permission);
}
else {
security.grantPermission(slideToken,permission);
}
nat.commit();
} catch (Exception e) {
try {
nat.rollback();
}
catch (Exception f) {
f.printStackTrace();
}
throw e;
}
}
public static void removeLock(NamespaceAccessToken nat,
String caller,
String uri,
String lockId) throws Exception {
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Lock lock = nat.getLockHelper();
try {
nat.begin();
lock.unlock(slideToken,uri,lockId);
nat.commit();
}
catch (Exception e) {
try {
nat.rollback();
}
catch (Exception f) {
f.printStackTrace();
}
throw e;
}
}
public static void addLock(NamespaceAccessToken nat,
String caller,
String path,
String subject,
String type,
String expiration,
String exclusive,
String inherit) throws Exception {
String uri = getUriFromPath(nat,path);
boolean isExclusive = Boolean.valueOf(exclusive).booleanValue();
boolean isInherit = Boolean.valueOf(inherit).booleanValue();
// expiration in minutes
int intExpiration = Integer.valueOf(expiration).intValue();
Date expire = new Date(System.currentTimeMillis() +
intExpiration*1000*60);
SlideToken slideToken = new SlideTokenImpl(new
CredentialsToken(caller));
Lock lock = nat.getLockHelper();
try {
nat.begin();
lock.lock(slideToken, new NodeLock(uri, subject, type, expire,
isInherit, isExclusive, uri));
nat.commit();
}
catch (Exception e) {
try {
nat.rollback();
}
catch (Exception f) {
f.printStackTrace();
}
throw e;
}
}
private static String getUriFromPath(NamespaceAccessToken nat,
String path) {
String filesPath = nat.getNamespaceConfig().getFilesPath();
String uri;
if (path.equals("/") || path.length() == 0) {
uri = filesPath;
}
else {
uri = filesPath + "/" + path;
}
return uri;
}
public static class Group {
private final String m_uri;
private final List m_members;
private Group(String uri, List members) {
m_uri = uri;
m_members = members;
}
public String getUri() {
return m_uri;
}
public List getMembers() {
return m_members;
}
public String toString() {
return m_uri;
}
}
}
1.18 +61 -28 cocoon-2.1/src/blocks/slide/samples/flow.js
Index: flow.js
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/slide/samples/flow.js,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- flow.js 13 Apr 2004 14:25:23 -0000 1.17
+++ flow.js 17 Jul 2004 17:57:25 -0000 1.18
@@ -16,12 +16,11 @@
importPackage(Packages.org.apache.cocoon.components.modules.input);
importPackage(Packages.org.apache.cocoon.components.slide);
-importPackage(Packages.org.apache.cocoon.components.source);
+importClass(Packages.org.apache.cocoon.components.source.SourceDTO);
importPackage(Packages.org.apache.cocoon.components.source.helpers);
-importPackage(Packages.org.apache.cocoon.samples.slide);
+importPackage(Packages.org.apache.cocoon.slide.util);
importPackage(Packages.org.apache.excalibur.source);
-var repository =
cocoon.getComponent('org.apache.cocoon.components.repository.SourceRepository');
var resolver = cocoon.getComponent(SourceResolver.ROLE);
var global = cocoon.getComponent(InputModule.ROLE +
"Selector").select("global");
var namespace = global.getAttribute("namespace",null,null);
@@ -80,9 +79,18 @@
login();
- var baseUri = "slide://" + principal + "@" + namespace + "/";
+ var baseUri = "slide://" + principal + "@" + namespace + "/";
var location = baseUri + parentPath + "/" + collectionName;
- var status = repository.makeCollection(location);
+ var source = null;
+ try {
+ source = resolver.resolveURI(location);
+ source.makeCollection();
+ }
+ finally {
+ if (source != null) {
+ resolver.release(source);
+ }
+ }
cocoon.redirectTo("viewcontent.do?path=" + parentPath);
}
@@ -95,10 +103,24 @@
//FIXME: retrieve upload object before login
login();
- var baseUri = "slide://" + principal + "@" + namespace + "/";
+ var baseUri = "slide://" + principal + "@" + namespace + "/";
var dest = baseUri + parentPath + "/" + resourceName;
var src = "upload://uploadFile";
- var status = repository.save(src,dest);
+
+ var source, destination = null;
+ try {
+ source = resolver.resolveURI(src);
+ destination = resolver.resolveURI(dest);
+ SourceUtil.copy(source, destination);
+ }
+ finally {
+ if (source != null) {
+ resolver.release(source);
+ }
+ if (destination != null) {
+ resolver.release(destination);
+ }
+ }
cocoon.redirectTo("viewcontent.do?path=" + parentPath);
}
@@ -112,7 +134,16 @@
var baseUri = "slide://" + principal + "@" + namespace + "/";
var location = baseUri + parentPath + "/" + resourceName;
- var status = repository.remove(location);
+ var source = null;
+ try {
+ source = resolver.resolveURI(location);
+ source["delete"].call(source);
+ }
+ finally {
+ if (source != null) {
+ resolver.release(source);
+ }
+ }
cocoon.redirectTo("viewcontent.do?path=" + parentPath);
}
@@ -209,18 +240,20 @@
var roles = AdminHelper.listGroups(nat,principal,"/roles");
var users = AdminHelper.listUsers(nat,principal);
var privileges = AdminHelper.listPrivileges(nat,principal);
- cocoon.sendPage("screens/permissions.html",{source:sourceDTO, roles:roles,
users:users, privileges:privileges});
+ var permissions = AdminHelper.listPermissions(nat,principal,path);
+
+ cocoon.sendPage("screens/permissions.html",{source:sourceDTO, roles:roles,
users:users, privileges:privileges, permissions:permissions});
}
function removePermission() {
var resourcePath = cocoon.request.getParameter("resourcePath");
var subject = cocoon.request.getParameter("subject");
- var privilege = cocoon.request.getParameter("privilege");
+ var action = cocoon.request.getParameter("action");
login();
- AdminHelper.removePermission(nat,principal,resourcePath,subject,privilege);
- cocoon.redirectTo("permissions/" + resourcePath);
+ AdminHelper.removePermission(nat, principal, resourcePath, subject,
action);
+ cocoon.redirectTo("viewpermissions.do?path=" + resourcePath);
}
function addPermission() {
@@ -233,7 +266,7 @@
login();
AdminHelper.addPermission(nat,principal,resourcePath,subject,action,inheritable,negative);
- cocoon.redirectTo("permissions/" + resourcePath);
+ cocoon.redirectTo("viewpermissions.do?path=" + resourcePath);
}
// ---------------------------------------------- lock management
@@ -258,7 +291,8 @@
var roles = AdminHelper.listGroups(nat,principal,"/roles");
var users = AdminHelper.listUsers(nat,principal);
var privileges = AdminHelper.listPrivileges(nat,principal);
- cocoon.sendPage("screens/locks.html",{source:sourceDTO, roles:roles,
users:users, privileges:privileges});
+ var locks = AdminHelper.listLocks(nat, principal, path);
+ cocoon.sendPage("screens/locks.html",{source:sourceDTO, roles:roles,
users:users, privileges:privileges, locks:locks});
}
function removelock() {
@@ -277,14 +311,14 @@
var resourcePath = cocoon.request.getParameter("resourcePath");
var subject = cocoon.request.getParameter("subject");
var type = cocoon.request.getParameter("type");
- var exclusive = cocoon.request.getParameter("exclusive");
var expiration = cocoon.request.getParameter("expiration");
+ var exclusive = cocoon.request.getParameter("exclusive");
var inheritable = cocoon.request.getParameter("inheritable");
login();
-
-
AdminHelper.addLock(nat,principal,resourcePath,subject,type,expiration,exclusive,inheritable);
-
+
+ AdminHelper.addLock(nat, principal, resourcePath, subject, type,
expiration, exclusive, inheritable);
+
cocoon.redirectTo("viewlocks.do?path=" + resourcePath);
}
@@ -306,14 +340,14 @@
login();
AdminHelper.addUser(nat,principal,username,password);
- cocoon.redirectTo("users");
+ cocoon.redirectTo("viewusers.do");
}
function addrole () {
var rolename = cocoon.request.getParameter("rolename");
AdminHelper.addRole(nat,principal,rolename);
- cocoon.redirectTo("users");
+ cocoon.redirectTo("viewusers.do");
}
function addgroup () {
@@ -322,7 +356,7 @@
login();
AdminHelper.addGroup(nat,principal,groupname);
- cocoon.redirectTo("users");
+ cocoon.redirectTo("viewusers.do");
}
function removeobject() {
@@ -331,7 +365,7 @@
login();
AdminHelper.removeObject(nat,principal,objecturi);
- cocoon.redirectTo("users");
+ cocoon.redirectTo("viewusers.do");
}
function addmember() {
@@ -339,9 +373,8 @@
var subjecturi = cocoon.request.getParameter("subjecturi");
login();
-
AdminHelper.addMember(nat,principal,objecturi,subjecturi);
- cocoon.redirectTo("users");
+ cocoon.redirectTo("viewusers.do");
}
function removemember() {
@@ -351,14 +384,14 @@
login();
AdminHelper.removeMember(nat,principal,objecturi,subjecturi);
- cocoon.redirectTo("users");
+ cocoon.redirectTo("viewusers.do");
}
function changepwd() {
- var username = cocoon.request.getParameter("username");
+ var useruri = cocoon.request.getParameter("useruri");
var password = cocoon.request.getParameter("password");
- AdminHelper.changePassword(nat, principal, username, password);
- cocoon.redirectTo("users");
+ AdminHelper.changePassword(nat, principal, useruri, password);
+ cocoon.redirectTo("viewusers.do");
}