use of com.enonic.xp.branch.Branch in project xp by enonic.
the class RenameContentCommandTest method test_already_exists.
@Test
void test_already_exists() {
Node mockNode = Node.create().id(NodeId.from("testId")).build();
final RepositoryId repositoryId = RepositoryId.from("some.repo");
final Branch branch = Branch.from("somebranch");
when(nodeService.rename(isA(RenameNodeParams.class))).thenThrow(new NodeAlreadyExistAtPathException(NodePath.create("/content/mycontent2").build(), repositoryId, branch));
when(nodeService.getById(mockNode.id())).thenReturn(mockNode);
final Content content = createContent(true);
final RenameContentCommand command = createCommand(RenameContentParams.create().contentId(content.getId()).newName(ContentName.from("mycontent2")).build());
final ContentAlreadyExistsException exception = assertThrows(ContentAlreadyExistsException.class, command::execute);
assertEquals(branch, exception.getBranch());
assertEquals(repositoryId, exception.getRepositoryId());
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class RepoDumper method getActiveVersion.
private NodeVersionMetadata getActiveVersion(final NodeId nodeId) {
final Branch branch = ContextAccessor.current().getBranch();
final GetActiveNodeVersionsParams params = GetActiveNodeVersionsParams.create().nodeId(nodeId).branches(Branches.from(branch)).build();
return this.nodeService.getActiveVersions(params).getNodeVersions().get(branch);
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class RepoLoader method doExecute.
private void doExecute(final RepoLoadResult.Builder result) {
final Branch currentBranch = ContextAccessor.current().getBranch();
verifyOrCreateBranch(currentBranch);
final BranchLoadResult branchLoadResult = this.reader.loadBranch(repositoryId, currentBranch, this.branchEntryProcessor);
result.add(branchLoadResult);
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class AbstractMetaDumpUpgrader method doUpgrade.
@Override
public void doUpgrade(final String dumpName) {
super.doUpgrade(dumpName);
final String timeMillis = Long.toString(System.currentTimeMillis());
FilePaths tmpFilePaths = new DefaultFilePaths() {
@Override
public PathRef branchMetaPath(final RepositoryId repositoryId, final Branch branch) {
return branchRootPath(repositoryId).resolve(branch.toString()).resolve("meta-" + timeMillis + ".tar.gz");
}
@Override
public PathRef versionMetaPath(final RepositoryId repositoryId) {
return branchRootPath(repositoryId).resolve("versions-" + timeMillis + ".tar.gz");
}
};
tmpDumpReader = FileDumpReader.create(null, basePath, dumpName, tmpFilePaths);
tmpDumpWriter = FileDumpWriter.create(basePath, dumpName, null, tmpFilePaths);
try {
dumpReader.getRepositories().forEach(this::upgradeRepository);
overwriteSourceFiles();
} catch (Exception e) {
try {
deleteBufferFiles();
} catch (Exception e2) {
LOG.error("Error while deleting buffer files", e);
}
throw new DumpUpgradeException("Error while upgrading dump [" + dumpName + "]", e);
} finally {
try {
tmpDumpReader.close();
tmpDumpWriter.close();
} catch (IOException e) {
LOG.error("Error while closing dump writer", e);
}
}
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class ReindexExecutor method execute.
public ReindexResult execute() {
final ReindexResult.Builder builder = ReindexResult.create();
final long start = System.currentTimeMillis();
builder.startTime(Instant.ofEpochMilli(start));
builder.branches(this.branches);
builder.repositoryId(this.repositoryId);
if (listener != null) {
listener.totalBranches(this.branches.getSize());
}
for (final Branch branch : this.branches) {
doReindexBranchNew(repositoryId, builder, branch);
}
final long stop = System.currentTimeMillis();
builder.endTime(Instant.ofEpochMilli(stop));
builder.duration(Duration.ofMillis(stop - start));
return builder.build();
}
Aggregations