1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.opencastproject.adminui.impl;
22
23 import org.osgi.service.component.annotations.Activate;
24 import org.osgi.service.component.annotations.Component;
25 import org.osgi.service.component.annotations.Modified;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29 import java.util.ArrayList;
30 import java.util.Arrays;
31 import java.util.List;
32 import java.util.Map;
33 import java.util.Objects;
34
35 @Component(
36 immediate = true,
37 service = AdminUIConfiguration.class,
38 property = {
39 "service.description=Admin UI - Configuration",
40 "service.pid=org.opencastproject.adminui"
41 }
42 )
43 public class AdminUIConfiguration {
44
45
46 private static final Logger logger = LoggerFactory.getLogger(AdminUIConfiguration.class);
47
48 public static final String OPT_PREVIEW_SUBTYPE = "preview.subtype";
49 private static final String OPT_RETRACT_WORKFLOW_ID = "retract.workflow.id";
50 private static final String OPT_MATCH_MANAGED_ACL_ROLE_PREFIXES = "match.managed.acl.role.prefixes";
51
52 private static final String DEFAULT_PREVIEW_SUBTYPE = "preview";
53 private static final String DEFAULT_RETRACT_WORKFLOW_ID = "delete";
54 private static final String DEFAULT_MATCH_MANAGED_ACL_ROLE_PREFIXES = "";
55
56 private String previewSubtype = DEFAULT_PREVIEW_SUBTYPE;
57 private String retractWorkflowId = DEFAULT_RETRACT_WORKFLOW_ID;
58 private List<String> matchManagedAclRolePrefixes = new ArrayList<>();
59
60 public String getPreviewSubtype() {
61 return previewSubtype;
62 }
63
64 public String getRetractWorkflowId() {
65 return retractWorkflowId;
66 }
67
68 public List<String> getMatchManagedAclRolePrefixes() { return matchManagedAclRolePrefixes; }
69
70 @Activate
71 @Modified
72 public void modified(Map<String, Object> properties) {
73 if (properties == null) {
74 properties = Map.of();
75 }
76
77
78 previewSubtype = Objects.toString(properties.get(OPT_PREVIEW_SUBTYPE), DEFAULT_PREVIEW_SUBTYPE);
79 logger.debug("Preview subtype configuration set to '{}'", previewSubtype);
80
81
82 retractWorkflowId = Objects.toString(properties.get(OPT_RETRACT_WORKFLOW_ID), DEFAULT_RETRACT_WORKFLOW_ID);
83 logger.debug("Retract workflow ID set to {}", retractWorkflowId);
84
85
86 String tmp = Objects.toString(properties.get(OPT_MATCH_MANAGED_ACL_ROLE_PREFIXES),
87 DEFAULT_MATCH_MANAGED_ACL_ROLE_PREFIXES);
88 matchManagedAclRolePrefixes = Arrays.asList(tmp.split(","));
89 logger.debug("Match managed acl role prefixes set to {}", matchManagedAclRolePrefixes);
90 }
91 }