public AppKfsDeleteItem(IAppHelper _helper, List<KfsServerOp> _operations)
            : base(_helper, _operations)
        {
            Debug.Assert(m_ops.Count > 0);

            FirstOp = m_ops[0] as KfsDeleteServerOp;

            Debug.Assert(FirstOp != null);
        }
Example #2
0
        /// <summary>
        /// Fill the array specified with the operations contained in the phase 1
        /// event message specified.
        /// </summary>
        public void DecomposePhase1Event(AnpMsg m, out List<KfsServerOp> opList)
        {
            opList = new List<KfsServerOp>();
            UInt64 eid = m.ID;
            UInt64 date = m.Elements[1].UInt64;
            UInt32 uid = m.Elements[2].UInt32;
            UInt64 cid = m.Elements[4].UInt64;
            UInt32 nbChange = m.Elements[5].UInt32;
            int pos = 6;

            for (int i = 0; i < nbChange; i++)
            {
                UInt32 type = m.Elements[pos + 1].UInt32;
                KfsServerOp o;

                if (type == KAnpType.KANP_KFS_OP_CREATE_FILE || type == KAnpType.KANP_KFS_OP_CREATE_DIR)
                    o = new KfsCreateServerOp(Share, eid, date, uid, cid,
                                              type == KAnpType.KANP_KFS_OP_CREATE_FILE,
                                              m.Elements[pos + 2].UInt64,
                                              m.Elements[pos + 3].UInt64,
                                              m.Elements[pos + 4].String);

                else if (type == KAnpType.KANP_KFS_OP_UPDATE_FILE)
                    o = new KfsUpdateServerOp(Share, eid, date, uid, cid, m.Elements[pos + 2].UInt64);

                else if (type == KAnpType.KANP_KFS_OP_DELETE_FILE || type == KAnpType.KANP_KFS_OP_DELETE_DIR)
                    o = new KfsDeleteServerOp(Share, eid, date, uid, cid,
                                              type == KAnpType.KANP_KFS_OP_DELETE_FILE,
                                              m.Elements[pos + 2].UInt64);

                else if (type == KAnpType.KANP_KFS_OP_MOVE_FILE || type == KAnpType.KANP_KFS_OP_MOVE_DIR)
                    o = new KfsMoveServerOp(Share, eid, date, uid, cid,
                                            type == KAnpType.KANP_KFS_OP_MOVE_FILE,
                                            m.Elements[pos + 2].UInt64,
                                            m.Elements[pos + 3].UInt64,
                                            m.Elements[pos + 4].String);

                else throw new Exception("invalid server phase 1 operation type");

                opList.Add(o);

                int nbElem = (int)m.Elements[pos].UInt32;
                if (nbElem < 3) throw new Exception("invalid number of elements in server phase 1 operation");
                pos += nbElem;
            }
        }