|
|
@@ -2283,18 +2283,15 @@ class PageService {
|
|
|
const normalizedPage = this.normalizeParentByPage(page, user);
|
|
|
|
|
|
if (normalizedPage == null) {
|
|
|
- // ------------------ send socket error with path ------------------
|
|
|
socket.emit(SocketEventName.PageMigrationError, { page.path });
|
|
|
logger.error(`Failed to update descendantCount of page of id: "${pageId}"`);
|
|
|
}
|
|
|
}
|
|
|
catch (err) {
|
|
|
- // ------------------ send socket error with path ------------------
|
|
|
socket.emit(SocketEventName.PageMigrationError, { page.path });
|
|
|
logger.error('Something went wrong while normalizing parent.', err);
|
|
|
}
|
|
|
}
|
|
|
- // ------------------ send socket success ------------------
|
|
|
socket.emit(SocketEventName.PageMigrationSuccess);
|
|
|
}
|
|
|
|
|
|
@@ -2362,13 +2359,11 @@ class PageService {
|
|
|
|
|
|
if (pages == null || pages.length === 0) {
|
|
|
logger.error('pageIds is null or 0 length.');
|
|
|
- // ------------------ send socket error ------------------
|
|
|
socket.emit(SocketEventName.PageMigrationError);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (pages.length > LIMIT_FOR_MULTIPLE_PAGE_OP) {
|
|
|
- // ------------------ send socket error ------------------
|
|
|
socket.emit(SocketEventName.PageMigrationError);
|
|
|
throw Error(`The maximum number of pageIds allowed is ${LIMIT_FOR_MULTIPLE_PAGE_OP}.`);
|
|
|
}
|
|
|
@@ -2381,22 +2376,16 @@ class PageService {
|
|
|
[normalizablePages, nonNormalizablePages] = await this.crowi.pageGrantService.separateNormalizableAndNotNormalizablePages(user, pagesToNormalize);
|
|
|
}
|
|
|
catch (err) {
|
|
|
- // ------------------ send socket error ------------------
|
|
|
socket.emit(SocketEventName.PageMigrationError);
|
|
|
throw err;
|
|
|
}
|
|
|
|
|
|
if (normalizablePages.length === 0) {
|
|
|
- // socket.emit('normalizeParentRecursivelyByPages', { error: err.message }); TODO: use socket to tell user
|
|
|
- // ------------------ send socket error ------------------
|
|
|
socket.emit(SocketEventName.PageMigrationError);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (nonNormalizablePages.length !== 0) {
|
|
|
- // TODO: iterate nonNormalizablePages and send socket error to client so that the user can know which path failed to migrate
|
|
|
- // socket.emit('normalizeParentRecursivelyByPages', { error: err.message }); TODO: use socket to tell user
|
|
|
- // ------------------ send socket error with path ------------------
|
|
|
for (const page of nonNormalizablePages) {
|
|
|
socket.emit(SocketEventName.PageMigrationError, { page.path });
|
|
|
}
|
|
|
@@ -2408,7 +2397,6 @@ class PageService {
|
|
|
for await (const page of normalizablePages) {
|
|
|
const canOperate = await this.crowi.pageOperationService.canOperate(true, page.path, page.path);
|
|
|
if (!canOperate) {
|
|
|
- // ------------------ send socket error with path ------------------
|
|
|
socket.emit(SocketEventName.PageMigrationError, { page.path });
|
|
|
throw Error(`Cannot operate normalizeParentRecursiively to path "${page.path}" right now.`);
|
|
|
}
|
|
|
@@ -2421,7 +2409,6 @@ class PageService {
|
|
|
const existingPage = await builder.query.exec();
|
|
|
|
|
|
if (existingPage?.parent != null) {
|
|
|
- // ------------------ send socket error with path ------------------
|
|
|
socket.emit(SocketEventName.PageMigrationError, { page.path });
|
|
|
throw Error('This page has already converted.');
|
|
|
}
|
|
|
@@ -2438,7 +2425,6 @@ class PageService {
|
|
|
});
|
|
|
}
|
|
|
catch (err) {
|
|
|
- // ------------------ send socket error with path ------------------
|
|
|
socket.emit(SocketEventName.PageMigrationError, { page.path });
|
|
|
logger.error('Failed to create PageOperation document.', err);
|
|
|
throw err;
|
|
|
@@ -2448,13 +2434,11 @@ class PageService {
|
|
|
await this.normalizeParentRecursivelyMainOperation(page, user, pageOp._id);
|
|
|
}
|
|
|
catch (err) {
|
|
|
- // ------------------ send socket error with path ------------------
|
|
|
socket.emit(SocketEventName.PageMigrationError, { page.path });
|
|
|
logger.err('Failed to run normalizeParentRecursivelyMainOperation.', err);
|
|
|
throw err;
|
|
|
}
|
|
|
}
|
|
|
- // ------------------ send socket success ------------------
|
|
|
socket.emit(SocketEventName.PageMigrationSuccess);
|
|
|
}
|
|
|
|