AemDsSettingsServiceImpl.java
6.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.commons.io.FileUtils
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.PropertyOption
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.commons.osgi.OsgiUtil
* org.apache.sling.settings.SlingSettingsService
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.settings.internal;
import com.adobe.aemds.settings.AemDsSettingsService;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.PropertyOption;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.OsgiUtil;
import org.apache.sling.settings.SlingSettingsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
@Service
@Component(metatype=1, immediate=1, label="%settings.name", description="%settings.description")
public class AemDsSettingsServiceImpl
implements AemDsSettingsService {
private static final String TEMP_FOLDER_TYPE_SYSTEM = "system";
private static final String TEMP_FOLDER_TYPE_SLING = "sling";
private static final String TEMP_FOLDER_TYPE_CUSTOM = "custom";
@Property(value={"sling"}, options={@PropertyOption(name="system", value="%settings.tempfolder.type.system"), @PropertyOption(name="sling", value="%settings.tempfolder.type.sling"), @PropertyOption(name="custom", value="%settings.tempfolder.type.custom")})
private static final String PROP_TEMP_FOLDER_TYPE = "settings.tempfolder.type";
@Property
private static final String PROP_TEMP_FOLDER_PATH = "settings.tempfolder.path";
@Property(boolValue={1})
private static final String PROP_TEMP_FOLDER_CLEAN = "settings.tempfolder.clean";
private static final boolean PROP_FIPS_MODE_DEFAULT = false;
@Property(boolValue={0})
private static final String PROP_FIPS_MODE = "settings.fipsmode.enabled";
private static final boolean PROPS_A9_COMPAT_MODE_ENABLED_DEFAULT = false;
@Property(boolValue={0})
private static final String PROPS_A9_COMPAT_MODE = "settings.a9compatmode.enabled";
@Property
private static final String PROPS_PROCESSING_SERVER_URL = "settings.processing.server.url";
@Property
private static final String PROPS_PROCESSING_SERVER_USERNAME = "settings.processing.server.username";
@Property
private static final String PROPS_PROCESSING_SERVER_PASSWORD = "settings.processing.server.password";
private static final String TEMP_FOLDER_NAME = "temp";
private Logger log = LoggerFactory.getLogger(AemDsSettingsServiceImpl.class);
@Reference
private SlingSettingsService settingsService;
private String tempFolderPath;
private boolean fipsModeEnabled;
private boolean a9CompatModeEnabled;
private String processingServerUrl;
private String processingServerUsername;
private String processingServerPassword;
@Activate
private void activate(Map<String, Object> config) throws IOException {
String folderType = OsgiUtil.toString((Object)config.get("settings.tempfolder.type"), (String)"sling");
this.tempFolderPath = "system".equals(folderType) ? System.getProperty("java.io.tmpdir") : ("sling".equals(folderType) ? new File(this.settingsService.getSlingHomePath(), "temp").getCanonicalPath() : OsgiUtil.toString((Object)config.get("settings.tempfolder.path"), (String)null));
File tempFolder = new File(this.tempFolderPath);
boolean clean = OsgiUtil.toBoolean((Object)config.get("settings.tempfolder.clean"), (boolean)true);
if (!"system".equals(folderType)) {
if (clean && tempFolder.exists()) {
this.log.info("Clean temporary file folder option enabled. Cleaning the folder {}", (Object)tempFolder);
try {
FileUtils.cleanDirectory((File)tempFolder);
}
catch (IOException ioe) {
this.log.info("Exception while cleaning temporary file folder", (Throwable)ioe);
}
this.log.info("Cleaned the temp folder {}", (Object)tempFolder);
}
if (!tempFolder.exists()) {
FileUtils.forceMkdir((File)tempFolder);
}
}
if (!tempFolder.exists()) {
throw new IllegalArgumentException("Temporary file folder [" + tempFolder + "] does not exist");
}
this.tempFolderPath = tempFolder.getCanonicalPath();
this.fipsModeEnabled = OsgiUtil.toBoolean((Object)config.get("settings.fipsmode.enabled"), (boolean)false);
this.a9CompatModeEnabled = OsgiUtil.toBoolean((Object)config.get("settings.a9compatmode.enabled"), (boolean)false);
this.processingServerUrl = OsgiUtil.toString((Object)config.get("settings.processing.server.url"), (String)null);
this.processingServerUsername = OsgiUtil.toString((Object)config.get("settings.processing.server.username"), (String)null);
this.processingServerPassword = OsgiUtil.toString((Object)config.get("settings.processing.server.password"), (String)null);
this.log.info("Using folder {} as temporary file storage location", (Object)this.tempFolderPath);
}
@Override
public String getTempFolderPath() {
return this.tempFolderPath;
}
@Override
public boolean isFIPSModeEnabled() {
return this.fipsModeEnabled;
}
@Override
public boolean isA9CompatModeEnabled() {
return this.a9CompatModeEnabled;
}
@Override
public String getProcessingServerUrl() {
return this.processingServerUrl;
}
@Override
public String getProcessingServerUsername() {
return this.processingServerUsername;
}
@Override
public String getProcessingServerPassword() {
return this.processingServerPassword;
}
protected void bindSettingsService(SlingSettingsService slingSettingsService) {
this.settingsService = slingSettingsService;
}
protected void unbindSettingsService(SlingSettingsService slingSettingsService) {
if (this.settingsService == slingSettingsService) {
this.settingsService = null;
}
}
}