Been down this road and have worked on many iterations of the same fundamental problem. Moving it to the main details page will not be your user's final ask. Start from the EPMDocument itself to get the assumed default representation:
VisualizationHelper vizHelper = new VisualizationHelper();
Representation rep = vizHelper.getRepresentation(doc);
I have send this to a method that returns a bit more but is looking for file extension ".stp":
//processRep takes a representation and finds the STP or PDF's download link
//@param fileExt the type of file extension to look for
//@param rep the representation to look through
//@param ch the content holder where the file is located
//@returns a content message either download url, or telling user file not found.
private static ContentMessage processRep(String fileExt, Representation rep, ContentHolder ch) throws WTException, PropertyVetoException {
LOGGER.debug("Looking in representation: " + rep.getName() + ", id: " + IdentityFactory.getDisplayIdentifier(rep));
//Get the content within the representation
ContentHolder repContent = (ContentHolder)ContentHelper.service.getContents(rep);
Vector<?> appDatas = ContentHelper.getContentListAll(repContent);
for(int i = 0; i < appDatas.size(); i++) {
ApplicationData appData = (ApplicationData)appDatas.get(i);
LOGGER.debug("File found with name: " + appData.getFileName() + ", and role: " + appData.getRole());
//If the content is an additional file and matches the file extensions get the download url and return it.
if((appData.getRole().equals(ContentRoleType.ADDITIONAL_FILES) || appData.getRole().equals(ContentRoleType.SECONDARY)) && appData.getFileName().contains(fileExt)) {
LOGGER.debug("File found meets all conditions! Will download url and return it.");
ApplicationData ad = (ApplicationData)ContentHelper.getPrimary((FormatContentHolder)ch);
ContentMessage returned = new ContentMessage(ContentHelper.getDownloadURL(repContent, appData, false).toString(), null, true);
if(returned.getValid()) {
LOGGER.debug("file found is good");
}
else {
LOGGER.debug("File found is bad");
}
return returned;
}
}
//If fails to find a file return an error message to the user
LOGGER.debug("failed to find a file inside given representation");
return new ContentMessage(null, "Error: could not find " + fileExt + " file.<br>", false);
}
In the bean class I return is the download URL to the step file. That is what you need to render on your details page.