@Test void loadWithInvalidCharName() throws UnsupportedEncodingException { Document doc = DocumentTools.INSTANCE.getDocumentBuilder().newDocument(); Bundle bundle = new Bundle(); final String encodedRoot = URLEncoder.encode(Folder.ROOT_FOLDER_NAME, "UTF-8"); final String encodedTestFolder = URLEncoder.encode(TEST_FOLDER_1 + "/1", "UTF-8"); loader.load(bundle, createFolderXml(doc, Folder.ROOT_FOLDER_NAME, Folder.ROOT_FOLDER_ID, null)); loader.load(bundle, createFolderXml(doc, TEST_FOLDER_1 + "/1", TEST_FOLDER_1, Folder.ROOT_FOLDER_ID)); assertNotNull(bundle.getFolders().get(encodedRoot)); assertEquals(encodedRoot, bundle.getFolders().get(encodedRoot).getName()); assertNotNull(bundle.getFolders().get(encodedTestFolder)); assertEquals(encodedTestFolder, bundle.getFolders().get(encodedTestFolder).getName()); }
@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();  }