Skip to content

Commit

Permalink
Pass username from principal to PrivateCollectionsProvider, resolve #231
Browse files Browse the repository at this point in the history
  • Loading branch information
Willem Elbers committed Nov 1, 2024
1 parent 610d618 commit d51fd27
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class BrowsePrivateCollectionsPage extends BasePage {

public BrowsePrivateCollectionsPage() {
final BrowseEditableCollectionsPanel pnl =
new BrowseEditableCollectionsPanel("collections", new PrivateCollectionsProvider(getSession()), getPageReference());
new BrowseEditableCollectionsPanel("collections", new PrivateCollectionsProvider(getUser()), getPageReference());
pnl.setOutputMarkupId(true);
add(pnl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public MergeCollectionsPage(PageParameters params) throws VirtualCollectionRegis
throw new RestartResponseException(ErrorPage.class);
}

this.provider = new PrivateCollectionsProvider(getSession());
this.provider = new PrivateCollectionsProvider(getUser());

addLabel(this, "heading_submitted_collection");
addLabel(this, "heading_actions");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package eu.clarin.cmdi.virtualcollectionregistry.gui.table;

import eu.clarin.cmdi.virtualcollectionregistry.QueryOptions;
import eu.clarin.cmdi.virtualcollectionregistry.gui.ApplicationSession;
import eu.clarin.cmdi.virtualcollectionregistry.model.VirtualCollection;
import java.security.Principal;

/**
*
Expand All @@ -11,18 +11,21 @@
@SuppressWarnings("serial")
public class PrivateCollectionsProvider extends CollectionsProvider {

private final ApplicationSession session;
private final String authenticatedUsername;

public PrivateCollectionsProvider(final ApplicationSession session) {
this.session = session;
public PrivateCollectionsProvider(final Principal authenticatedPrincipal) {
this(authenticatedPrincipal.getName());
}

public PrivateCollectionsProvider(final String authenticatedUsername) {
this.authenticatedUsername = authenticatedUsername;
}

@Override
protected void addSpaceFilter(QueryOptions.Filter filter) {
//ApplicationSession session = ApplicationSession.get();
filter.add(QueryOptions.Property.VC_OWNER,
QueryOptions.Relation.EQ,
session.getUser());
authenticatedUsername);
}

protected void addTypeFilter(QueryOptions.Filter filter, VirtualCollection.Type type) {
Expand Down

0 comments on commit d51fd27

Please sign in to comment.