BBCodeServiceImpl implements Startable, BBCodeService, ManagementAware { public void delete(String bbcodeId) throws Exception { SessionProvider sProvider = SessionProvider.createSystemProvider(); Node bbCodeHome = getBBcodeHome(sProvider); try { bbCodeHome.getNode(bbcodeId).remove(); bbCodeHome.save(); synchronized (activeBBCodesCache) { activeBBCodesCache.clear(); } } catch (Exception e) { log.error("Error removing BBCode" + bbcodeId, e); } finally { sProvider.close(); } } BBCodeServiceImpl();  BBCodeServiceImpl(KSDataLocation dataLocator); void registerBBCodePlugin(BBCodePlugin plugin); void initDefaultBBCodes(); void save(List<BBCode> bbcodes); List<BBCode> getAll(); List<String> getActive(); BBCode findById(String id); void delete(String bbcodeId); void start(); void stop(); void setContext(ManagementContext context); KSDataLocation getDataLocator(); void setDataLocator(KSDataLocation dataLocator); List<BBCodePlugin> getPlugins(); void setPlugins(List<BBCodePlugin> plugins); final static String BBCODE_NODE_TYPE; final static String BBCODE_HOME_NODE_TYPE; }
@Test public void testDelete() throws Exception { List<BBCode> bbcodes = Arrays.asList(createBBCode("foo", "replacement", "description", "example", false, false)); bbcodeService.save(bbcodes); String targetPath = bbcodesPath + "/" + "foo"; assertNodeExists(targetPath); bbcodeService.delete("foo"); assertNodeNotExists(targetPath); }