Source:
<code>public static boolean publishHTMLPage(IHTMLPage htmlPage, List relatedNotPublished, User user, boolean respectFrontendRoles ) throws WebAssetException, DotSecurityException, DotDataException { Logger.debug(PublishFactory.class, "*****I'm an HTML Page -- Publishing"); ContentletAPI contentletAPI = APILocator.getContentletAPI(); for ( Object asset : relatedNotPublished ) { if ( asset instanceof Contentlet ) { Logger.debug( PublishFactory.class, "*****I'm an HTML Page -- Publishing my Contentlet Child=" + ((Contentlet) asset).getInode() ); try { Contentlet contentlet = (Contentlet) asset; WorkflowStep step = null; <START> List<WorkflowStep> steps = APILocator.getWorkflowAPI().findStepsByContentlet(contentlet); <END> if( null != steps && !steps.isEmpty() && steps.size() == 1) { step = steps.get(0); } if (null != step && !APILocator.getWorkflowAPI().findScheme(step.getSchemeId()).isMandatory() ) { contentletAPI.publish( (Contentlet) asset, user, false ); ContentletServices.invalidateLive(contentlet); } } catch ( DotSecurityException e ) { Logger.debug( PublishFactory.class, "publish html page: User has no permission to publish the content inode = " + ((Contentlet) asset).getInode() + " in the page, skipping it." ); } } else if ( asset instanceof Template ) { Logger.debug( PublishFactory.class, "*****I'm an HTML Page -- Publishing Template =" + ((Template) asset).getInode() ); publishAsset( (Template) asset, user, respectFrontendRoles, false ); } } PageServices.invalidateAll(htmlPage); if ( htmlPage instanceof HTMLPageAsset ) { APILocator.getContentletAPI().publish( (HTMLPageAsset) htmlPage, user, false ); } return true; }</code><technical_language>this encapsulated a method called findFirstStepByContentlet, returns WorkflowStep null if</technical_language>

Target:
public static boolean publishHTMLPage(IHTMLPage htmlPage, List relatedNotPublished, User user, boolean respectFrontendRoles ) throws WebAssetException, DotSecurityException, DotDataException { Logger.debug(PublishFactory.class, "*****I'm an HTML Page -- Publishing"); ContentletAPI contentletAPI = APILocator.getContentletAPI(); for ( Object asset : relatedNotPublished ) { if ( asset instanceof Contentlet ) { Logger.debug( PublishFactory.class, "*****I'm an HTML Page -- Publishing my Contentlet Child=" + ((Contentlet) asset).getInode() ); try { Contentlet contentlet = (Contentlet) asset; WorkflowStep step = APILocator.getWorkflowAPI().findStepByContentlet(contentlet); if (null != step && !APILocator.getWorkflowAPI().findScheme(step.getSchemeId()).isMandatory() ) { contentletAPI.publish( (Contentlet) asset, user, false ); ContentletServices.invalidateLive(contentlet); } } catch ( DotSecurityException e ) { Logger.debug( PublishFactory.class, "publish html page: User has no permission to publish the content inode = " + ((Contentlet) asset).getInode() + " in the page, skipping it." ); } } else if ( asset instanceof Template ) { Logger.debug( PublishFactory.class, "*****I'm an HTML Page -- Publishing Template =" + ((Template) asset).getInode() ); publishAsset( (Template) asset, user, respectFrontendRoles, false ); } } PageServices.invalidateAll(htmlPage); if ( htmlPage instanceof HTMLPageAsset ) { APILocator.getContentletAPI().publish( (HTMLPageAsset) htmlPage, user, false ); } return true; }