Skip to content

Commit

Permalink
Merge branch 'xwiki:master' into XWIKI-21772
Browse files Browse the repository at this point in the history
  • Loading branch information
Sereza7 authored Jan 16, 2024
2 parents 7c122dc + 60d51ab commit 12a2abb
Show file tree
Hide file tree
Showing 23 changed files with 467 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,4 @@ XWiki.Registration_liveValidation_defaultFieldOkMessage.hint=실시간 유효성
## Used to indicate where deprecated keys end
#@deprecatedend
</content>
</xwikidoc>
</xwikidoc>
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ administration.templateProvider.creationRestrictions.none=이 템플릿은 어
administration.templateProvider.creationRestrictionsAreSuggestions=제안사항에 따른 생성 제한
administration.templateProvider.creationRestrictionsAreSuggestions.hint=목록에서 템플릿을 선택할 때 미리 입력된 기본 위치로 첫 번째 생성 제한을 사용하여 사용자가 이 템플릿으로 페이지를 생성할 위치를 선택할 수 있습니다.
</content>
</xwikidoc>
</xwikidoc>
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,12 @@ already take care of padding and shadow. */
}

#docextrapanes {
border-top: 1px solid @xwiki-border-color;
border: 1px solid @xwiki-border-color;
border-top-left-radius: @border-radius-base;
border-top-right-radius: @border-radius-base;
margin-top: -1px;
border-left: 1px solid @xwiki-border-color;
border-right: 1px solid @xwiki-border-color;
/* Makes the bottom border hidden below the footer on pages with a long content (longer than the viewport height). */
margin-bottom: -1px;
}

#xdocFooter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-livedata-api</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-livedata-livetable</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<!-- Test dependencies. -->
<dependency>
<groupId>javax.servlet</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,39 @@
#livetable_filterObfuscated($map)
$jsontool.serialize($map)
#else
<h1>$escapetool.xml($services.localization.render('like.likers.title', [$doc.plainTitle]))</h1>
#set($columns = ["name", "first_name", "last_name"])
#set($columnsProperties = {
"name" : { "type" : "text", "sortable": false, "filterable": false, "html": true },
"first_name" : { "type" : "text", "sortable": false, "filterable": false},
"last_name" : { "type" : "text", "sortable": false, "filterable": false}
})
#set ($queryParams = {
"livetable": "true",
"xpage": "likers",
"outputSyntax": "plain"
})
## We rely on the same column name than the Users administration, so we use same translation prefix for now.
#set($options = {
'url': $doc.getURL('get', $escapetool.url($queryParams)),
'outputOnlyHtml': true,
'translationPrefix' : "xe.admin.users."
})

#livetable("likers" $columns $columnsProperties $options)
<h1>$escapetool.xml($services.localization.render('like.likers.title', [$doc.plainTitle]))</h1>
## We rely on the same column name than the Users administration, so we use same translation prefix for now.
#set ($sourceParameters = {
'template': 'likers.vm',
'livetable': 'true',
'outputSyntax': 'plain',
'$doc': $doc.documentReference,
'translationPrefix' : 'xe.admin.users.'
})
$services.liveData.render({
'id': 'likersTable',
'properties': 'name,first_name,last_name',
'source': 'liveTable',
'sourceParameters': $escapetool.url($sourceParameters)
}, {
'meta': {
'propertyDescriptors': [
{
'id': 'name',
'displayer': 'html',
'sortable': false,
'filterable': false
},
{
'id': 'first_name',
'sortable': false,
'filterable': false
},{
'id': 'last_name',
'sortable': false,
'filterable': false
}
]
}
})
#end
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.xwiki.like.test.po.LikeButton;
import org.xwiki.like.test.po.LikersPage;
import org.xwiki.like.test.po.UserProfileLikedPagesPage;
import org.xwiki.livedata.test.po.LiveDataElement;
import org.xwiki.livedata.test.po.TableLayoutElement;
import org.xwiki.model.reference.DocumentReference;
import org.xwiki.test.docker.junit5.TestReference;
Expand Down Expand Up @@ -138,7 +140,7 @@ void likeUnlikeDefaultConfiguration(TestUtils testUtils, TestReference testRefer
tableLayout.assertRow(LIKES_COLUMN_NAME, "2");
tableLayout.assertRow(LIKES_COLUMN_NAME, "1");

// Go to the profile of user 1 and verify that the like pages are displayed and valid.
// Go to the profile of user 1 and verify that the liked pages are displayed and valid.
UserProfileLikedPagesPage user1ProfileLikedPagesPage = new UserProfileLikedPagesPage(USER1);
user1ProfileLikedPagesPage.gotoPage();
tableLayout = user1ProfileLikedPagesPage.getLiveData().getTableLayout();
Expand All @@ -147,6 +149,14 @@ void likeUnlikeDefaultConfiguration(TestUtils testUtils, TestReference testRefer
testUtils.getURL(testReference.getLastSpaceReference()));
tableLayout.assertRow(LIKES_COLUMN_NAME, "2");

// Go to the likers of the page and verify the Live Data is accurate.
LikersPage likersPage = LikersPage.goToLikers(testReference);
LiveDataElement likersLiveData = likersPage.getLiveData();
TableLayoutElement likersTableLayout = likersLiveData.getTableLayout();
assertEquals(2, likersTableLayout.countRows());
likersTableLayout.assertRow("User", "LikeUser1");
likersTableLayout.assertRow("User", "LikeUser2");

testUtils.login(USER1, USER1);
testUtils.gotoPage(testReference);
likeButton = new LikeButton();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.like.test.po;

import java.util.Map;

import org.xwiki.livedata.test.po.LiveDataElement;
import org.xwiki.model.reference.DocumentReference;
import org.xwiki.test.ui.po.ViewPage;

/**
* Likers page object.
*
* @version $Id$
* @since 16.0.0RC1
*/
public class LikersPage extends ViewPage
{
/**
* Go to the likers page of a given page.
*
* @param documentReference the document reference of the page for which likers are shown
* @return the likers page object for the given document reference
*/
public static LikersPage goToLikers(DocumentReference documentReference)
{
getUtil().gotoPage(documentReference, "view", Map.of("viewer", "likers"));
return new LikersPage();
}

/**
* @return the likers Live Data element
*/
public LiveDataElement getLiveData()
{
return new LiveDataElement("likersTable");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class LiveDataMacroParameters extends LiveDataRendererParameters
/**
* {@inheritDoc}
*/
@Override
@PropertyDescription("The live data instance id.")
public void setId(String id)
{
Expand All @@ -43,6 +44,7 @@ public void setId(String id)
/**
* {@inheritDoc}
*/
@Override
@PropertyDescription("The comma-separated list of properties to fetch and display.")
public void setProperties(String properties)
{
Expand All @@ -52,6 +54,7 @@ public void setProperties(String properties)
/**
* {@inheritDoc}
*/
@Override
@PropertyDescription("The live data source to use, specified as a component hint.")
public void setSource(String source)
{
Expand All @@ -61,6 +64,7 @@ public void setSource(String source)
/**
* {@inheritDoc}
*/
@Override
@PropertyDescription("The live data source parameters, specified as an URL query string.")
public void setSourceParameters(String sourceParameters)
{
Expand All @@ -70,6 +74,7 @@ public void setSourceParameters(String sourceParameters)
/**
* {@inheritDoc}
*/
@Override
@PropertyDescription("The properties to sort on the live data initially, specified as a comma-separated list of "
+ "property names, where each property name can be optionally suffixed with the sort order using :asc or "
+ ":desc.")
Expand All @@ -81,6 +86,7 @@ public void setSort(String sort)
/**
* {@inheritDoc}
*/
@Override
@PropertyDescription("The initial filters to apply on the live data, specified as an URL query string.")
public void setFilters(String filters)
{
Expand All @@ -90,6 +96,7 @@ public void setFilters(String filters)
/**
* {@inheritDoc}
*/
@Override
@PropertyDescription("The maximum number of live data entries to show on a page.")
public void setLimit(Integer limit)
{
Expand All @@ -99,6 +106,7 @@ public void setLimit(Integer limit)
/**
* {@inheritDoc}
*/
@Override
@PropertyDescription("The index of the first live data entry to show.")
public void setOffset(Long offset)
{
Expand All @@ -108,6 +116,7 @@ public void setOffset(Long offset)
/**
* {@inheritDoc}
*/
@Override
@PropertyDescription("The comma-separated list of layouts the user can choose from to display the live data. "
+ "The first layout in the list will be loaded initially.")
public void setLayouts(String layouts)
Expand All @@ -118,6 +127,7 @@ public void setLayouts(String layouts)
/**
* {@inheritDoc}
*/
@Override
@PropertyDescription("Show or hide the page size drop down that allows the user to change "
+ "the number of entries displayed per page.")
public void setShowPageSizeDropdown(Boolean showPageSizeDropdown)
Expand All @@ -128,6 +138,7 @@ public void setShowPageSizeDropdown(Boolean showPageSizeDropdown)
/**
* {@inheritDoc}
*/
@Override
@PropertyDescription("The comma-separated list of page sizes to display in the page size drop down.")
public void setPageSizes(String pageSizes)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class R151002000XWIKI21448DataMigration extends AbstractHibernateDataMigr
private DocumentReferenceResolver<String> documentReferenceResolver;

@Inject
@Named("compactwiki")
@Named("local")
private EntityReferenceSerializer<String> entityReferenceSerializer;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
import com.xpn.xwiki.internal.store.hibernate.HibernateConfiguration;
import com.xpn.xwiki.store.migration.hibernate.HibernateDataMigration;

/**
* Template for {@link DataMigrationManager}.
Expand Down Expand Up @@ -338,26 +339,25 @@ protected String getMainXWiki()
@Override
public void initialize() throws InitializationException
{
checkMigrationsVersions();
try {
SortedMap<XWikiDBVersion, XWikiMigration> availableMigrations = new TreeMap<>();

Map<XWikiDBVersion, XWikiMigration> forcedMigrations = getForcedMigrations();
if (!forcedMigrations.isEmpty()) {
availableMigrations.putAll(forcedMigrations);
} else {
Set<String> ignoredMigrations = new HashSet<>(this.hibernateConfiguration.getIgnoredMigrations());
for (DataMigration migrator : getAllMigrations()) {
if (ignoredMigrations.contains(migrator.getClass().getName())
|| ignoredMigrations.contains(migrator.getVersion().toString())) {
XWikiDBVersion migratorVersion = migrator.getVersion();
if (isMigrationIgnored(migrator, ignoredMigrations)) {
continue;
}
XWikiMigration migration = new XWikiMigration(migrator, false);
availableMigrations.put(migrator.getVersion(), migration);
availableMigrations.put(migratorVersion, migration);
}
}

this.targetVersion =
(availableMigrations.size() > 0) ? availableMigrations.lastKey() : new XWikiDBVersion(0);
this.targetVersion = !availableMigrations.isEmpty() ? availableMigrations.lastKey() : new XWikiDBVersion(0);
this.migrations = availableMigrations.values();
} catch (Exception e) {
throw new InitializationException("Migration Manager initialization failed", e);
Expand All @@ -366,6 +366,51 @@ public void initialize() throws InitializationException
this.observationManager.addListener(new WikiDeletedEventListener());
}

public boolean isMigrationIgnored(DataMigration migration, Set<String> ignoredMigrations)
{
return ignoredMigrations.contains(migration.getClass().getName())
|| ignoredMigrations.contains(migration.getVersion().toString());
}

/**
* Ensure we don't have two migrations with same DB version.
* Note that it's possible to use the ignored migrations feature to bypass this check: if two migrations has same
* version one can ignore them in which case there will be only a warning.
*
* @throws InitializationException in case we found same DB version or the list of migration cannot be obtained.
*/
private void checkMigrationsVersions() throws InitializationException
{
try {
List<HibernateDataMigration> migrationList =
this.componentManager.getInstanceList(HibernateDataMigration.class);
Set<String> ignoredMigrations = new HashSet<>(this.hibernateConfiguration.getIgnoredMigrations());
Map<XWikiDBVersion, String> hintMap = new HashMap<>();
for (HibernateDataMigration dataMigration : migrationList) {
XWikiDBVersion version = dataMigration.getVersion();
if (hintMap.containsKey(version)) {
if (isMigrationIgnored(dataMigration, ignoredMigrations)) {
this.logger.warn("Two migrations with same version [{}] were found: [{}] and [{}] but "
+ "migration [{}] is ignored.",
version,
hintMap.get(version),
dataMigration.getClass().getName(),
dataMigration.getClass().getName());
} else {
throw new InitializationException(
String.format("Two migrations with same version [%s] were found: [%s] and [%s]",
version,
hintMap.get(version),
dataMigration.getClass().getName()));
}
}
hintMap.put(version, dataMigration.getClass().getName());
}
} catch (ComponentLookupException e) {
throw new InitializationException("Unable to retrieve the list of hibernate data migrations", e);
}
}

/**
* read data version from xwiki.cfg.
*
Expand Down
Loading

0 comments on commit 12a2abb

Please sign in to comment.