The problem of the complete transfer of quantum states and entanglement in a four-qubit system composed of two single-mode cavities and two two-level atoms is investigated. The transfer of single and double excitation states is discussed for two different coupling configurations between the qubits. In the first, the coupling is mediated by the atoms that simultaneously couple to the cavity modes. In the second configuration, each atom resides inside one of the cavities and the coupling between the cavities is mediated by the overlapping field modes. A proper choice of basis states makes it possible to identify states that could be completely transferred between themselves. Simple expressions are derived for the conditions for the complete transfer of quantum states and entanglement. These conditions impose severe constraints on the evolution of the system in the form of constants of motion. The constrains on the evolution of the system imply that not all states can evolve in time, and we find that the evolution of the entire system can be confined into that occurring among two states only. Detailed analysis show that in the case where the interaction is mediated by the atoms, only symmetric superposition states can be completely and reversibly transferred between the atoms and the cavity modes. In the case where the interaction is mediated by the overlapping field modes, both symmetric and antisymmetric superposition states can be completely transferred. We also show that the system is capable of generating purely photonic NOON states, but only if the coupling is mediated by the atoms, and demonstrate that the ability to generate the NOON states relies on perfect transfer of an entanglement from the atoms to the cavity modes.