1
16
17 package org.apache.wsrp4j.producer.driver;
18
19 import java.rmi.RemoteException;
20 import java.util.ArrayList;
21 import java.util.Arrays;
22 import java.util.Iterator;
23
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpSession;
26
27 import oasis.names.tc.wsrp.v1.types.BlockingInteractionResponse;
28 import oasis.names.tc.wsrp.v1.types.ClonePortlet;
29 import oasis.names.tc.wsrp.v1.types.DestroyFailed;
30 import oasis.names.tc.wsrp.v1.types.DestroyPortlets;
31 import oasis.names.tc.wsrp.v1.types.DestroyPortletsResponse;
32 import oasis.names.tc.wsrp.v1.types.GetMarkup;
33 import oasis.names.tc.wsrp.v1.types.GetPortletDescription;
34 import oasis.names.tc.wsrp.v1.types.GetPortletProperties;
35 import oasis.names.tc.wsrp.v1.types.GetPortletPropertyDescription;
36 import oasis.names.tc.wsrp.v1.types.GetServiceDescription;
37 import oasis.names.tc.wsrp.v1.types.InitCookie;
38 import oasis.names.tc.wsrp.v1.types.MarkupParams;
39 import oasis.names.tc.wsrp.v1.types.MarkupResponse;
40 import oasis.names.tc.wsrp.v1.types.MarkupType;
41 import oasis.names.tc.wsrp.v1.types.MissingParametersFault;
42 import oasis.names.tc.wsrp.v1.types.ModifyRegistration;
43 import oasis.names.tc.wsrp.v1.types.PerformBlockingInteraction;
44 import oasis.names.tc.wsrp.v1.types.PortletContext;
45 import oasis.names.tc.wsrp.v1.types.PortletDescription;
46 import oasis.names.tc.wsrp.v1.types.PortletDescriptionResponse;
47 import oasis.names.tc.wsrp.v1.types.PortletPropertyDescriptionResponse;
48 import oasis.names.tc.wsrp.v1.types.PropertyList;
49 import oasis.names.tc.wsrp.v1.types.RegistrationContext;
50 import oasis.names.tc.wsrp.v1.types.RegistrationData;
51 import oasis.names.tc.wsrp.v1.types.RegistrationState;
52 import oasis.names.tc.wsrp.v1.types.ReleaseSessions;
53 import oasis.names.tc.wsrp.v1.types.ReturnAny;
54 import oasis.names.tc.wsrp.v1.types.ServiceDescription;
55 import oasis.names.tc.wsrp.v1.types.SetPortletProperties;
56 import oasis.names.tc.wsrp.v1.types.StateChange;
57
58 import org.apache.axis.AxisEngine;
59 import org.apache.axis.MessageContext;
60 import org.apache.axis.transport.http.HTTPConstants;
61 import org.apache.wsrp4j.exception.ErrorCodes;
62 import org.apache.wsrp4j.exception.WSRPException;
63 import org.apache.wsrp4j.exception.WSRPXHelper;
64 import org.apache.wsrp4j.log.LogManager;
65 import org.apache.wsrp4j.log.Logger;
66 import org.apache.wsrp4j.producer.ConsumerRegistry;
67 import org.apache.wsrp4j.producer.ConsumerRegistryAccess;
68 import org.apache.wsrp4j.producer.ProviderAccess;
69 import org.apache.wsrp4j.producer.Registration;
70 import org.apache.wsrp4j.producer.provider.ConsumerConfiguredPortlet;
71 import org.apache.wsrp4j.producer.provider.DescriptionHandler;
72 import org.apache.wsrp4j.producer.provider.Portlet;
73 import org.apache.wsrp4j.producer.provider.PortletStateManager;
74 import org.apache.wsrp4j.producer.provider.ProducerOfferedPortlet;
75 import org.apache.wsrp4j.producer.provider.Provider;
76 import org.apache.wsrp4j.util.Constants;
77 import org.apache.wsrp4j.util.LocaleHelper;
78 import org.apache.wsrp4j.util.ParameterChecker;
79
80
105
106 public class WSRPEngine implements
107 oasis.names.tc.wsrp.v1.intf.WSRP_v1_PortletManagement_PortType,
108 oasis.names.tc.wsrp.v1.intf.WSRP_v1_Markup_PortType,
109 oasis.names.tc.wsrp.v1.intf.WSRP_v1_Registration_PortType,
110 oasis.names.tc.wsrp.v1.intf.WSRP_v1_ServiceDescription_PortType {
111
112 private boolean registrationRequired;
113
114 private Provider provider = null;
116
117 private ConsumerRegistry consumerRegistry = null;
119
120 private static WSRPEngine instance = null;
122
123 private ParameterChecker paramCheck = new ParameterChecker();
125
126 private Logger logger = LogManager.getLogManager().getLogger(
128 this.getClass());
129
130
133 private WSRPEngine() throws java.rmi.RemoteException {
134 String MN = "Constructor";
135 if (logger.isLogging(Logger.TRACE_HIGH)) {
136 logger.entry(Logger.TRACE_HIGH, MN);
137 }
138
139 try {
140 provider = ProviderAccess.getProvider();
141 consumerRegistry = ConsumerRegistryAccess.getConsumerRegistry();
142
143 registrationRequired = consumerRegistry.isRegistrationRequired();
144
145 }
146 catch (WSRPException e) {
147
148 WSRPXHelper.handleWSRPException(e);
149
150 }
151
152 if (logger.isLogging(Logger.TRACE_HIGH)) {
153 logger.exit(Logger.TRACE_HIGH, MN);
154 }
155
156 }
157
158
162 private void createSession() throws WSRPException {
163 MessageContext msgContext = AxisEngine.getCurrentMessageContext();
164
165 HttpServletRequest servletRequest = (HttpServletRequest) msgContext
166 .getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
167 HttpSession session = servletRequest.getSession(true);
168
169 if (session == null) {
170 throw new WSRPException(ErrorCodes.OPERATION_FAILED);
171 }
172 }
173
174
179 public synchronized static WSRPEngine getInstance()
180 throws java.rmi.RemoteException {
181 if (instance == null) {
182 instance = new WSRPEngine();
183 }
184
185 return instance;
186 }
187
188
191
192
205 public ServiceDescription getServiceDescription(
206 GetServiceDescription request) throws java.rmi.RemoteException {
207
208 String MN = "getServiceDescription";
209 if (logger.isLogging(Logger.TRACE_HIGH)) {
210 logger.entry(Logger.TRACE_HIGH, MN);
211 }
212
213 ServiceDescription description = null;
214
215 try {
216 paramCheck.check(request);
218
219 DescriptionHandler descrHandler = provider.getDescriptionHandler();
220 RegistrationContext regContext = request.getRegistrationContext();
221
222 boolean registered = false;
223
224 if (regContext != null) {
225 registered = consumerRegistry.check(regContext
226 .getRegistrationHandle());
227 }
228
229 if (!registrationRequired || ((regContext != null) && (registered))) {
232 description = descrHandler.getServiceDescription(regContext,
233 request.getDesiredLocales());
234 }
235 else {
236 if (regContext == null && !registered) {
237
238 description = descrHandler.getServiceDescription(null,
239 request.getDesiredLocales());
240 }
241 else {
242
243 throw new WSRPException(ErrorCodes.INVALID_REGISTRATION);
244 }
245 }
246
247 }
248 catch (WSRPException e) {
249
250 WSRPXHelper.handleWSRPException(e);
251
252 }
253 catch (Throwable t) {
254 t.printStackTrace();
255 }
256
257 if (logger.isLogging(Logger.TRACE_HIGH)) {
258 logger.exit(Logger.TRACE_HIGH, MN);
259 }
260
261 return description;
262 }
263
264
267
268
278 public RegistrationContext register(RegistrationData request)
279 throws java.rmi.RemoteException {
280
281 String MN = "register";
282 if (logger.isLogging(Logger.TRACE_HIGH)) {
283 logger.entry(Logger.TRACE_HIGH, MN);
284 }
285
286 RegistrationContext regContext = null;
287
288 try {
289
290 paramCheck.check(request, Constants.NILLABLE_FALSE);
292
293 Registration consumerRegistration = consumerRegistry
295 .register(request);
296
297 regContext = consumerRegistration.getRegistrationContext();
299
300 }
301 catch (WSRPException e) {
302
303 WSRPXHelper.handleWSRPException(e);
304
305 }
306
307 if (logger.isLogging(Logger.TRACE_HIGH)) {
308 logger.exit(Logger.TRACE_HIGH, MN);
309 }
310
311 return regContext;
312 }
313
314
326 public ReturnAny deregister(RegistrationContext request)
327 throws java.rmi.RemoteException {
328
329 String MN = "deregister";
330 if (logger.isLogging(Logger.TRACE_HIGH)) {
331 logger.entry(Logger.TRACE_HIGH, MN);
332 }
333
334 paramCheck.check(request, Constants.NILLABLE_FALSE);
336
337 try {
338
339 checkRegistration(request);
340
341 }
342 catch (WSRPException e) {
343
344 WSRPXHelper.handleWSRPException(e);
345 }
346
347 if (logger.isLogging(Logger.TRACE_HIGH)) {
348 logger.exit(Logger.TRACE_HIGH, MN);
349 }
350
351 return new ReturnAny();
352 }
353
354
365 public RegistrationState modifyRegistration(ModifyRegistration request)
366 throws java.rmi.RemoteException {
367
368 String MN = "modifyRegistration";
369 if (logger.isLogging(Logger.TRACE_HIGH)) {
370 logger.entry(Logger.TRACE_HIGH, MN);
371 }
372
373 paramCheck.check(request);
375
376
380 RegistrationState regState = null;
381
382 try {
383
384 checkRegistration(request.getRegistrationContext());
385
386 }
387 catch (WSRPException e) {
388
389 WSRPXHelper.handleWSRPException(e);
390 }
391
392 Registration registration = consumerRegistry.get(request
393 .getRegistrationContext().getRegistrationHandle());
394
395 registration.setRegistrationData(request.getRegistrationData());
397 registration.setRegistrationContext(request.getRegistrationContext());
398
399 regState = new RegistrationState();
402 regState.setRegistrationState(registration.getRegistrationContext()
403 .getRegistrationState());
404 regState.setExtensions(null);
405
406 if (logger.isLogging(Logger.TRACE_HIGH)) {
407 logger.exit(Logger.TRACE_HIGH, MN);
408 }
409
410 return regState;
411
412 }
413
414
424 private void checkRegistration(RegistrationContext registrationContext)
425 throws java.rmi.RemoteException, WSRPException {
426
427 String MN = "checkRegistration";
428 if (logger.isLogging(Logger.TRACE_HIGH)) {
429 logger.entry(Logger.TRACE_HIGH, MN);
430 }
431
432 paramCheck.check(registrationContext, Constants.NILLABLE_FALSE);
433
434 if (!consumerRegistry
435 .check(registrationContext.getRegistrationHandle())) {
436 throw new WSRPException(ErrorCodes.INVALID_REGISTRATION);
437
438 }
439
440 if (logger.isLogging(Logger.TRACE_HIGH)) {
441 logger.exit(Logger.TRACE_HIGH, MN);
442 }
443
444 }
445
446
456 private Portlet getPortlet(RegistrationContext registrationContext,
457 String portletHandle) throws java.rmi.RemoteException {
458
459 String MN = "getPortlet";
460 if (logger.isLogging(Logger.TRACE_HIGH)) {
461 logger.entry(Logger.TRACE_HIGH, MN);
462 }
463
464 Portlet portlet = null;
465
466 try {
467
468 portlet = provider.getPortletPool().get(portletHandle);
469
470 if (registrationRequired) {
471 ProducerOfferedPortlet parent = null;
472
473 if (portlet instanceof ProducerOfferedPortlet) {
474 parent = (ProducerOfferedPortlet) portlet;
475 }
476 else {
477 String regHandle = registrationContext
479 .getRegistrationHandle();
480 if (!provider.getPortletRegistrationFilter().isAvailable(
481 regHandle, portletHandle)) {
482 throw new WSRPException(ErrorCodes.ACCESS_DENIED);
483 }
484
485 String parentHandle = ((ConsumerConfiguredPortlet) portlet)
487 .getParentHandle();
488
489 parent = (ProducerOfferedPortlet) provider.getPortletPool()
490 .get(parentHandle);
491
492 }
493
494 if ((parent != null) && parent.isRegistrationRequired()) {
495 checkRegistration(registrationContext);
496 }
497
498 }
499
500 }
501 catch (WSRPException e) {
502 WSRPXHelper.handleWSRPException(e);
503 }
504
505 if (logger.isLogging(Logger.TRACE_HIGH)) {
506 logger.exit(Logger.TRACE_HIGH, MN);
507 }
508
509 return portlet;
510 }
511
512
517 private void checkCookie() throws java.rmi.RemoteException, WSRPException {
518 MessageContext msgContext = AxisEngine.getCurrentMessageContext();
520
521 HttpServletRequest servletRequest = (HttpServletRequest) msgContext
522 .getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
523 HttpSession session = servletRequest.getSession(false);
524
525 if (session == null) {
526 throw new WSRPException(ErrorCodes.INVALID_COOKIE);
527 }
528
529 }
530
531
543 private MarkupType checkMarkupParams(PortletDescription portletDescription,
544 MarkupParams markupParams) throws WSRPException {
545
546 String MN = "checkMarkupParams";
547 if (logger.isLogging(Logger.TRACE_HIGH)) {
548 logger.entry(Logger.TRACE_HIGH, MN);
549 }
550
551 MarkupType match = new MarkupType();
552
553 String[] reqMimeTypes = markupParams.getMimeTypes();
554 String reqMode = markupParams.getMode();
555 String reqWindowState = markupParams.getWindowState();
556 String[] reqLocales = markupParams.getLocales();
557 boolean foundMime, foundWindow, foundMode;
558 foundMime = foundWindow = foundMode = false;
559
560 MarkupType[] markupTypes = portletDescription.getMarkupTypes();
561 for (int i = 0; i < markupTypes.length; i++) {
562
563 String mimeType = markupTypes[i].getMimeType();
565 for (int j = 0; j < reqMimeTypes.length; j++) {
566
567 if (mimeType.equalsIgnoreCase(reqMimeTypes[j])) {
570 foundMime = true;
571 match.setMimeType(mimeType);
572
573 String[] modes = markupTypes[i].getModes();
575 for (int k = 0; k < modes.length; k++) {
576
577 if (modes[k].equalsIgnoreCase(reqMode)) {
578 foundMode = true;
579 match.setModes(new String[] { reqMode });
580
581 String[] windowStates = markupTypes[i]
583 .getWindowStates();
584 for (int l = 0; l < windowStates.length; l++) {
585
586 if (windowStates[l]
587 .equalsIgnoreCase(reqWindowState)) {
588 foundWindow = true;
589 match
590 .setWindowStates(new String[] { reqWindowState });
591
592 String[] locales = markupTypes[i]
594 .getLocales();
595 if (locales == null) {
596 if (logger.isLogging(Logger.TRACE_HIGH)) {
597 logger.exit(Logger.TRACE_HIGH, MN);
598 }
599 return match;
600 }
601
602 for (int m = 0; m < locales.length; m++) {
603 for (int n = 0; n < reqLocales.length; n++) {
604 if (locales[m]
605 .equalsIgnoreCase(reqLocales[n])) {
606 match
607 .setLocales(new String[] { locales[m] });
608
609 if (logger
610 .isLogging(Logger.TRACE_HIGH)) {
611 logger.exit(
612 Logger.TRACE_HIGH,
613 MN);
614 }
615 return match;
616 }
617 else {
618 if (LocaleHelper
620 .getLanguageCode(
621 locales[m])
622 .equalsIgnoreCase(
623 LocaleHelper
624 .getLanguageCode(reqLocales[n]))) {
625 match
626 .setLocales(new String[] { LocaleHelper
627 .getLanguageCode(locales[m]) });
628
629 if (logger
630 .isLogging(Logger.TRACE_HIGH)) {
631 logger
632 .exit(
633 Logger.TRACE_HIGH,
634 MN);
635 }
636
637 return match;
638 }
639
640 }
641 }
642 }
643 }
644 }
645 }
646 }
647 }
648 }
649 }
650
651 if (logger.isLogging(Logger.TRACE_HIGH)) {
652 logger.exit(Logger.TRACE_HIGH, MN);
653 }
654
655 if (!foundMime)
656 throw new WSRPException(ErrorCodes.UNSUPPORTED_MIME_TYPE);
657 if (!foundMode)
658 throw new WSRPException(ErrorCodes.UNSUPPORTED_MODE);
659 if (!foundWindow)
660 throw new WSRPException(ErrorCodes.UNSUPPORTED_WINDOW_STATE);
661
662 throw new WSRPException(ErrorCodes.UNSUPPORTED_LOCALE);
663 }
664
665
668
669
686 public MarkupResponse getMarkup(GetMarkup request)
687 throws java.rmi.RemoteException {
688
689 String MN = "getMarkup";
690 if (logger.isLogging(Logger.TRACE_HIGH)) {
691 logger.entry(Logger.TRACE_HIGH, MN);
692 }
693
694 MarkupResponse markupResponse = null;
695
696 try {
697
698 paramCheck.check(request);
700
701 this.checkCookie();
702
703 RegistrationContext regContext = request.getRegistrationContext();
704
705 PortletDescription portletDescription = null;
706
707 portletDescription = provider.getDescriptionHandler()
708 .getPortletDescription(
709 request.getPortletContext().getPortletHandle(),
710 regContext, null,
711 request.getMarkupParams().getLocales());
712
713 MarkupType markupType = this.checkMarkupParams(portletDescription,
716 request.getMarkupParams());
717
718 request.getMarkupParams().setLocales(markupType.getLocales());
720 request.getMarkupParams().setMimeTypes(
721 new String[] { markupType.getMimeType() });
722 request.getMarkupParams().setMode(markupType.getModes()[0]);
723 request.getMarkupParams().setWindowState(
724 markupType.getWindowStates()[0]);
725 request.getMarkupParams().setWindowState(
726 markupType.getWindowStates()[0]);
727
728 Boolean templateProcessing = portletDescription
730 .getDoesUrlTemplateProcessing();
731 if (templateProcessing == null) {
732 templateProcessing = Boolean.FALSE;
734 }
735
736 if (templateProcessing.booleanValue()) {
737 try {
739 paramCheck
740 .check(request.getRuntimeContext().getTemplates());
741 }
742 catch (MissingParametersFault e) {
743 templateProcessing = Boolean.FALSE;
744 }
745 }
746
747 markupResponse = provider.getPortletInvoker().invokeGetMarkup(
749 request);
750
751 if (!templateProcessing.booleanValue()) {
754 markupResponse.getMarkupContext().setRequiresUrlRewriting(
755 Boolean.TRUE);
756 }
757 else {
758 markupResponse.getMarkupContext().setRequiresUrlRewriting(
759 Boolean.FALSE);
760 }
761
762 }
763 catch (WSRPException e) {
764 WSRPXHelper.handleWSRPException(e);
765 }
766
767 if (logger.isLogging(Logger.TRACE_HIGH)) {
768 logger.exit(Logger.TRACE_HIGH, MN);
769 }
770
771 return markupResponse;
772 }
773
774
788 public BlockingInteractionResponse performBlockingInteraction(
789 PerformBlockingInteraction request)
790 throws java.rmi.RemoteException {
791 String MN = "performBlockingInteraction";
792 if (logger.isLogging(Logger.TRACE_HIGH)) {
793 logger.entry(Logger.TRACE_HIGH, MN);
794 }
795
796 BlockingInteractionResponse interactionResponse = null;
797
798 try {
799
800 paramCheck.check(request);
802
803 checkCookie();
804
805 PortletContext newPortletContext = null;
808 newPortletContext = handlePortletStateChange(request);
809
810 PortletDescription portletDescription = null;
813
814 portletDescription = provider.getDescriptionHandler()
815 .getPortletDescription(
816 request.getPortletContext().getPortletHandle(),
817 request.getRegistrationContext(), null,
818 request.getMarkupParams().getLocales());
819
820 MarkupType markupType = this.checkMarkupParams(portletDescription,
821 request.getMarkupParams());
822
823 request.getMarkupParams().setLocales(markupType.getLocales());
825 request.getMarkupParams().setMimeTypes(
826 new String[] { markupType.getMimeType() });
827 request.getMarkupParams().setMode(markupType.getModes()[0]);
828 request.getMarkupParams().setWindowState(
829 markupType.getWindowStates()[0]);
830
831 interactionResponse = provider.getPortletInvoker()
833 .invokePerformBlockingInteraction(request);
834 if (newPortletContext != null) {
835 interactionResponse.getUpdateResponse().setPortletContext(
836 newPortletContext);
837 }
838 }
839 catch (WSRPException e) {
840 WSRPXHelper.handleWSRPException(e);
841 }
842
843 if (logger.isLogging(Logger.TRACE_HIGH)) {
844 logger.exit(Logger.TRACE_HIGH, MN);
845 }
846
847 return interactionResponse;
848 }
849
850
856 private PortletContext handlePortletStateChange(
857 PerformBlockingInteraction request) throws RemoteException,
858 WSRPException {
859
860 final String MN = "handlePortletStateChange";
861
862 PortletContext portletContext = null;
863 Portlet portlet = null;
864 try {
865 portlet = provider.getPortletPool().get(
866 request.getPortletContext().getPortletHandle());
867 }
868 catch (WSRPException e) {
869 if (e.getErrorCode() == ErrorCodes.GET_PORTLET_FAILED) {
870 WSRPXHelper.throwX(logger, Logger.ERROR, MN,
872 ErrorCodes.INVALID_HANDLE);
873 }
874 else {
875 WSRPXHelper.throwX(e.getErrorCode());
876 }
877 }
878
879 StateChange stateChange = null;
882 stateChange = request.getInteractionParams().getPortletStateChange();
883 if (portlet instanceof ProducerOfferedPortlet) {
884 if (stateChange.toString().equals(StateChange._readOnly)) {
885 WSRPXHelper.throwX(ErrorCodes.PORTLET_STATE_CHANGE_REQUIRED);
888 }
889 else if (stateChange.toString().equals(
890 StateChange._cloneBeforeWrite)) {
891 portletContext = handleCloneBeforeWrite(request);
893 }
894 else {
895 WSRPXHelper.throwX(ErrorCodes.OPERATION_FAILED);
897 }
898 }
899 else if (portlet instanceof ConsumerConfiguredPortlet) {
900 if (stateChange.toString().equals(StateChange._readOnly)) {
901 WSRPXHelper.throwX(ErrorCodes.PORTLET_STATE_CHANGE_REQUIRED);
904 }
905 else if (stateChange.toString().equals(
906 StateChange._cloneBeforeWrite)) {
907 portletContext = handleCloneBeforeWrite(request);
909 }
910 else {
911 }
913 }
914 else {
915 WSRPXHelper.throwX(logger, Logger.ERROR, MN,
917 ErrorCodes.OPERATION_FAILED);
918 }
919
920 return portletContext;
921 }
922
923
927 private PortletContext handleCloneBeforeWrite(
928 PerformBlockingInteraction request) throws WSRPException,
929 java.rmi.RemoteException {
930
931 PortletContext portletContext = null;
933 ClonePortlet cloneRequest = new ClonePortlet();
934 cloneRequest.setPortletContext(request.getPortletContext());
935 cloneRequest.setRegistrationContext(request.getRegistrationContext());
936 cloneRequest.setUserContext(request.getUserContext());
937
938 portletContext = clonePortlet(cloneRequest);
939
940 request.setPortletContext(portletContext);
943
944
946 return portletContext;
947 }
948
949
964 public ReturnAny initCookie(InitCookie request)
965 throws java.rmi.RemoteException {
966
967 String MN = "initCookie";
968 if (logger.isLogging(Logger.TRACE_HIGH)) {
969 logger.entry(Logger.TRACE_HIGH, MN);
970 }
971 try {
972
973 paramCheck.check(request);
975
976 if (registrationRequired) {
979 checkRegistration(request.getRegistrationContext());
980 }
981
982 createSession();
984
985 }
986 catch (WSRPException e) {
987
988 WSRPXHelper.handleWSRPException(e);
989 }
990
991 if (logger.isLogging(Logger.TRACE_HIGH)) {
992 logger.exit(Logger.TRACE_HIGH, MN);
993 }
994
995 return new ReturnAny();
996 }
997
998
1009 public ReturnAny releaseSessions(ReleaseSessions request)
1010 throws java.rmi.RemoteException {
1011
1012 String MN = "releaseSession";
1013 if (logger.isLogging(Logger.TRACE_HIGH)) {
1014 logger.entry(Logger.TRACE_HIGH, MN);
1015 }
1016
1017
1020 if (logger.isLogging(Logger.TRACE_HIGH)) {
1021 logger.exit(Logger.TRACE_HIGH, MN);
1022 }
1023 return new ReturnAny();
1024 }
1025
1026
1029
1030
1043 public PortletDescriptionResponse getPortletDescription(
1044 GetPortletDescription request) throws java.rmi.RemoteException {
1045
1046 String MN = "getPortletDescription";
1047 if (logger.isLogging(Logger.TRACE_HIGH)) {
1048 logger.entry(Logger.TRACE_HIGH, MN);
1049 }
1050
1051 PortletDescription portletDescription = null;
1052 PortletDescriptionResponse response = null;
1053
1054 try {
1055
1056 paramCheck.check(request);
1058
1059 RegistrationContext regContext = request.getRegistrationContext();
1060
1061 portletDescription = provider.getDescriptionHandler()
1062 .getPortletDescription(
1063 request.getPortletContext().getPortletHandle(),
1064 regContext, null, request.getDesiredLocales());
1065
1066 response = new PortletDescriptionResponse();
1067 response.setPortletDescription(portletDescription);
1068 response.setResourceList(null);
1069 response.setExtensions(null);
1070
1071 }
1072 catch (WSRPException e) {
1073
1074 WSRPXHelper.handleWSRPException(e);
1075
1076 }
1077
1078 if (logger.isLogging(Logger.TRACE_HIGH)) {
1079 logger.exit(Logger.TRACE_HIGH, MN);
1080 }
1081
1082 return response;
1083 }
1084
1085
1096 public PortletContext clonePortlet(ClonePortlet request)
1097 throws java.rmi.RemoteException {
1098
1099 String MN = "clonePortlet";
1100 if (logger.isLogging(Logger.TRACE_HIGH)) {
1101 logger.entry(Logger.TRACE_HIGH, MN);
1102 }
1103
1104 PortletContext portletContext = null;
1105
1106 try {
1107 paramCheck.check(request);
1109
1110 PortletStateManager portletStateManager = null;
1111
1112 portletStateManager = provider.getPortletStateManager();
1113
1114 String orgPortletHandle = request.getPortletContext()
1115 .getPortletHandle();
1116
1117 Portlet portletClone = null;
1118
1119 portletClone = provider.getPortletPool().clone(orgPortletHandle);
1121
1122 if (portletClone != null) {
1123
1124 String newPortletHandle = portletClone.getPortletHandle();
1125
1126 portletContext = new PortletContext();
1128 portletContext.setPortletHandle(newPortletHandle);
1129 portletContext.setPortletState(portletStateManager.getAsString(
1130 newPortletHandle).getBytes());
1131 portletContext.setExtensions(null);
1132
1133 RegistrationContext regContext = request
1135 .getRegistrationContext();
1136 if (regContext != null) {
1137 String regHandle = regContext.getRegistrationHandle();
1138 if (regHandle != null
1139 && consumerRegistry.check(regHandle) == true) {
1140 provider.getPortletRegistrationFilterWriter()
1141 .makeAvailable(regHandle, newPortletHandle);
1142 }
1143 }
1144
1145 }
1146 else {
1147 throw new WSRPException(ErrorCodes.OPERATION_FAILED);
1148 }
1149
1150 }
1151 catch (WSRPException e) {
1152 WSRPXHelper.handleWSRPException(e);
1153 }
1154
1155 if (logger.isLogging(Logger.TRACE_HIGH)) {
1156 logger.exit(Logger.TRACE_HIGH, MN);
1157 }
1158
1159 return portletContext;
1160 }
1161
1162
1175 public DestroyPortletsResponse destroyPortlets(DestroyPortlets request)
1176 throws java.rmi.RemoteException {
1177
1178 String MN = "destroyPortlets";
1179 if (logger.isLogging(Logger.TRACE_HIGH)) {
1180 logger.entry(Logger.TRACE_HIGH, MN);
1181 }
1182
1183 paramCheck.check(request);
1185
1186 try {
1187
1188 checkRegistration(request.getRegistrationContext());
1189
1190 RegistrationContext regContext = request.getRegistrationContext();
1192 if (regContext != null) {
1193 String regHandle = regContext.getRegistrationHandle();
1194 if (regHandle != null
1195 && consumerRegistry.check(regHandle) == true) {
1196 provider.getPortletRegistrationFilterWriter().remove(
1197 regHandle,
1198 Arrays.asList(request.getPortletHandles())
1199 .iterator());
1200 }
1201 }
1202
1203 }
1204 catch (WSRPException e) {
1205
1206 WSRPXHelper.handleWSRPException(e);
1207 }
1208
1209 Iterator handles = Arrays.asList(request.getPortletHandles())
1210 .iterator();
1211
1212 Iterator result = provider.getPortletPool().destroySeveral(handles);
1215
1216 ArrayList failedHandles = new ArrayList();
1217
1218 while (result.hasNext()) {
1219
1220 DestroyFailed failed = new DestroyFailed();
1221 failed.setPortletHandle(result.next().toString());
1222 failed
1223 .setReason("Portlet handle refers to a producer offered portlet!");
1224 failedHandles.add(failed);
1225
1226 }
1227
1228 DestroyFailed[] destroyFailedArray = new DestroyFailed[failedHandles
1229 .size()];
1230 failedHandles.toArray(destroyFailedArray);
1231
1232 DestroyPortletsResponse response = new DestroyPortletsResponse();
1233 response.setDestroyFailed(destroyFailedArray);
1234 response.setExtensions(null);
1235
1236 if (logger.isLogging(Logger.TRACE_HIGH)) {
1237 logger.exit(Logger.TRACE_HIGH, MN);
1238 }
1239
1240 return response;
1241 }
1242
1243
1255 public PortletContext setPortletProperties(SetPortletProperties request)
1256 throws java.rmi.RemoteException {
1257
1258 String MN = "setPortletProperties";
1259 if (logger.isLogging(Logger.TRACE_HIGH)) {
1260 logger.entry(Logger.TRACE_HIGH, MN);
1261 }
1262
1263 PortletContext portletContext = null;
1264
1265 try {
1266
1267 paramCheck.check(request);
1269
1270 String portletHandle = request.getPortletContext()
1271 .getPortletHandle();
1272 Portlet portlet = getPortlet(request.getRegistrationContext(),
1273 portletHandle);
1274
1275 if (portlet instanceof ConsumerConfiguredPortlet) {
1277
1278 provider.getPortletStateManager().setAsPropertyList(
1279 portletHandle, request.getPropertyList());
1280 portletContext = request.getPortletContext();
1281
1282 }
1283 else {
1284 throw new WSRPException(ErrorCodes.INCONSISTENT_PARAMETERS);
1285 }
1286
1287 }
1288 catch (WSRPException e) {
1289
1290 WSRPXHelper.handleWSRPException(e);
1291
1292 }
1293
1294 if (logger.isLogging(Logger.TRACE_HIGH)) {
1295 logger.exit(Logger.TRACE_HIGH, MN);
1296 }
1297
1298 return portletContext;
1299
1300 }
1301
1302
1315 public PropertyList getPortletProperties(GetPortletProperties request)
1316 throws java.rmi.RemoteException {
1317
1318 String MN = "getPortletProperties";
1319 if (logger.isLogging(Logger.TRACE_HIGH)) {
1320 logger.entry(Logger.TRACE_HIGH, MN);
1321 }
1322
1323 PropertyList propertyList = null;
1324
1325 try {
1326 paramCheck.check(request);
1328
1329 String portletHandle = request.getPortletContext()
1330 .getPortletHandle();
1331 getPortlet(request.getRegistrationContext(), portletHandle);
1332
1333 PortletStateManager portletStateManager = provider
1334 .getPortletStateManager();
1335 propertyList = portletStateManager.getAsPropertyList(portletHandle);
1336
1337 }
1338 catch (WSRPException e) {
1339
1340 WSRPXHelper.handleWSRPException(e);
1341
1342 }
1343
1344 if (logger.isLogging(Logger.TRACE_HIGH)) {
1345 logger.exit(Logger.TRACE_HIGH, MN);
1346 }
1347
1348 return propertyList;
1349 }
1350
1351
1365 public PortletPropertyDescriptionResponse getPortletPropertyDescription(
1366 GetPortletPropertyDescription request)
1367 throws java.rmi.RemoteException {
1368
1369 String MN = "getPortletPropertyDescription";
1370 if (logger.isLogging(Logger.TRACE_HIGH)) {
1371 logger.entry(Logger.TRACE_HIGH, MN);
1372 }
1373
1374 PortletPropertyDescriptionResponse response = null;
1375
1376 try {
1377
1378 paramCheck.check(request);
1380
1381 String portletHandle = request.getPortletContext()
1382 .getPortletHandle();
1383 getPortlet(request.getRegistrationContext(), portletHandle);
1384
1385 response = new PortletPropertyDescriptionResponse();
1386 response.setModelDescription(provider.getPortletStateManager()
1387 .getModelDescription(portletHandle,
1388 request.getDesiredLocales(), false));
1389 response.setResourceList(null);
1390 response.setExtensions(null);
1391
1392 }
1393 catch (WSRPException e) {
1394
1395 WSRPXHelper.handleWSRPException(e);
1396
1397 }
1398
1399 if (logger.isLogging(Logger.TRACE_HIGH)) {
1400 logger.exit(Logger.TRACE_HIGH, MN);
1401 }
1402
1403 return response;
1404 }
1405
1406}