@Test void copy() throws Exception { DocumentReference sourceReference = new DocumentReference("wiki", "Space", "Page", Locale.FRENCH); DocumentReference copyReference = new DocumentReference("wiki", "Space", "Copy"); when(this.xcontext.getWiki().copyDocument(sourceReference, copyReference, "fr", false, true, true, this.xcontext)).thenReturn(true); assertTrue(this.modelBridge.copy(sourceReference, copyReference)); assertLog(Level.INFO, "Document [{}] has been copied to [{}].", sourceReference, copyReference); }
@Override public boolean copy(DocumentReference source, DocumentReference destination) { XWikiContext xcontext = this.xcontextProvider.get(); try { String language = source.getLocale() != null ? source.getLocale().toString() : null; boolean result = xcontext.getWiki().copyDocument(source, destination, language, false, true, true, xcontext); if (result) { this.logger.info("Document [{}] has been copied to [{}].", source, destination); } else { this.logger.warn( "Cannot fully copy [{}] to [{}] because an orphan translation" + " exists at the destination.", source, destination); } return result; } catch (Exception e) { this.logger.error("Failed to copy [{}] to [{}].", source, destination, e); return false; } }
DefaultModelBridge implements ModelBridge { @Override public boolean copy(DocumentReference source, DocumentReference destination) { XWikiContext xcontext = this.xcontextProvider.get(); try { String language = source.getLocale() != null ? source.getLocale().toString() : null; boolean result = xcontext.getWiki().copyDocument(source, destination, language, false, true, true, xcontext); if (result) { this.logger.info("Document [{}] has been copied to [{}].", source, destination); } else { this.logger.warn( "Cannot fully copy [{}] to [{}] because an orphan translation" + " exists at the destination.", source, destination); } return result; } catch (Exception e) { this.logger.error("Failed to copy [{}] to [{}].", source, destination, e); return false; } } }
DefaultModelBridge implements ModelBridge { @Override public boolean copy(DocumentReference source, DocumentReference destination) { XWikiContext xcontext = this.xcontextProvider.get(); try { String language = source.getLocale() != null ? source.getLocale().toString() : null; boolean result = xcontext.getWiki().copyDocument(source, destination, language, false, true, true, xcontext); if (result) { this.logger.info("Document [{}] has been copied to [{}].", source, destination); } else { this.logger.warn( "Cannot fully copy [{}] to [{}] because an orphan translation" + " exists at the destination.", source, destination); } return result; } catch (Exception e) { this.logger.error("Failed to copy [{}] to [{}].", source, destination, e); return false; } }  }
DefaultModelBridge implements ModelBridge { @Override public boolean copy(DocumentReference source, DocumentReference destination) { XWikiContext xcontext = this.xcontextProvider.get(); try { String language = source.getLocale() != null ? source.getLocale().toString() : null; boolean result = xcontext.getWiki().copyDocument(source, destination, language, false, true, true, xcontext); if (result) { this.logger.info("Document [{}] has been copied to [{}].", source, destination); } else { this.logger.warn( "Cannot fully copy [{}] to [{}] because an orphan translation" + " exists at the destination.", source, destination); } return result; } catch (Exception e) { this.logger.error("Failed to copy [{}] to [{}].", source, destination, e); return false; } }  @Override boolean create(DocumentReference documentReference); @Override boolean copy(DocumentReference source, DocumentReference destination); @Override boolean delete(DocumentReference reference); @Override boolean delete(DocumentReference reference, boolean skipRecycleBin); @Override boolean removeLock(DocumentReference reference); @Override void createRedirect(DocumentReference oldReference, DocumentReference newReference); @Override boolean canOverwriteSilently(DocumentReference documentReference); @Override boolean exists(DocumentReference reference); @Override List<DocumentReference> getBackLinkedReferences(DocumentReference documentReference, String wikiId); @Override List<DocumentReference> getDocumentReferences(SpaceReference spaceReference); @Override boolean updateParentField(final DocumentReference oldParentReference,
        final DocumentReference newParentReference); @Override DocumentReference setContextUserReference(DocumentReference userReference); @Override void update(DocumentReference documentReference, Map<String, String> parameters); @Override boolean restoreDeletedDocument(long deletedDocumentId, AbstractCheckRightsRequest request); @Override List<Long> getDeletedDocumentIds(String batchId); @Override boolean permanentlyDeleteDocument(long deletedDocumentId, AbstractCheckRightsRequest request); @Override boolean permanentlyDeleteAllDocuments(PermanentlyDeleteJob deleteJob, AbstractCheckRightsRequest request); @Override boolean rename(DocumentReference source, DocumentReference destination); }
DefaultModelBridge implements ModelBridge { @Override public boolean copy(DocumentReference source, DocumentReference destination) { XWikiContext xcontext = this.xcontextProvider.get(); try { String language = source.getLocale() != null ? source.getLocale().toString() : null; boolean result = xcontext.getWiki().copyDocument(source, destination, language, false, true, true, xcontext); if (result) { this.logger.info("Document [{}] has been copied to [{}].", source, destination); } else { this.logger.warn( "Cannot fully copy [{}] to [{}] because an orphan translation" + " exists at the destination.", source, destination); } return result; } catch (Exception e) { this.logger.error("Failed to copy [{}] to [{}].", source, destination, e); return false; } }  @Override boolean create(DocumentReference documentReference); @Override boolean copy(DocumentReference source, DocumentReference destination); @Override boolean delete(DocumentReference reference); @Override boolean delete(DocumentReference reference, boolean skipRecycleBin); @Override boolean removeLock(DocumentReference reference); @Override void createRedirect(DocumentReference oldReference, DocumentReference newReference); @Override boolean canOverwriteSilently(DocumentReference documentReference); @Override boolean exists(DocumentReference reference); @Override List<DocumentReference> getBackLinkedReferences(DocumentReference documentReference, String wikiId); @Override List<DocumentReference> getDocumentReferences(SpaceReference spaceReference); @Override boolean updateParentField(final DocumentReference oldParentReference,
        final DocumentReference newParentReference); @Override DocumentReference setContextUserReference(DocumentReference userReference); @Override void update(DocumentReference documentReference, Map<String, String> parameters); @Override boolean restoreDeletedDocument(long deletedDocumentId, AbstractCheckRightsRequest request); @Override List<Long> getDeletedDocumentIds(String batchId); @Override boolean permanentlyDeleteDocument(long deletedDocumentId, AbstractCheckRightsRequest request); @Override boolean permanentlyDeleteAllDocuments(PermanentlyDeleteJob deleteJob, AbstractCheckRightsRequest request); @Override boolean rename(DocumentReference source, DocumentReference destination);  }