01: /******************************************************************************
02: * JBoss, a division of Red Hat *
03: * Copyright 2006, Red Hat Middleware, LLC, and individual *
04: * contributors as indicated by the @authors tag. See the *
05: * copyright.txt in the distribution for a full listing of *
06: * individual contributors. *
07: * *
08: * This is free software; you can redistribute it and/or modify it *
09: * under the terms of the GNU Lesser General Public License as *
10: * published by the Free Software Foundation; either version 2.1 of *
11: * the License, or (at your option) any later version. *
12: * *
13: * This software is distributed in the hope that it will be useful, *
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16: * Lesser General Public License for more details. *
17: * *
18: * You should have received a copy of the GNU Lesser General Public *
19: * License along with this software; if not, write to the Free *
20: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
21: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
22: ******************************************************************************/package org.jboss.portal.core.identity.services.impl;
23:
24: import org.jboss.portal.core.controller.ControllerCommand;
25: import org.jboss.portal.core.controller.ControllerContext;
26: import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
27: import org.jboss.portal.core.identity.services.IdentityCommandFactory;
28: import org.jboss.portal.core.identity.services.IdentityConstants;
29: import org.jboss.portal.core.identity.services.metadata.CoreIdentityConfigurationException;
30: import org.jboss.portal.core.identity.services.workflow.ValidateEmailService;
31: import org.jboss.portal.core.model.instance.command.action.InvokePortletInstanceRenderCommand;
32: import org.jboss.portal.portlet.PortletParametersStateString;
33: import org.jboss.portal.server.ServerInvocation;
34:
35: /**
36: * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
37: * @version $Revision$
38: */
39: public class IdentityCommandFactoryService extends
40: AbstractCommandFactory implements IdentityCommandFactory {
41: /** Portlet instance */
42: private String instanceId;
43:
44: /** jBPM email validation service */
45: protected ValidateEmailService validateEmailService = null;
46:
47: public void setInstanceId(String instanceId) {
48: this .instanceId = instanceId;
49: }
50:
51: public void setValidateEmailService(
52: ValidateEmailService validateEmailService) {
53: this .validateEmailService = validateEmailService;
54: }
55:
56: public ControllerCommand doMapping(
57: ControllerContext controllerContext,
58: ServerInvocation invocation, String host,
59: String contextPath, String requestPath) {
60: PortletParametersStateString renderParameters = new PortletParametersStateString();
61: String operation = IdentityConstants.VALIDATION_FAILED;
62:
63: if (requestPath != null && requestPath.length() > 1) {
64:
65: // Remove starting /
66: String rPath = requestPath.trim().substring(1,
67: requestPath.length());
68: String[] aRequest = rPath.split("/");
69: int aLength = aRequest.length;
70:
71: if (aLength == 2) {
72: String bpmId = aRequest[0];
73: String hash = aRequest[1];
74: try {
75: // Validating email
76: String status = validateEmailService.validateEmail(
77: bpmId, hash);
78: // Passing status to portlet render parameters
79: operation = status;
80: } catch (CoreIdentityConfigurationException e) {
81: log.error(e);
82: operation = IdentityConstants.VALIDATION_ERROR;
83: }
84:
85: }
86: }
87: // Perform a render URL on the target window
88:
89: renderParameters.setValue("operation", operation);
90: InvokePortletInstanceRenderCommand ipirc = new InvokePortletInstanceRenderCommand(
91: instanceId, renderParameters);
92: return ipirc;
93: }
94:
95: }
|