/** @see IOManager#addIOHandler(IOHandler) */ @Override public void addIOHandler(IOHandler ioHandler) { if (ioHandler == null) { throw new IllegalArgumentException("'null' is not a valid IOHandler."); } ioHandler.setIOManager(this); ioHandlers.add(ioHandler); }
/** @see IOManager#importContent(ImportContext, DavResource) */ @Override public boolean importContent(ImportContext context, DavResource resource) throws IOException { boolean success = false; if (context != null && resource != null) { IOListener ioListener = context.getIOListener(); if (ioListener == null) { ioListener = new DefaultIOListener(log); } IOHandler[] ioHandlers = getIOHandlers(); for (int i = 0; i < ioHandlers.length && !success; i++) { IOHandler ioh = ioHandlers[i]; if (ioh.canImport(context, resource)) { ioListener.onBegin(ioh, context); success = ioh.importContent(context, resource); ioListener.onEnd(ioh, context, success); } } context.informCompleted(success); } return success; }
/** @see IOManager#exportContent(ExportContext, boolean) */ @Override public boolean exportContent(ExportContext context, boolean isCollection) throws IOException { log.debug("exportContent({}, {})", context, isCollection); boolean success = false; if (context != null) { IOListener ioListener = context.getIOListener(); if (ioListener == null) { ioListener = new DefaultIOListener(log); } IOHandler[] ioHandlers = getIOHandlers(); for (int i = 0; i < ioHandlers.length && !success; i++) { IOHandler ioh = ioHandlers[i]; if (ioh.canExport(context, isCollection)) { ioListener.onBegin(ioh, context); success = ioh.exportContent(context, isCollection); ioListener.onEnd(ioh, context, success); } } context.informCompleted(success); } log.debug("exportContent: {}", success); return success; }