Search in sources :

Example 21 with MoveRequest

use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.

the class RefactoringScriptServiceTest method copyAs.

@Test
public void copyAs() throws Exception {
    SpaceReference spaceReference = new SpaceReference("Alice", new SpaceReference("Users", new WikiReference("dev")));
    getService().copyAs(spaceReference, "Bob");
    ArgumentCaptor<MoveRequest> request = ArgumentCaptor.forClass(MoveRequest.class);
    // The RENAME job can perform a COPY too.
    verify(this.jobExecutor).execute(eq(RefactoringJobs.RENAME), request.capture());
    assertEquals(RefactoringJobs.COPY_AS, request.getValue().getJobType());
    assertEquals(Arrays.asList(spaceReference), request.getValue().getEntityReferences());
    assertEquals(new SpaceReference("Bob", spaceReference.getParent()), request.getValue().getDestination());
    assertFalse(request.getValue().isDeleteSource());
}
Also used : MoveRequest(org.xwiki.refactoring.job.MoveRequest) SpaceReference(org.xwiki.model.reference.SpaceReference) WikiReference(org.xwiki.model.reference.WikiReference) Test(org.junit.Test)

Example 22 with MoveRequest

use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.

the class AbstractMoveJobTest method createRequest.

protected MoveRequest createRequest(EntityReference source, EntityReference destination) {
    MoveRequest request = new MoveRequest();
    request.setEntityReferences(Arrays.asList(source));
    request.setDestination(destination);
    return request;
}
Also used : MoveRequest(org.xwiki.refactoring.job.MoveRequest)

Example 23 with MoveRequest

use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.

the class RefactoringScriptService method createMoveRequest.

private MoveRequest createMoveRequest(String type, Collection<EntityReference> sources, EntityReference destination) {
    MoveRequest request = new MoveRequest();
    initEntityRequest(request, type, sources);
    request.setDestination(destination);
    request.setUpdateLinks(true);
    request.setAutoRedirect(true);
    request.setUpdateParentField(true);
    return request;
}
Also used : MoveRequest(org.xwiki.refactoring.job.MoveRequest)

Example 24 with MoveRequest

use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.

the class RefactoringScriptService method createCopyRequest.

/**
 * Creates a request to copy the specified source entities to the specified destination entity.
 *
 * @param sources specifies the entities to be copied
 * @param destination specifies the place where to copy the entities (becomes the parent of the copies)
 * @return the copy request
 */
public MoveRequest createCopyRequest(Collection<EntityReference> sources, EntityReference destination) {
    MoveRequest request = createMoveRequest(RefactoringJobs.COPY, sources, destination);
    request.setDeleteSource(false);
    request.setUpdateParentField(false);
    return request;
}
Also used : MoveRequest(org.xwiki.refactoring.job.MoveRequest)

Example 25 with MoveRequest

use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.

the class RefactoringScriptService method createCopyAsRequest.

/**
 * Creates a request to copy the specified entity with a different reference.
 *
 * @param sourceReference the entity to copy
 * @param copyReference the reference to use for the copy
 * @return the copy-as request
 */
public MoveRequest createCopyAsRequest(EntityReference sourceReference, EntityReference copyReference) {
    MoveRequest request = createMoveRequest(RefactoringJobs.COPY_AS, Arrays.asList(sourceReference), copyReference);
    request.setDeleteSource(false);
    request.setUpdateParentField(false);
    return request;
}
Also used : MoveRequest(org.xwiki.refactoring.job.MoveRequest)

Aggregations

MoveRequest (org.xwiki.refactoring.job.MoveRequest)25 Test (org.junit.Test)21 DocumentReference (org.xwiki.model.reference.DocumentReference)16 SpaceReference (org.xwiki.model.reference.SpaceReference)6 WikiReference (org.xwiki.model.reference.WikiReference)6 LinkRefactoring (org.xwiki.refactoring.internal.LinkRefactoring)3 GroupedJob (org.xwiki.job.GroupedJob)1 Job (org.xwiki.job.Job)1 JobException (org.xwiki.job.JobException)1 ContextualAuthorizationManager (org.xwiki.security.authorization.ContextualAuthorizationManager)1 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)1