You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by df...@apache.org on 2004/06/16 18:45:37 UTC
cvs commit: jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/tree TreeLocalizer.java
dflorey 2004/06/16 09:45:37
Modified: proposals/projector/src/java/org/apache/slide/projector/processor/security
CreateUser.java DeleteUser.java
proposals/projector/src/java/org/apache/slide/projector/connector/webdav
WebdavConnector.java
proposals/projector/src/java/org/apache/slide/projector/processor/core
CachedContent.java
proposals/projector/src/java/org/apache/slide/projector/application
ApplicationManager.java
proposals/projector/src/java/org/apache/slide/projector/processor/tree
TreeLocalizer.java
Added: proposals/projector/src/java/org/apache/slide/projector/processor/security
AddRole.java
Log:
Admin application continued...
Revision Changes Path
1.2 +31 -22 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/security/CreateUser.java
Index: CreateUser.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/security/CreateUser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CreateUser.java 15 Jun 2004 16:34:20 -0000 1.1
+++ CreateUser.java 16 Jun 2004 16:45:37 -0000 1.2
@@ -6,6 +6,9 @@
import org.apache.slide.projector.i18n.DefaultMessage;
import org.apache.slide.projector.i18n.ErrorMessage;
import org.apache.slide.projector.i18n.ParameterMessage;
+import org.apache.slide.projector.value.NullValue;
+import org.apache.slide.projector.value.URIValue;
+import org.apache.slide.projector.value.Value;
import org.apache.slide.projector.Information;
import org.apache.slide.projector.*;
@@ -21,48 +24,54 @@
private final static String PASSWORD = "password";
private final static String RETYPE_PASSWORD = "retypePassword";
- private final static String VALID = "valid";
- private final static String INVALID = "invalid";
+ private final static String USER = "user";
+ private final static String OK = "ok";
+ private final static String FAILED = "failed";
+
+ private final static ParameterDescriptor [] parameterDescriptor = new ParameterDescriptor[] {
+ new ParameterDescriptor(USERNAME, new ParameterMessage("create-user/username"), new StringValueDescriptor(1,24)),
+ new ParameterDescriptor(PASSWORD, new ParameterMessage("create-user/password"), new StringValueDescriptor(1,24)),
+ new ParameterDescriptor(RETYPE_PASSWORD, new ParameterMessage("create-user/retyped-password"), new StringValueDescriptor(1,24)),
+ };
+
+ private final static ResultDescriptor resultDescriptor = new ResultDescriptor(
+ new StateDescriptor[] {
+ new StateDescriptor(OK, new DefaultMessage("create-user/state/ok")),
+ new StateDescriptor(FAILED, new DefaultMessage("create-user/state/failed"))
+ }, new ResultEntryDescriptor[] {
+ new ResultEntryDescriptor(USER, new DefaultMessage("createUser/result/user"), URIValue.CONTENT_TYPE, false)
+ });
public Result process(Map parameter, Context context) throws Exception {
String username = parameter.get(USERNAME).toString();
String retypedPassword = parameter.get(RETYPE_PASSWORD).toString();
String password = parameter.get(PASSWORD).toString();
- String state = VALID;
+ String state = OK;
// Check spelling
+ Value user = NullValue.NULL;
if ( !password.equals(retypedPassword) ) {
context.addInformation(new Information(Information.ERROR, new ErrorMessage("register/passwordsNotIdentical"), new String[] { PASSWORD, RETYPE_PASSWORD }));
- state = INVALID;
+ state = FAILED;
} else {
try {
- ConnectorFactory.getConnector().createUser(username, password, context.getCredentials());
+ user = ConnectorFactory.getConnector().createUser(username, password, context.getCredentials());
} catch ( UserExistsException exception ) {
context.addInformation(new Information(Information.ERROR, exception.getErrorMessage(), new String[] { USERNAME }));
- state = INVALID;
+ state = FAILED;
}
}
- /*
- if ( password.equals("aaaa") ) {
- context.addInformation(new Information(Information.ERROR, new ErrorMessage("login/invalidPassword"), new String[] { PASSWORD }));
- state = INVALID;
+ if ( user == null ) {
+ context.addInformation(new Information(Information.ERROR, new ErrorMessage("register/failed"), new String[0]));
+ state = FAILED;
}
- */
- // Check if user already exists
- return new Result(state);
+ return new Result(state, USER, user);
}
public ParameterDescriptor[] getParameterDescriptors() {
- return new ParameterDescriptor[] {
- new ParameterDescriptor(USERNAME, new ParameterMessage("create-user/username"), new StringValueDescriptor(1,24)),
- new ParameterDescriptor(PASSWORD, new ParameterMessage("create-user/password"), new StringValueDescriptor(1,24)),
- new ParameterDescriptor(RETYPE_PASSWORD, new ParameterMessage("create-user/retyped-password"), new StringValueDescriptor(1,24)),
- };
+ return parameterDescriptor;
}
public ResultDescriptor getResultDescriptor() {
- return new ResultDescriptor(new StateDescriptor[] {
- new StateDescriptor(VALID, new DefaultMessage("create-user/state/valid")),
- new StateDescriptor(INVALID, new DefaultMessage("create-user/state/invalid"))
- });
+ return resultDescriptor;
}
}
1.2 +5 -5 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/security/DeleteUser.java
Index: DeleteUser.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/security/DeleteUser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DeleteUser.java 15 Jun 2004 16:34:20 -0000 1.1
+++ DeleteUser.java 16 Jun 2004 16:45:37 -0000 1.2
@@ -39,15 +39,15 @@
* @author <a href="mailto:dflorey@c1-fse.de">Daniel Florey</a>
*/
public class DeleteUser implements Processor {
- public final static String URI = "uri";
+ public final static String USER = "user";
private final static ParameterDescriptor[] parameterDescriptors = new ParameterDescriptor[] {
- new ParameterDescriptor(URI, new ParameterMessage("deleteUser/parameter/uri"), new URIValueDescriptor())
+ new ParameterDescriptor(USER, new ParameterMessage("deleteUser/parameter/user"), new URIValueDescriptor())
};
private final static ResultDescriptor resultDescriptor = new ResultDescriptor(new StateDescriptor[] { StateDescriptor.OK_DESCRIPTOR });
public Result process(Map parameter, Context context) throws Exception {
- URI uri = (URI)parameter.get(URI);
+ URI uri = (URI)parameter.get(USER);
ConnectorFactory.getConnector().deleteUser(uri, context.getCredentials());
return Result.OK;
}
1.1 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/security/AddRole.java
Index: AddRole.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/security/AddRole.java,v 1.1 2004/06/16 16:45:37 dflorey Exp $
* $Revision: 1.1 $
* $Date: 2004/06/16 16:45:37 $
*
* ====================================================================
*
* Copyright 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.slide.projector.processor.security;
import org.apache.slide.projector.Context;
import org.apache.slide.projector.Processor;
import org.apache.slide.projector.Result;
import org.apache.slide.projector.URI;
import org.apache.slide.projector.connector.ConnectorFactory;
import org.apache.slide.projector.descriptor.*;
import org.apache.slide.projector.i18n.ParameterMessage;
import java.util.Map;
/**
* The Event class
*
* @author <a href="mailto:dflorey@c1-fse.de">Daniel Florey</a>
*/
public class AddRole implements Processor {
public final static String USER = "user";
public final static String ROLE = "role";
private final static ParameterDescriptor[] parameterDescriptors = new ParameterDescriptor[] {
new ParameterDescriptor(USER, new ParameterMessage("addRole/parameter/user"), new URIValueDescriptor()),
new ParameterDescriptor(ROLE, new ParameterMessage("addRole/parameter/role"), new URIValueDescriptor())
};
private final static ResultDescriptor resultDescriptor = new ResultDescriptor(new StateDescriptor[] { StateDescriptor.OK_DESCRIPTOR });
public Result process(Map parameter, Context context) throws Exception {
URI user = (URI)parameter.get(USER);
URI role = (URI)parameter.get(ROLE);
ConnectorFactory.getConnector().addRole(user, role, context.getCredentials());
return Result.OK;
}
public ParameterDescriptor[] getParameterDescriptors() {
return parameterDescriptors;
}
public ResultDescriptor getResultDescriptor() {
return resultDescriptor;
}
}
1.12 +12 -11 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/connector/webdav/WebdavConnector.java
Index: WebdavConnector.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/connector/webdav/WebdavConnector.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- WebdavConnector.java 15 Jun 2004 16:34:20 -0000 1.11
+++ WebdavConnector.java 16 Jun 2004 16:45:37 -0000 1.12
@@ -24,6 +24,7 @@
import org.apache.webdav.lib.methods.SearchMethod;
import org.jdom.Element;
import org.jdom.input.DOMBuilder;
+import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
import java.io.IOException;
@@ -75,7 +76,6 @@
int state = mkcolMethod.execute(httpState, new HttpConnection(Constants.REPOSITORY_HOST, Constants.REPOSITORY_PORT, Constants.REPOSITORY_PROTOCOL));
if ( state == HttpStatus.SC_CREATED ) {
changePassword(userUri, null, password, credentials);
- addRole(userUri, new URIValue(Constants.REPOSITORY_DOMAIN+Constants.ROLES_DIR+"root"), credentials);
return userUri;
}
return null;
@@ -87,12 +87,14 @@
}
public void addRole(URI user, URI role, Credentials credentials) throws IOException {
- XMLValue roleElement = getPropertyAsXMLValue(role, DAV_NAMESPACE, "group-member-set", credentials);
- Element newElement = new Element("href", "DAV:");
- newElement.addContent(user.toString());
- roleElement.getRootElement().addContent(newElement);
- XMLOutputter xout = new XMLOutputter();
- String groupMemberSet = xout.outputString(roleElement.getRootElement());
+ // Add user to role
+ role = new URIValue(Constants.REPOSITORY_DOMAIN+role);
+ XMLValue roleElement = getPropertyAsXMLValue(role, DAV_NAMESPACE, "group-member-set", credentials);
+ Element newUserElement = new Element("href", "DAV:");
+ newUserElement.addContent(user.toString());
+ roleElement.getRootElement().addContent(newUserElement);
+ XMLOutputter xout = new XMLOutputter(Format.getCompactFormat());
+ String groupMemberSet = xout.outputString(roleElement.getRootElement().getContent());
setProperty(role, DAV_NAMESPACE, "group-member-set", groupMemberSet, credentials);
}
@@ -150,13 +152,12 @@
private Property getProperty(URI uri, String namespace, String name, Credentials credentials) throws IOException {
String url = uri.toString();
- PropFindMethod propfindMethod = new PropFindMethod(url, 0);
+ Vector props = new Vector();
+ props.add(new PropertyName(namespace, name));
+ PropFindMethod propfindMethod = new PropFindMethod(url, 0, props.elements());
propfindMethod.setDoAuthentication(true);
HttpState httpState = new HttpState();
httpState.setCredentials(null, Constants.REPOSITORY_HOST, credentials);
- Vector props = new Vector();
- props.add(new PropertyName(namespace, name));
- propfindMethod.setPropertyNames(props.elements());
int state = propfindMethod.execute(httpState, new HttpConnection(Constants.REPOSITORY_HOST, Constants.REPOSITORY_PORT, Constants.REPOSITORY_PROTOCOL));
if ( state != HttpStatus.SC_MULTI_STATUS ) {
throw new IOException("Received status code "+state+" when doing PROPFIND on URI="+url);
1.5 +3 -2 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/core/CachedContent.java
Index: CachedContent.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/core/CachedContent.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CachedContent.java 15 Jun 2004 16:34:20 -0000 1.4
+++ CachedContent.java 16 Jun 2004 16:45:37 -0000 1.5
@@ -65,7 +65,8 @@
return new ResultDescriptor(new StateDescriptor[]{ StateDescriptor.OK_DESCRIPTOR },
new ResultEntryDescriptor[] {
new ResultEntryDescriptor(SimpleProcessor.OUTPUT, new DefaultMessage("cachedContent/result/output"), "*", true),
- new ResultEntryDescriptor(URL, new DefaultMessage("cachedContent/result/url"), "text/url", true), }
+ new ResultEntryDescriptor(URL, new DefaultMessage("cachedContent/result/url"), "text/url", false),
+ }
);
}
}
1.9 +1 -1 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/application/ApplicationManager.java
Index: ApplicationManager.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/application/ApplicationManager.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ApplicationManager.java 10 Jun 2004 16:14:12 -0000 1.8
+++ ApplicationManager.java 16 Jun 2004 16:45:37 -0000 1.9
@@ -154,8 +154,8 @@
addRequiredApplicationsFirst(sortedApplications, applicationsToInstall, requiredApplication);
}
}
- logger.log(Level.INFO, "Adding '"+application.getName()+"' to installation process");
if ( !sortedApplications.contains(application) ) {
+ logger.log(Level.INFO, "Adding '"+application.getName()+"' to installation process");
sortedApplications.add(application);
}
}
1.3 +20 -8 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/tree/TreeLocalizer.java
Index: TreeLocalizer.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/tree/TreeLocalizer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TreeLocalizer.java 1 Jun 2004 07:49:57 -0000 1.2
+++ TreeLocalizer.java 16 Jun 2004 16:45:37 -0000 1.3
@@ -24,10 +24,12 @@
package org.apache.slide.projector.processor.tree;
import org.apache.slide.projector.Context;
+import org.apache.slide.projector.ProcessException;
import org.apache.slide.projector.Processor;
import org.apache.slide.projector.Result;
import org.apache.slide.projector.processor.SimpleProcessor;
import org.apache.slide.projector.descriptor.*;
+import org.apache.slide.projector.engine.ProcessorManager;
import org.apache.slide.projector.i18n.DefaultMessage;
import org.apache.slide.projector.i18n.MessageManager;
import org.apache.slide.projector.i18n.MessageNotFoundException;
@@ -51,6 +53,8 @@
private static Logger logger = Logger.getLogger(TreeLocalizer.class.getName());
public final static String LOCALE = "locale";
+
+ protected final static String IMAGE_IDENTIFIER = "image";
private final static ParameterDescriptor[] parameterDescriptors = new ParameterDescriptor[] {
new ParameterDescriptor(SimpleProcessor.INPUT, new ParameterMessage("treeLocalizer/input"), new TreeValueDescriptor(new StringValueDescriptor())),
@@ -65,26 +69,34 @@
public Result process(Map parameter, Context context) throws Exception {
Value []resources = ((ArrayValue)parameter.get(SimpleProcessor.INPUT)).getArray();
Locale locale = (((LocaleValue)parameter.get(LOCALE)).getLocale());
- return new Result(StateDescriptor.OK, SimpleProcessor.OUTPUT, localize(resources, locale));
+ return new Result(StateDescriptor.OK, SimpleProcessor.OUTPUT, localize(resources, locale, context));
}
- private ArrayValue localize(Value []resources, Locale locale) {
+ private ArrayValue localize(Value []resources, Locale locale, Context context) throws ProcessException {
List localizedResources = new ArrayList();
for ( int i = 0; i < resources.length; i++ ) {
if ( resources[i] instanceof StringValue ) {
Map localizedMap = new HashMap();
try {
- Map entries = MessageManager.getEntries(((StringValue)resources[i]).toString(), locale);
+ localizedMap.put(TreeRenderer.ID, resources[i]);
+ Map entries = MessageManager.getEntries(((StringValue)resources[i]).toString(), locale);
for ( Iterator j = entries.entrySet().iterator(); j.hasNext(); ) {
Map.Entry entry = (Map.Entry)j.next();
- localizedMap.put((String)entry.getKey(), new StringValue((String)entry.getValue()));
+ String key = (String)entry.getKey();
+ String value = (String)entry.getValue();
+ if ( key.startsWith(IMAGE_IDENTIFIER) ) {
+ key = key.substring(IMAGE_IDENTIFIER.length()+1);
+ localizedMap.put(key, ProcessorManager.getInstance().process(ProcessorManager.BINARY, value, "url", context));
+ } else {
+ localizedMap.put(key, new StringValue(value));
+ }
}
} catch ( MessageNotFoundException exception ) {
logger.log(Level.SEVERE, "No message found while localizing tree", exception);
}
localizedResources.add(new MapValue(localizedMap));
} else if ( resources[i] instanceof ArrayValue ) {
- localizedResources.add(localize(((ArrayValue)resources[i]).getArray(), locale));
+ localizedResources.add(localize(((ArrayValue)resources[i]).getArray(), locale, context));
}
}
Value[] localizedResourceArray = new Value[localizedResources.size()];
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org