private void doubleCheckAddLock(String resource, String transaction,
            LockType type) {

        /*
         * this if should always be false. resources is a replicated data to
         * ensure that lock are given to correct resources
         */
        if (!resource.equals(this.resource)) {
            System.err.println("error: Attempting to add lock of [" + resource
                    + "] to a LockEntity of [" + this.resource + "]");
            return;
        }

        /*
         * if the current type is null, which means there is no lock now. safe
         * just check if the current transactions is empty
         */
        if (this.type == null && this.transactions.size() == 0) {
            this.type = type;
            this.transactions.add(transaction);
            return;
        }

        /*
         * If current type is read, and the coming type is read, then OK
         */
        if (this.type == LockType.READ && type == LockType.READ) {
            this.transactions.add(transaction);
            return;
        }

        /*
         * If the current type or coming type contains Write, the coming
         * transaction must be the same as the ONLY transaction in the Set
         * 
         * This is a replicated conflict check.
         */
        if (this.type == LockType.WRITE || type == LockType.WRITE) {
            if (this.transactions.size() == 1
                    && this.transactions.contains(transaction)) {
                this.type = LockType.WRITE;
                return;
            }
        }

        /*
         * All other cases, there is error. Gives out error message.
         */

        System.err.println("error: site.LockEntity.addLock()\n LockEntity: "
                + this.toString() + "\nRequest:\n" + "Resource: " + resource
                + "Transaction ID: " + transaction + "type: " + type);

    }