Example #1
0
		public EnforceResponse Enforce(Request request, Response response)
		{
			Logger.LogDebug("CONTENT ENFORCER: Enforce()");
			if (null == request)
				throw new System.ArgumentNullException("request");
			if (null == response)
				throw new System.ArgumentNullException("response");

			bool isAppCacheNeeded = ResponseNeedsApplicationCache(response);

			List<IDisposable> disposeList = new List<IDisposable>();
			try
			{
				IContainer virtualRoot;
				IPolicyResponseObject pro = ResponseAdaptor.GetPRO(response, request, out virtualRoot);
				disposeList.Add(pro as IDisposable);
				disposeList.Add(virtualRoot);

				ActionExecuter executer = new ActionExecuter(m_operationCallback);

				if (isAppCacheNeeded)
				{
					CacheOfficeApps(response);
				}

				IUniversalRequestObject uro = executer.ExecuteActions(pro, ref virtualRoot);
				disposeList.Add(uro as IDisposable);

				EnforceResponse enforcedResponse = new EnforceResponse();

				enforcedResponse.Properties = new CustomProperty[0];

				enforcedResponse.ModifiedRequest = RequestAdaptor.GetRequest(uro);

				return enforcedResponse;
			}
			///TODO: resolve the fault v error code debate later. essentially need a test system to simulate
			/// the different scenarios. Note that the exception handling is part of the service agreement
			/// as opposed to the general Exception catch case below.
			catch (PolicyActionException actionException)
			{
				return HandleException(actionException, request, actionException.ExceptionHandling);
			}
			catch (Exception ex)
			{
				Logger.LogError("Content Enforcer General Failure");
				Logger.LogError(ex);
				return HandleException(ex, request, ActionExceptionHandling.Prompt);
			}
			finally
			{
				//For now, just shut down cached applications at the end of a call.
				if (isAppCacheNeeded)
				{
					Logger.LogDebug("CONTENT ENFORCER: Closing MS Office Apps");
					OfficeApplicationCache.Instance.ShutDown();
				}

				Logger.LogDebug("CONTENT ENFORCER: Disposing URO's");
				foreach (IDisposable disp in disposeList)
				{
					if (disp != null)
					{
						disp.Dispose();
					}
				}
                disposeList.Clear();
			}
		}
Example #2
0
		public IUniversalRequestObject ExecuteActions(IPolicyResponseObject upi)
		{
			ActionExecuter executer = new ActionExecuter(m_progressCallback);
			return executer.ExecuteActions(upi, ref m_container);
		}