if (insertPage.equals("lastPage")) {
metadataBean.createPagination();
} else {
Prefs prefs = metadataBean.getMyProzess().getRegelsatz().getPreferences();
DigitalDocument doc = metadataBean.getDocument();
DocStruct physical = doc.getPhysicalDocStruct();
List<DocStruct> pageList = physical.getAllChildren();
int indexToImport = Integer.parseInt(insertPage);
DocStructType newPageType = prefs.getDocStrctTypeByName("page");
DocStruct newPage = doc.createDocStruct(newPageType);
MetadataType physicalPageNoType = prefs.getMetadataTypeByName("physPageNumber");
MetadataType logicalPageNoType = prefs.getMetadataTypeByName("logicalPageNumber");
for (int index = 0; index < pageList.size(); index++) {
if (index == indexToImport) {
DocStruct oldPage = pageList.get(index);