code: public static void registerMixinType(Session session, String mixin) throws RepositoryException {
          NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
          if (!nodeTypeManager.hasNodeType(mixin)) {
              NodeTypeTemplate nodeTypeTemplate = nodeTypeManager.createNodeTypeTemplate();
              nodeTypeTemplate.setMixin(true);
              nodeTypeTemplate.setName(mixin);
  
              NodeTypeDefinition[] nodeTypes = new NodeTypeDefinition[]{nodeTypeTemplate};
              nodeTypeManager.registerNodeTypes(nodeTypes, true);
          }
      }
docs: Register new mixin type if does not exists on workspace
  
  @param session the JCR session
  @param mixin the mixin name to register
  @throws RepositoryException