@Test void loadWithoutParent() { Document doc = DocumentTools.INSTANCE.getDocumentBuilder().newDocument(); Bundle bundle = new Bundle(); assertThrows(BundleLoadException.class, () -> loader.load(bundle, createFolderXml(doc, TEST_FOLDER_1, TEST_FOLDER_1, Folder.ROOT_FOLDER_ID))); }
@Override public void load(Bundle bundle, Element element) { final Element folderElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), FOLDER); String name = getSingleChildElementTextContent(folderElement, NAME); final String id = folderElement.getAttribute(ATTRIBUTE_ID); final String parentFolderID = folderElement.getAttribute(ATTRIBUTE_FOLDER_ID); final Folder parentFolder; if (ROOT_FOLDER_ID.equals(id)) { parentFolder = null; } else { parentFolder = ServiceAndPolicyLoaderUtil.getFolder(bundle, parentFolderID); } name = CharacterBlacklistUtil.encodeName(name); Folder folder = new Folder(); folder.setId(id); folder.setName(name); folder.setParentFolder(parentFolder); folder.setPath(getPath(folder).toString()); bundle.getFolders().put(folder.getPath(), folder); }
FolderLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element folderElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), FOLDER); String name = getSingleChildElementTextContent(folderElement, NAME); final String id = folderElement.getAttribute(ATTRIBUTE_ID); final String parentFolderID = folderElement.getAttribute(ATTRIBUTE_FOLDER_ID); final Folder parentFolder; if (ROOT_FOLDER_ID.equals(id)) { parentFolder = null; } else { parentFolder = ServiceAndPolicyLoaderUtil.getFolder(bundle, parentFolderID); } name = CharacterBlacklistUtil.encodeName(name); Folder folder = new Folder(); folder.setId(id); folder.setName(name); folder.setParentFolder(parentFolder); folder.setPath(getPath(folder).toString()); bundle.getFolders().put(folder.getPath(), folder); } }
FolderLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element folderElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), FOLDER); String name = getSingleChildElementTextContent(folderElement, NAME); final String id = folderElement.getAttribute(ATTRIBUTE_ID); final String parentFolderID = folderElement.getAttribute(ATTRIBUTE_FOLDER_ID); final Folder parentFolder; if (ROOT_FOLDER_ID.equals(id)) { parentFolder = null; } else { parentFolder = ServiceAndPolicyLoaderUtil.getFolder(bundle, parentFolderID); } name = CharacterBlacklistUtil.encodeName(name); Folder folder = new Folder(); folder.setId(id); folder.setName(name); folder.setParentFolder(parentFolder); folder.setPath(getPath(folder).toString()); bundle.getFolders().put(folder.getPath(), folder); }  }
FolderLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element folderElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), FOLDER); String name = getSingleChildElementTextContent(folderElement, NAME); final String id = folderElement.getAttribute(ATTRIBUTE_ID); final String parentFolderID = folderElement.getAttribute(ATTRIBUTE_FOLDER_ID); final Folder parentFolder; if (ROOT_FOLDER_ID.equals(id)) { parentFolder = null; } else { parentFolder = ServiceAndPolicyLoaderUtil.getFolder(bundle, parentFolderID); } name = CharacterBlacklistUtil.encodeName(name); Folder folder = new Folder(); folder.setId(id); folder.setName(name); folder.setParentFolder(parentFolder); folder.setPath(getPath(folder).toString()); bundle.getFolders().put(folder.getPath(), folder); }  @Override void load(Bundle bundle, Element element); @Override String getEntityType(); }
FolderLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element folderElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), FOLDER); String name = getSingleChildElementTextContent(folderElement, NAME); final String id = folderElement.getAttribute(ATTRIBUTE_ID); final String parentFolderID = folderElement.getAttribute(ATTRIBUTE_FOLDER_ID); final Folder parentFolder; if (ROOT_FOLDER_ID.equals(id)) { parentFolder = null; } else { parentFolder = ServiceAndPolicyLoaderUtil.getFolder(bundle, parentFolderID); } name = CharacterBlacklistUtil.encodeName(name); Folder folder = new Folder(); folder.setId(id); folder.setName(name); folder.setParentFolder(parentFolder); folder.setPath(getPath(folder).toString()); bundle.getFolders().put(folder.getPath(), folder); }  @Override void load(Bundle bundle, Element element); @Override String getEntityType();  }