public TestResult checkExpectedEventWasFired(EventRequest request,
EventResponse response) {
tally(response);
TestResult result = new TestResult();
result.setSpecPLT("15.2.2");
result.setDescription("Check to make sure the the " +
SIMPLE_PAYLOAD_EVENT + " event was fired.");
Event event = request.getEvent();
if (event == null) {
throw new NullPointerException("No event was received!");
}
if (SIMPLE_PAYLOAD_EVENT.equals(event.getName())) {
result.setReturnCode(TestResult.PASSED);
} else {
result.setReturnCode(TestResult.FAILED);
result.setResultMessage("Expected event name to be '" +
SIMPLE_PAYLOAD_EVENT + "' but it was actually '" +
event.getName() + "'");
}
return result;
}
java类javax.portlet.Event的实例源码
SimplePayloadEventTest.java 文件源码
项目:portals-pluto
阅读 21
收藏 0
点赞 0
评论 0
SimplePayloadEventTest.java 文件源码
项目:portals-pluto
阅读 19
收藏 0
点赞 0
评论 0
public TestResult checkEventPayloadIsCorrectClass(EventRequest request,
EventResponse response) {
tally(response);
TestResult result = new TestResult();
result.setSpecPLT("15.2.2");
result.setDescription("Check to make sure that payload is an instance" +
"of " + String.class);
Event event = request.getEvent();
if (event == null) {
throw new NullPointerException("No event received!");
}
Object value = event.getValue();
if (value == null) {
result.setReturnCode(TestResult.FAILED);
result.setResultMessage("Expected event payload type to be '" +
String.class.getName() + "' but it was null.");
} else if (value instanceof String) {
result.setReturnCode(TestResult.PASSED);
} else {
result.setReturnCode(TestResult.FAILED);
result.setResultMessage("Expected event payload type to be '" +
String.class.getName() + "' but it was actually '" +
value.getClass().getName() + "'");
}
return result;
}
AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration2.java 文件源码
项目:portals-pluto
阅读 18
收藏 0
点赞 0
评论 0
@EventMethod(
portletName = "AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration2",
processingEvents = @PortletQName(
localPart = "AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration2a",
namespaceURI = "http://www.apache.org/portals/pluto/portlet-tck_3.0"
)
)
public void processEventa(EventRequest portletReq, EventResponse portletResp)
throws PortletException, IOException {
Event e = portletReq.getEvent();
String eventPayload = (String) e.getValue();
if(eventPayload!=null && eventPayload.equals("a")){
MutableRenderParameters mutableRenderParameters = portletResp.getRenderParameters();
mutableRenderParameters.setValue("tr0_a", "true");
}
}
AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration2.java 文件源码
项目:portals-pluto
阅读 16
收藏 0
点赞 0
评论 0
@EventMethod(
portletName = "AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration2",
processingEvents = @PortletQName(
localPart = "AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration2b",
namespaceURI = "http://www.apache.org/portals/pluto/portlet-tck_3.0"
)
)
public void processEventb(EventRequest portletReq, EventResponse portletResp)
throws PortletException, IOException {
Event e = portletReq.getEvent();
String eventPayload = (String) e.getValue();
if(eventPayload!=null && eventPayload.equals("b")){
MutableRenderParameters mutableRenderParameters = portletResp.getRenderParameters();
mutableRenderParameters.setValue("tr0_b", "true");
}
}
AnnotationPortletAppConfigOverrideTests_SPEC1_28_PublicRenderParameters3.java 文件源码
项目:portals-pluto
阅读 15
收藏 0
点赞 0
评论 0
@EventMethod(
portletName = "AnnotationPortletAppConfigOverrideTests_SPEC1_28_PublicRenderParameters3",
processingEvents = @PortletQName(
localPart = "AnnotationPortletAppConfigOverrideTests_SPEC1_28_PublicRenderParameters2",
namespaceURI = "http://www.apache.org/portals/pluto/portlet-tck_3.0"
)
)
public void processEventb(EventRequest portletReq, EventResponse portletResp)
throws PortletException, IOException {
Event e = portletReq.getEvent();
String eventPayload = (String) e.getValue();
if(eventPayload!=null && eventPayload.equals("Hi!")){
MutableRenderParameters mutableRenderParameters = portletResp.getRenderParameters();
mutableRenderParameters.setValue("tr2_public", "true");
}
}
AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration1.java 文件源码
项目:portals-pluto
阅读 17
收藏 0
点赞 0
评论 0
@EventMethod(
portletName = "AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration1",
processingEvents = @PortletQName(
localPart = "AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration1",
namespaceURI = "http://www.apache.org/portals/pluto/portlet-tck_3.0"
)
)
public void processEventTr0(EventRequest portletReq, EventResponse portletResp)
throws PortletException, IOException {
Event e = portletReq.getEvent();
String eventPayload = (String) e.getValue();
if(eventPayload!=null && eventPayload.equals("Hi!")){
MutableRenderParameters mutableRenderParameters = portletResp.getRenderParameters();
mutableRenderParameters.setValue("tr0", "true");
}
}
AddlPortletTests_SPEC2_5_RenderGenericPortlet_event.java 文件源码
项目:portals-pluto
阅读 27
收藏 0
点赞 0
评论 0
@ProcessEvent(qname = "AddlPortletTests_SPEC2_5_RenderGenericPortlet")
public void processEvent(EventRequest portletReq, EventResponse portletResp)
throws PortletException, IOException {
JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails();
/* TestCase: V2AddlPortletTests_SPEC2_5_RenderGenericPortlet_eventDispatching1 */
/* Details: "The GenericPortlet processEvent method will dispatch the */
/* request to a subclass method annotated with the tag */
/* @ProcessEvent(qname=<eventname>), where <eventname> */
/* must be in the format provided by Qname.toString()" */
Event event = portletReq.getEvent();
String qName = event.getName();
TestResult tr1 =
tcd.getTestResultFailed(V2ADDLPORTLETTESTS_SPEC2_5_RENDERGENERICPORTLET_EVENTDISPATCHING1);
if (qName.toString().equals("AddlPortletTests_SPEC2_5_RenderGenericPortlet")) {
tr1.setTcSuccess(true);
} else {
tr1.appendTcDetail(
"Failed because QName is not AddlPortletTests_SPEC2_5_RenderGenericPortlet");
}
portletReq.getPortletSession().setAttribute(
Constants.RESULT_ATTR_PREFIX + "AddlPortletTests_SPEC2_5_RenderGenericPortlet_event_a",
tr1.toString(), APPLICATION_SCOPE);
}
StateAwareResponseImpl.java 文件源码
项目:portals-pluto
阅读 19
收藏 0
点赞 0
评论 0
public void setEvent(QName qname, Serializable value) {
ArgumentUtility.validateNotNull("qname", qname);
if (LOGGER.isTraceEnabled()) {
StringBuilder txt = new StringBuilder(128);
txt.append("QName: ").append(qname.toString());
txt.append(", value class: ").append((value == null) ? "null": value.getClass().getCanonicalName());
LOGGER.debug(txt.toString());
}
Event event = responseContext.getEventProvider()
.createEvent(qname, value);
if (event != null) {
responseContext.getEvents().add(event);
}
}
AnnotationMethodHandlerAdapter.java 文件源码
项目:spring4-understanding
阅读 19
收藏 0
点赞 0
评论 0
public boolean match(PortletRequest request) {
if (!this.modes.isEmpty() && !this.modes.contains(request.getPortletMode())) {
return false;
}
if (StringUtils.hasLength(this.phase) &&
!this.phase.equals(request.getAttribute(PortletRequest.LIFECYCLE_PHASE))) {
return false;
}
if (StringUtils.hasLength(this.value)) {
if (this.phase.equals(PortletRequest.ACTION_PHASE) &&
!this.value.equals(request.getParameter(ActionRequest.ACTION_NAME))) {
return false;
}
else if (this.phase.equals(PortletRequest.RENDER_PHASE) &&
!(new WindowState(this.value)).equals(request.getWindowState())) {
return false;
}
else if (this.phase.equals(PortletRequest.RESOURCE_PHASE) &&
!this.value.equals(((ResourceRequest) request).getResourceID())) {
return false;
}
else if (this.phase.equals(PortletRequest.EVENT_PHASE)) {
Event event = ((EventRequest) request).getEvent();
if (!this.value.equals(event.getName()) && !this.value.equals(event.getQName().toString())) {
return false;
}
}
}
return (PortletAnnotationMappingUtils.checkRequestMethod(this.methods, request) &&
PortletAnnotationMappingUtils.checkParameters(this.params, request) &&
PortletAnnotationMappingUtils.checkHeaders(this.headers, request));
}
DefaultAnnotationHandlerMapping.java 文件源码
项目:spring4-understanding
阅读 23
收藏 0
点赞 0
评论 0
@Override
public boolean match(PortletRequest request) {
if (!PortletRequest.EVENT_PHASE.equals(request.getAttribute(PortletRequest.LIFECYCLE_PHASE))) {
return false;
}
if ("".equals(this.eventName)) {
return true;
}
Event event = ((EventRequest) request).getEvent();
return (this.eventName.equals(event.getName()) || this.eventName.equals(event.getQName().toString()));
}
DossierProcPortlet.java 文件源码
项目:OEPv2
阅读 22
收藏 0
点赞 0
评论 0
@ProcessEvent(qname = "{http://org.oep.com/events}ipc-domainno")
public void myDomainNoEvent(EventRequest request, EventResponse response) {
Event event = request.getEvent();
String domainNo = event.getValue().toString();
response.setRenderParameter("domainNo", domainNo);
}
DossierProcPortlet.java 文件源码
项目:OEPv2
阅读 20
收藏 0
点赞 0
评论 0
@ProcessEvent(qname = "{http://org.oep.com/events}ipc-administrationno")
public void myAdministrationNoEvent(EventRequest request,
EventResponse response) {
Event event = request.getEvent();
// Get data from the event
String administrationNo = event.getValue().toString();
response.setRenderParameter("administrationNo", administrationNo);
}
IpcEventReceiverPortlet.java 文件源码
项目:OEPv2
阅读 18
收藏 0
点赞 0
评论 0
@ProcessEvent(qname = "{http://proliferay.com/events}ipc-text")
public void myEvent(EventRequest request, EventResponse response) {
Event event = request.getEvent();
//Get data from the event
//String sampleText = (String) event.getValue();
Employee employee = (Employee)event.getValue();
//Set the text in response to display in UI
response.setRenderParameter("sampleText", employee.name);
}
AnnotationMethodHandlerAdapter.java 文件源码
项目:class-guard
阅读 20
收藏 0
点赞 0
评论 0
public boolean match(PortletRequest request) {
if (!this.modes.isEmpty() && !this.modes.contains(request.getPortletMode())) {
return false;
}
if (StringUtils.hasLength(this.phase) &&
!this.phase.equals(request.getAttribute(PortletRequest.LIFECYCLE_PHASE))) {
return false;
}
if (StringUtils.hasLength(this.value)) {
if (this.phase.equals(PortletRequest.ACTION_PHASE) &&
!this.value.equals(request.getParameter(ActionRequest.ACTION_NAME))) {
return false;
}
else if (this.phase.equals(PortletRequest.RENDER_PHASE) &&
!(new WindowState(this.value)).equals(request.getWindowState())) {
return false;
}
else if (this.phase.equals(PortletRequest.RESOURCE_PHASE) &&
!this.value.equals(((ResourceRequest) request).getResourceID())) {
return false;
}
else if (this.phase.equals(PortletRequest.EVENT_PHASE)) {
Event event = ((EventRequest) request).getEvent();
if (!this.value.equals(event.getName()) && !this.value.equals(event.getQName().toString())) {
return false;
}
}
}
return PortletAnnotationMappingUtils.checkRequestMethod(this.methods, request) &&
PortletAnnotationMappingUtils.checkParameters(this.params, request) &&
PortletAnnotationMappingUtils.checkHeaders(this.headers, request);
}
DefaultAnnotationHandlerMapping.java 文件源码
项目:class-guard
阅读 23
收藏 0
点赞 0
评论 0
public boolean match(PortletRequest request) {
if (!PortletRequest.EVENT_PHASE.equals(request.getAttribute(PortletRequest.LIFECYCLE_PHASE))) {
return false;
}
if ("".equals(this.eventName)) {
return true;
}
Event event = ((EventRequest) request).getEvent();
return (this.eventName.equals(event.getName()) || this.eventName.equals(event.getQName().toString()));
}
AddlPortletTests_SPEC2_15_Event_event.java 文件源码
项目:portals-pluto
阅读 16
收藏 0
点赞 0
评论 0
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
throws PortletException, IOException {
portletResp.setRenderParameters(portletReq);
long tid = Thread.currentThread().getId();
portletReq.setAttribute(THREADID_ATTR, tid);
StringWriter writer = new StringWriter();
JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails();
// Create result objects for the tests
/* TestCase: V2AddlPortletTests_SPEC2_15_Event_event1 */
/* Details: "Event names are defined in the deployment descriptor" */
TestResult tr0 = tcd.getTestResultFailed(V2ADDLPORTLETTESTS_SPEC2_15_EVENT_EVENT1);
Event event = portletReq.getEvent();
if (event.getName().equals("AddlPortletTests_SPEC2_15_Event")) {
tr0.setTcSuccess(true);
} else {
tr0.appendTcDetail(
"Event name is not \"AddlPortletTests_SPEC2_15_Event\" but \"" + event.getName() + "\"");
}
tr0.writeTo(writer);
portletReq.getPortletSession().setAttribute(
RESULT_ATTR_PREFIX + "AddlPortletTests_SPEC2_15_Event", writer.toString(),
APPLICATION_SCOPE);
}
AddlPortletTests_SPEC2_5_EventHandling_event.java 文件源码
项目:portals-pluto
阅读 19
收藏 0
点赞 0
评论 0
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
throws PortletException, IOException {
portletResp.setRenderParameters(portletReq);
long tid = Thread.currentThread().getId();
portletReq.setAttribute(THREADID_ATTR, tid);
Event event = portletReq.getEvent();
String qName = event.getName();
if (qName.equals("AddlPortletTests_SPEC2_5_EventHandling_exception4")) {
/* TestCase: V2AddlPortletTests_SPEC2_5_EventHandling_exception4 */
/* Details: "If the portlet throws an PortletException in */
/* processEvent, all operations on the EventResponse, including set */
/* events, must be ignored" */
portletResp.setRenderParameter("tr0", "true");
portletReq.getPortletSession().setAttribute(
RESULT_ATTR_PREFIX + "AddlPortletTests_SPEC2_5_EventHandling_portletException", "true",
APPLICATION_SCOPE);
throw new PortletException(
"PortletException from V2AddlPortletTests_SPEC2_5_EventHandling_exception4");
} else if (qName.equals("AddlPortletTests_SPEC2_5_EventHandling_exception5")) {
/* TestCase: V2AddlPortletTests_SPEC2_5_EventHandling_exception5 */
/* Details: "If the portlet throws a RuntimeException in */
/* processEvent, all operations on the EventResponse, including set */
/* events, must be ignored" */
portletResp.setRenderParameter("tr1", "true");
portletReq.getPortletSession().setAttribute(
RESULT_ATTR_PREFIX + "AddlPortletTests_SPEC2_5_EventHandling_runtimeException", "true",
APPLICATION_SCOPE);
throw new RuntimeException(
"RuntimeException from V2AddlPortletTests_SPEC2_5_EventHandling_exception5");
}
}
AddlPortletTests_SPEC2_15_EventEventHandling.java 文件源码
项目:portals-pluto
阅读 16
收藏 0
点赞 0
评论 0
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
throws PortletException, IOException {
portletResp.setRenderParameters(portletReq);
long tid = Thread.currentThread().getId();
portletReq.setAttribute(THREADID_ATTR, tid);
StringWriter writer = new StringWriter();
JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails();
Event event = portletReq.getEvent();
String qName = event.getName();
if (qName.equals("AddlPortletTests_SPEC2_15_EventEventHandling")) {
/* TestCase: V2AddlPortletTests_SPEC2_15_EventEventHandling_eventProcessEvent9 */
/* Details: "The portlet can publish multiple events via the setEvent */
/* method in the processEvent method" */
TestResult tr17 = tcd
.getTestResultFailed(V2ADDLPORTLETTESTS_SPEC2_15_EVENTEVENTHANDLING_EVENTPROCESSEVENT9);
tr17.setTcSuccess(true);
tr17.writeTo(writer);
} else if (qName.equals("AddlPortletTests_SPEC2_15_EventEventHandling_eventEvent")) {
/* TestCase: V2AddlPortletTests_SPEC2_15_EventEventHandling_eventProcessEvent1 */
/* Details: "The portlet can publish an event via the setEvent method */
/* in the processEvent method" */
TestResult tr9 = tcd
.getTestResultFailed(V2ADDLPORTLETTESTS_SPEC2_15_EVENTEVENTHANDLING_EVENTPROCESSEVENT1);
tr9.setTcSuccess(true);
tr9.writeTo(writer);
}
String msg = (String) portletReq.getPortletSession().getAttribute(
RESULT_ATTR_PREFIX + "AddlPortletTests_SPEC2_15_EventEventHandling", APPLICATION_SCOPE);
msg = msg + writer.toString();
portletReq.getPortletSession().setAttribute(
RESULT_ATTR_PREFIX + "AddlPortletTests_SPEC2_15_EventEventHandling", msg,
APPLICATION_SCOPE);
}
EventRequestWrapperChecker.java 文件源码
项目:portals-pluto
阅读 17
收藏 0
点赞 0
评论 0
@Override
public Event getEvent() {
String meth = "getEvent";
Object[] args = {};
Event ret = ((EventRequest) req).getEvent();
retVal = ret;
checkArgs(meth, args);
return ret;
}
PortletStateAwareResponseContextImpl.java 文件源码
项目:portals-pluto
阅读 19
收藏 0
点赞 0
评论 0
@Override
public List<Event> getEvents() {
if (isReleased()) {
return null;
}
if (events == null) {
events = new ArrayList<Event>();
}
return events;
}
ManageEventHandler.java 文件源码
项目:odp-manage-datasets-portlet
阅读 18
收藏 0
点赞 0
评论 0
@SuppressWarnings({ "static-access" })
@Override
public EventNavigationResult handleEvent(FacesContext facesContext, Event event) {
String eventQName = event.getQName().toString();
if (eventQName.equals("{http://fokus.fraunhofer.de/odplatform}metadata")) {
Metadata eData = (Metadata) event.getValue();
if (eData != null) {
PortletRequest request = (PortletRequest) facesContext.getCurrentInstance().getExternalContext().getRequest();
PortletSession session = request.getPortletSession();
session.setAttribute("metadata", eData);
}
}
return null;
}
AnnotationMethodHandlerAdapter.java 文件源码
项目:spring4-understanding
阅读 25
收藏 0
点赞 0
评论 0
@Override
protected Object resolveStandardArgument(Class<?> parameterType, NativeWebRequest webRequest)
throws Exception {
PortletRequest request = webRequest.getNativeRequest(PortletRequest.class);
PortletResponse response = webRequest.getNativeResponse(PortletResponse.class);
if (PortletRequest.class.isAssignableFrom(parameterType) ||
MultipartRequest.class.isAssignableFrom(parameterType)) {
Object nativeRequest = webRequest.getNativeRequest(parameterType);
if (nativeRequest == null) {
throw new IllegalStateException(
"Current request is not of type [" + parameterType.getName() + "]: " + request);
}
return nativeRequest;
}
else if (PortletResponse.class.isAssignableFrom(parameterType)) {
Object nativeResponse = webRequest.getNativeResponse(parameterType);
if (nativeResponse == null) {
throw new IllegalStateException(
"Current response is not of type [" + parameterType.getName() + "]: " + response);
}
return nativeResponse;
}
else if (PortletSession.class.isAssignableFrom(parameterType)) {
return request.getPortletSession();
}
else if (PortletPreferences.class.isAssignableFrom(parameterType)) {
return request.getPreferences();
}
else if (PortletMode.class.isAssignableFrom(parameterType)) {
return request.getPortletMode();
}
else if (WindowState.class.isAssignableFrom(parameterType)) {
return request.getWindowState();
}
else if (PortalContext.class.isAssignableFrom(parameterType)) {
return request.getPortalContext();
}
else if (Principal.class.isAssignableFrom(parameterType)) {
return request.getUserPrincipal();
}
else if (Locale.class == parameterType) {
return request.getLocale();
}
else if (InputStream.class.isAssignableFrom(parameterType)) {
if (!(request instanceof ClientDataRequest)) {
throw new IllegalStateException("InputStream can only get obtained for Action/ResourceRequest");
}
return ((ClientDataRequest) request).getPortletInputStream();
}
else if (Reader.class.isAssignableFrom(parameterType)) {
if (!(request instanceof ClientDataRequest)) {
throw new IllegalStateException("Reader can only get obtained for Action/ResourceRequest");
}
return ((ClientDataRequest) request).getReader();
}
else if (OutputStream.class.isAssignableFrom(parameterType)) {
if (!(response instanceof MimeResponse)) {
throw new IllegalStateException("OutputStream can only get obtained for Render/ResourceResponse");
}
return ((MimeResponse) response).getPortletOutputStream();
}
else if (Writer.class.isAssignableFrom(parameterType)) {
if (!(response instanceof MimeResponse)) {
throw new IllegalStateException("Writer can only get obtained for Render/ResourceResponse");
}
return ((MimeResponse) response).getWriter();
}
else if (Event.class == parameterType) {
if (!(request instanceof EventRequest)) {
throw new IllegalStateException("Event can only get obtained from EventRequest");
}
return ((EventRequest) request).getEvent();
}
return super.resolveStandardArgument(parameterType, webRequest);
}
MockEventRequest.java 文件源码
项目:spring4-understanding
阅读 17
收藏 0
点赞 0
评论 0
@Override
public Event getEvent() {
return this.event;
}
MockEventRequest.java 文件源码
项目:spring4-understanding
阅读 20
收藏 0
点赞 0
评论 0
@Override
public Event getEvent() {
return this.event;
}
AnnotationMethodHandlerAdapter.java 文件源码
项目:class-guard
阅读 27
收藏 0
点赞 0
评论 0
@Override
protected Object resolveStandardArgument(Class<?> parameterType, NativeWebRequest webRequest)
throws Exception {
PortletRequest request = webRequest.getNativeRequest(PortletRequest.class);
PortletResponse response = webRequest.getNativeResponse(PortletResponse.class);
if (PortletRequest.class.isAssignableFrom(parameterType) ||
MultipartRequest.class.isAssignableFrom(parameterType)) {
Object nativeRequest = webRequest.getNativeRequest(parameterType);
if (nativeRequest == null) {
throw new IllegalStateException(
"Current request is not of type [" + parameterType.getName() + "]: " + request);
}
return nativeRequest;
}
else if (PortletResponse.class.isAssignableFrom(parameterType)) {
Object nativeResponse = webRequest.getNativeResponse(parameterType);
if (nativeResponse == null) {
throw new IllegalStateException(
"Current response is not of type [" + parameterType.getName() + "]: " + response);
}
return nativeResponse;
}
else if (PortletSession.class.isAssignableFrom(parameterType)) {
return request.getPortletSession();
}
else if (PortletPreferences.class.isAssignableFrom(parameterType)) {
return request.getPreferences();
}
else if (PortletMode.class.isAssignableFrom(parameterType)) {
return request.getPortletMode();
}
else if (WindowState.class.isAssignableFrom(parameterType)) {
return request.getWindowState();
}
else if (PortalContext.class.isAssignableFrom(parameterType)) {
return request.getPortalContext();
}
else if (Principal.class.isAssignableFrom(parameterType)) {
return request.getUserPrincipal();
}
else if (Locale.class.equals(parameterType)) {
return request.getLocale();
}
else if (InputStream.class.isAssignableFrom(parameterType)) {
if (!(request instanceof ClientDataRequest)) {
throw new IllegalStateException("InputStream can only get obtained for Action/ResourceRequest");
}
return ((ClientDataRequest) request).getPortletInputStream();
}
else if (Reader.class.isAssignableFrom(parameterType)) {
if (!(request instanceof ClientDataRequest)) {
throw new IllegalStateException("Reader can only get obtained for Action/ResourceRequest");
}
return ((ClientDataRequest) request).getReader();
}
else if (OutputStream.class.isAssignableFrom(parameterType)) {
if (!(response instanceof MimeResponse)) {
throw new IllegalStateException("OutputStream can only get obtained for Render/ResourceResponse");
}
return ((MimeResponse) response).getPortletOutputStream();
}
else if (Writer.class.isAssignableFrom(parameterType)) {
if (!(response instanceof MimeResponse)) {
throw new IllegalStateException("Writer can only get obtained for Render/ResourceResponse");
}
return ((MimeResponse) response).getWriter();
}
else if (Event.class.equals(parameterType)) {
if (!(request instanceof EventRequest)) {
throw new IllegalStateException("Event can only get obtained from EventRequest");
}
return ((EventRequest) request).getEvent();
}
return super.resolveStandardArgument(parameterType, webRequest);
}
MockEventRequest.java 文件源码
项目:class-guard
阅读 21
收藏 0
点赞 0
评论 0
@Override
public Event getEvent() {
return this.event;
}
MockEventRequest.java 文件源码
项目:class-guard
阅读 23
收藏 0
点赞 0
评论 0
public Event getEvent() {
return this.event;
}
EventProvider.java 文件源码
项目:portals-pluto
阅读 20
收藏 0
点赞 0
评论 0
Event createEvent(QName name, Serializable value)
throws IllegalArgumentException;
RequestTests_EventRequest_ApiEvent_event.java 文件源码
项目:portals-pluto
阅读 16
收藏 0
点赞 0
评论 0
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
throws PortletException, IOException {
LOGGER.trace("event companion processEvent");
portletResp.setRenderParameters(portletReq);
long tid = Thread.currentThread().getId();
portletReq.setAttribute(THREADID_ATTR, tid);
StringWriter writer = new StringWriter();
JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();
// Create result objects for the tests
/* TestCase: V2RequestTests_EventRequest_ApiEvent_getEvent */
/* Details: "Method getEvent(): Returns the Event object that */
/* triggered the call to the processEvent method" */
TestResult tr0 = tcd.getTestResultFailed(V2REQUESTTESTS_EVENTREQUEST_APIEVENT_GETEVENT);
Event evt=portletReq.getEvent();
if(evt!=null) {
tr0.setTcSuccess(true);
}
tr0.writeTo(writer);
/* TestCase: V2RequestTests_EventRequest_ApiEvent_getMethod */
/* Details: "Method getMethod(): Returns a String containing the name */
/* of the HTTP method with which the request was made" */
TestResult tr1 = tcd.getTestResultFailed(V2REQUESTTESTS_EVENTREQUEST_APIEVENT_GETMETHOD);
String getmethod=portletReq.getMethod();
if(getmethod.equals("POST")) {
tr1.setTcSuccess(true);
} else {
tr1.appendTcDetail("The getMethod() for HTTP Request has the value :" +getmethod);
}
tr1.writeTo(writer);
portletReq.getPortletSession().setAttribute(
Constants.RESULT_ATTR_PREFIX + "RequestTests_EventRequest_ApiEvent",
writer.toString(), APPLICATION_SCOPE);
}
PortletContainerImpl.java 文件源码
项目:portals-pluto
阅读 19
收藏 0
点赞 0
评论 0
/**
* Fire Event for the portlet associated with the given portlet window and eventName
* @param portletWindow the portlet window.
* @param request the servlet request.
* @param response the servlet response.
* @param event the event
* @throws PortletException
* @throws IOException
* @throws PortletContainerException
*
* @see javax.portlet.EventPortlet#processEvent(javax.portlet.EventRequest, javax.portlet.EventResponse)
*/
public void doEvent(PortletWindow portletWindow,
HttpServletRequest request,
HttpServletResponse response,
Event event)
throws PortletException, IOException, PortletContainerException
{
ensureInitialized();
debugWithName("Event: "+event.getName()+" received for portlet: "
+ portletWindow.getPortletDefinition().getPortletName());
PortletRequestContextService rcService = getContainerServices().getPortletRequestContextService();
PortletEnvironmentService envService = getContainerServices().getPortletEnvironmentService();
PortletInvokerService invoker = getContainerServices().getPortletInvokerService();
PortletRequestContext requestContext = rcService.getPortletEventRequestContext(this, request, response, portletWindow);
PortletEventResponseContext responseContext = rcService.getPortletEventResponseContext(this, request, response, portletWindow, requestContext);
responseContext.setPropsAllowed(true);
EventRequest portletRequest = envService.createEventRequest(requestContext, responseContext, event);
EventResponse portletResponse = envService.createEventResponse(responseContext);
FilterManager filterManager = filterInitialisation(portletWindow,PortletRequest.EVENT_PHASE);
List<Event> events = null;
try
{
invoker.event(requestContext, portletRequest, portletResponse, filterManager);
debugWithName("Portlet event processed for: "
+ portletWindow.getPortletDefinition().getPortletName());
// add http headers to response
responseContext.processHttpHeaders();
// Mark portlet interaction is completed: backend implementation can flush response state now
responseContext.close();
events = responseContext.getEvents();
} catch (Throwable t) {
// Throw away events and parameters that were set
responseContext.reset();
// just swallow the exception, ignoring changes to the response
StringBuilder txt = new StringBuilder(128);
txt.append("Exception during action request processing. Exception: ");
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
pw.flush();
txt.append(sw.toString());
LOG.warn(txt.toString());
}
finally
{
responseContext.release();
}
if (events != null && !events.isEmpty())
{
getContainerServices().getEventCoordinationService().processEvents(this, portletWindow, request, response, events);
}
debugWithName("Portlet event: "+ event.getName() +" fired for: " + portletWindow.getPortletDefinition().getPortletName());
}