Example #1
0
            public void CreateAndInitializeNewProjection(
                ProjectionManager projectionManager,
                Guid projectionCorrelationId,
                Guid workerId,
                bool isSlave                  = false,
                Guid slaveMasterWorkerId      = default(Guid),
                Guid slaveMasterCorrelationId = default(Guid),
                int?version = -1)
            {
                var projection = projectionManager.CreateManagedProjectionInstance(
                    _name,
                    _projectionId,
                    projectionCorrelationId,
                    workerId,
                    isSlave,
                    slaveMasterWorkerId,
                    slaveMasterCorrelationId);

                projection.InitializeNew(
                    new ManagedProjection.PersistedState
                {
                    Enabled             = _enabled,
                    HandlerType         = _handlerType,
                    Query               = _query,
                    Mode                = _projectionMode,
                    EmitEnabled         = _emitEnabled,
                    CheckpointsDisabled = !_checkpointsEnabled,
                    Epoch               = -1,
                    Version             = version,
                    RunAs               = _enableRunAs ? SerializedRunAs.SerializePrincipal(_runAs) : null
                },
                    _replyEnvelope);
            }
Example #2
0
        private void LoadPersistedState(PersistedState persistedState)
        {
            var handlerType = persistedState.HandlerType;
            var query       = persistedState.Query;

            if (handlerType == null)
            {
                throw new ArgumentNullException("persistedState", "HandlerType");
            }
            if (query == null)
            {
                throw new ArgumentNullException("persistedState", "Query");
            }
            if (handlerType == "")
            {
                throw new ArgumentException("HandlerType", "persistedState");
            }

            if (_state != ManagedProjectionState.Creating && _state != ManagedProjectionState.Loading)
            {
                throw new InvalidOperationException("LoadPersistedState is now allowed in this state");
            }

            _persistedState = persistedState;
            _runAs          = SerializedRunAs.DeserializePrincipal(persistedState.RunAs);
        }
Example #3
0
 private void FixUpOldProjectionRunAs(PersistedState persistedState)
 {
     if (persistedState.RunAs == null || string.IsNullOrEmpty(persistedState.RunAs.Name))
     {
         _runAs = SystemAccount.Principal;
         persistedState.RunAs = SerializedRunAs.SerializePrincipal(ProjectionManagementMessage.RunAs.System);
     }
 }
Example #4
0
 private void DoSetRunAs1(ProjectionManagementMessage.Command.SetRunAs message)
 {
     _persistedState.RunAs = message.Action == ProjectionManagementMessage.Command.SetRunAs.SetRemove.Set
         ? SerializedRunAs.SerializePrincipal(message.RunAs)
         : null;
     _runAs = SerializedRunAs.DeserializePrincipal(_persistedState.RunAs);
     _pendingPersistedState = true;
 }
 public Definition(
     string name, string handlerType, string query, SlaveProjectionRequestedNumber requestedNumber,
     ProjectionMode mode, bool emitEnabled, bool checkpointsEnabled, bool enableRunAs,
     SerializedRunAs runAs1)
 {
     Name = name;
     HandlerType = handlerType;
     Query = query;
     RequestedNumber = requestedNumber;
     RunAs1 = runAs1;
     EnableRunAs = enableRunAs;
     CheckpointsEnabled = checkpointsEnabled;
     EmitEnabled = emitEnabled;
     Mode = mode;
 }
Example #6
0
 public static IPrincipal DeserializePrincipal(SerializedRunAs runAs)
 {
     if (runAs == null)
     {
         return(null);
     }
     if (runAs.Name == null)
     {
         return(null);
     }
     if (runAs.Name == "$system") //TODO: make sure nobody else uses it
     {
         return(SystemAccount.Principal);
     }
     return(new OpenGenericPrincipal(new GenericIdentity(runAs.Name), runAs.Roles));
 }
 private IPrincipal DeserializePrincipal(SerializedRunAs runAs)
 {
     if (runAs == null)
         return null;
     if (runAs.Name == null)
         return null;
     if (runAs.Name == "$system") //TODO: make sure nobody else uses it
         return SystemAccount.Principal;
     return new OpenGenericPrincipal(new GenericIdentity(runAs.Name), runAs.Roles);
 }