Skip to content

Commit f6cb80a

Browse files
committed
Remove acl additional action listprovider config
This replaces the listprovider config with a organization config based implementation.
1 parent 2094203 commit f6cb80a

File tree

2 files changed

+88
-9
lines changed

2 files changed

+88
-9
lines changed

etc/listproviders/acl.additional.actions.properties

Lines changed: 0 additions & 9 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Licensed to The Apereo Foundation under one or more contributor license
3+
* agreements. See the NOTICE file distributed with this work for additional
4+
* information regarding copyright ownership.
5+
*
6+
*
7+
* The Apereo Foundation licenses this file to you under the Educational
8+
* Community License, Version 2.0 (the "License"); you may not use this file
9+
* except in compliance with the License. You may obtain a copy of the License
10+
* at:
11+
*
12+
* http://opensource.org/licenses/ecl2.txt
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17+
* License for the specific language governing permissions and limitations under
18+
* the License.
19+
*
20+
*/
21+
22+
package org.opencastproject.list.common.provider;
23+
24+
import org.opencastproject.list.api.ResourceListProvider;
25+
import org.opencastproject.list.api.ResourceListQuery;
26+
import org.opencastproject.list.util.ListProviderUtil;
27+
import org.opencastproject.security.api.SecurityService;
28+
import org.opencastproject.security.api.Organization;
29+
import org.opencastproject.security.util.SecurityUtil;
30+
31+
import org.osgi.service.component.annotations.Component;
32+
import org.osgi.service.component.annotations.Reference;
33+
import org.slf4j.Logger;
34+
import org.slf4j.LoggerFactory;
35+
36+
import java.util.Map;
37+
import java.util.HashMap;
38+
39+
@Component(
40+
service = ResourceListProvider.class,
41+
property = {
42+
"service.description=ACL additional actions list provider",
43+
"opencast.service.type=org.opencastproject.list.provider.AclAdditionalActionsListProvider"
44+
}
45+
)
46+
public class AclAdditionalActionsListProvider implements ResourceListProvider {
47+
48+
private static final String PROVIDER_PREFIX = "ACL.ACTIONS";
49+
private static final String[] NAMES = { PROVIDER_PREFIX };
50+
private static final Logger logger = LoggerFactory.getLogger(AclAdditionalActionsListProvider.class);
51+
52+
private SecurityService securityService;
53+
54+
@Reference
55+
public void setSecurityService(SecurityService securityService) {
56+
this.securityService = securityService;
57+
}
58+
59+
@Override
60+
public String[] getListNames() {
61+
return NAMES;
62+
}
63+
64+
@Override
65+
public Map<String, String> getList(String listName, ResourceListQuery query) {
66+
try {
67+
Organization org = securityService.getOrganization();
68+
if (org == null) {
69+
return new HashMap<>();
70+
}
71+
Map<String, String> actions = SecurityUtil.additionalAclActions(org);
72+
return ListProviderUtil.filterMap(actions, query);
73+
} catch (Exception e) {
74+
logger.warn("Unable to read additional ACL actions from organization configuration", e);
75+
return new HashMap<>();
76+
}
77+
}
78+
79+
@Override
80+
public boolean isTranslatable(String listName) {
81+
return false;
82+
}
83+
84+
@Override
85+
public String getDefault() {
86+
return null;
87+
}
88+
}

0 commit comments

Comments
 (0)