use of com.xpn.xwiki.store.migration.DataMigrationException in project xwiki-platform by xwiki.
the class RecordableEventMigrator method hibernateMigrate.
@Override
protected void hibernateMigrate() throws DataMigrationException, XWikiException {
String hql = "select event from ActivityEventImpl event where event.page LIKE concat(event.wiki, ':%')";
try {
List<ActivityEventImpl> events;
do {
Query query = queryManager.createQuery(hql, Query.HQL);
query.setLimit(50);
events = query.execute();
for (ActivityEventImpl event : events) {
fixEvent(event);
}
} while (!events.isEmpty());
} catch (QueryException e) {
throw new DataMigrationException("Failed to fix RecordableEvent problems.", e);
}
}
use of com.xpn.xwiki.store.migration.DataMigrationException in project xwiki-platform by xwiki.
the class R40001XWIKI7540DataMigration method checkAnnotationsAndComments.
/**
* Check if the migration can be executed by verifying if the current annotation class is the default one and that
* the comments class does not have any custom mappings set up.
* <p>
* Note: We can not do this in {@link #shouldExecute(XWikiDBVersion)} because we need to read the database and we
* can not do that until the previous migrations are executed.
*
* @return true if the migration can be executed, false otherwise.
* @throws DataMigrationException if the annotation or comments class can not be properly retrieved
*/
protected boolean checkAnnotationsAndComments() throws DataMigrationException {
XWikiContext context = getXWikiContext();
String resultOfSkippingDatabase = "Comments and anotations will remain separated";
try {
EntityReference currentAnnotationClassReference = configuration.getAnnotationClassReference();
currentAnnotationClassReference = currentAnnotationClassReference.removeParent(new WikiReference(context.getWikiId()));
if (!XWIKI_ANNOTATION_CLASS_REFERENCE.equals(currentAnnotationClassReference)) {
logger.warn("Skipping database [{}] because it uses a custom annotation class. " + resultOfSkippingDatabase, context.getWikiId());
return false;
}
BaseClass commentsClass = context.getWiki().getCommentsClass(context);
if (commentsClass.hasCustomMapping()) {
logger.warn("Skipping database [{}] because it uses a custom mapping for comments. " + resultOfSkippingDatabase, context.getWikiId());
return false;
}
} catch (Exception e) {
// Should not happen
String message = "Failed to check the current annotation and comments classes for customizations. " + "Migration will not execute";
logger.error(message, e);
throw new DataMigrationException(message, e);
}
return true;
}
use of com.xpn.xwiki.store.migration.DataMigrationException in project xwiki-platform by xwiki.
the class HibernateDataMigrationManager method updateSchema.
@Override
protected void updateSchema(Collection<XWikiMigration> migrations) throws DataMigrationException {
try {
liquibaseUpdate(migrations, true);
hibernateShemaUpdate();
liquibaseUpdate(migrations, false);
} catch (Exception e) {
throw new DataMigrationException(String.format("Unable to update schema of wiki [%s]", getXWikiContext().getWikiId()), e);
}
}
Aggregations