protected DocumentRoute instantiateAndRun(
     CoreSession session, List<String> docIds, Map<String, Serializable> map) {
   DocumentRoutingService routing = Framework.getLocalService(DocumentRoutingService.class);
   DocumentRoute route = validate(routeDoc, session);
   // create instance and start
   String id =
       Framework.getLocalService(DocumentRoutingService.class)
           .createNewInstance(route.getDocument().getName(), docIds, map, session, true);
   return session.getDocument(new IdRef(id)).getAdapter(DocumentRoute.class);
 }
 protected DocumentRoute validate(DocumentModel routeDoc, CoreSession session)
     throws DocumentRouteNotLockedException {
   DocumentRoute route = routeDoc.getAdapter(DocumentRoute.class);
   // draft -> validated
   if (!route.isValidated()) {
     route =
         Framework.getLocalService(DocumentRoutingService.class)
             .validateRouteModel(route, session);
   }
   return route;
 }
 protected DocumentRoute instantiateAndRun(CoreSession session, Map<String, Serializable> map) {
   DocumentRoutingService routing = Framework.getLocalService(DocumentRoutingService.class);
   // route model
   DocumentRoute route = routeDoc.getAdapter(DocumentRoute.class);
   // draft -> validated
   if (!route.isValidated()) {
     route = routing.validateRouteModel(route, session);
   }
   session.save();
   // create instance and start
   String id =
       routing.createNewInstance(
           route.getDocument().getName(),
           Collections.singletonList(doc.getId()),
           map,
           session,
           true);
   return session.getDocument(new IdRef(id)).getAdapter(DocumentRoute.class);
 }