code: public static void registerAndAddMixinType(Session session, Node node, String mixin) throws RepositoryException {
          registerMixinType(session, mixin);
          if (!Arrays.asList(node.getMixinNodeTypes()).contains(mixin)) {
              node.addMixin(mixin);
          }
      }
docs: Register new mixin type if does not exists on workspace the add it to the given node
  
  @param session the JCR session
  @param node the node where to add the mixin
  @param mixin the mixin name to add
  @throws RepositoryException