Skip to content

Commit ce4977c

Browse files
committed
Added client API enable flag property - smb.clientAPI.enabled.
Update version to 25.1
1 parent 50d4001 commit ce4977c

File tree

4 files changed

+46
-32
lines changed

4 files changed

+46
-32
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.filesys</groupId>
66
<artifactId>fileserversng</artifactId>
7-
<version>24.3</version>
7+
<version>25.1</version>
88

99
<name>fileServersNG - New file server subsystem using JFileServer - SDK 4</name>
1010
<description>Platform/Repo JAR Module (to be included in the alfresco.war)</description>

src/main/java/org/filesys/alfresco/repo/clientapi/AlfrescoClientApi.java

+41-30
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ public class AlfrescoClientApi extends JSONClientAPI {
9494
// Filesystem device name, from the filesystem.name property value
9595
private String m_filesystemName;
9696

97+
// Client API enable
98+
private boolean m_clientAPIEnabled;
99+
97100
// Base URL for Share, in the format protocol://host:port/webapp
98101
private String m_shareBaseURL;
99102

@@ -154,43 +157,47 @@ private void init() {
154157
if (m_filesysContext == null)
155158
throw new RuntimeException("fileserversNG Failed to find context for filesystem '" + m_filesystemName + "'");
156159

157-
// Check the scripts folder
158-
if (m_scriptsDir != null) {
160+
// Check if the client API is enabled
161+
if ( m_clientAPIEnabled) {
159162

160-
Path scriptsPath = Path.of(m_scriptsDir);
163+
// Check the scripts folder
164+
if (m_scriptsDir != null) {
161165

162-
if (Files.exists(scriptsPath) && Files.isDirectory(scriptsPath)) {
166+
Path scriptsPath = Path.of(m_scriptsDir);
163167

164-
// Check for a script actions configuration TOML file
165-
File scriptsConfigFile = Paths.get(m_scriptsDir, CLIENT_API_SCRIPTS_CONFIGURATION).toFile();
168+
if (Files.exists(scriptsPath) && Files.isDirectory(scriptsPath)) {
166169

167-
try {
168-
m_scriptedActions = parseScriptConfiguration(scriptsConfigFile);
170+
// Check for a script actions configuration TOML file
171+
File scriptsConfigFile = Paths.get(m_scriptsDir, CLIENT_API_SCRIPTS_CONFIGURATION).toFile();
169172

170-
// DEBUG
171-
if (hasDebug())
172-
Debug.println(DBG + "Loaded " + m_scriptedActions.size() + " scripted actions from " + scriptsConfigFile.getAbsolutePath());
173+
try {
174+
m_scriptedActions = parseScriptConfiguration(scriptsConfigFile);
173175

174-
// Save the scripts configuration file path and last modified date/time
175-
m_scriptsConfigFile = scriptsConfigFile;
176-
m_scriptsConfigModifiedAt = scriptsConfigFile.lastModified();
177-
m_configNextCheckAt = System.currentTimeMillis() + m_configCheckInterval;
176+
// DEBUG
177+
if (hasDebug())
178+
Debug.println(DBG + "Loaded " + m_scriptedActions.size() + " scripted actions from " + scriptsConfigFile.getAbsolutePath());
178179

179-
// Update the action map with the scripted actions
180-
updateActionsMap( m_scriptedActions);
180+
// Save the scripts configuration file path and last modified date/time
181+
m_scriptsConfigFile = scriptsConfigFile;
182+
m_scriptsConfigModifiedAt = scriptsConfigFile.lastModified();
183+
m_configNextCheckAt = System.currentTimeMillis() + m_configCheckInterval;
181184

182-
} catch (FileNotFoundException ex) {
183-
throw new RuntimeException("fileserversNG Script configuration file " + CLIENT_API_SCRIPTS_CONFIGURATION + " not found", ex);
184-
} catch (Exception ex) {
185-
throw new RuntimeException("fileserversNG Script configuration file " + CLIENT_API_SCRIPTS_CONFIGURATION + " error", ex);
186-
}
187-
} else
188-
throw new RuntimeException("fileserversNG Client API scripts path is not valid - " + m_scriptsDir);
189-
} else {
185+
// Update the action map with the scripted actions
186+
updateActionsMap(m_scriptedActions);
190187

191-
// DEBUG
192-
if (hasDebug())
193-
Debug.println(DBG + "No script actions specified");
188+
} catch (FileNotFoundException ex) {
189+
throw new RuntimeException("fileserversNG Script configuration file " + CLIENT_API_SCRIPTS_CONFIGURATION + " not found", ex);
190+
} catch (Exception ex) {
191+
throw new RuntimeException("fileserversNG Script configuration file " + CLIENT_API_SCRIPTS_CONFIGURATION + " error", ex);
192+
}
193+
} else
194+
throw new RuntimeException("fileserversNG Client API scripts path is not valid - " + m_scriptsDir);
195+
} else {
196+
197+
// DEBUG
198+
if (hasDebug())
199+
Debug.println(DBG + "No script actions specified");
200+
}
194201
}
195202

196203
// Create the node script helper object
@@ -470,8 +477,13 @@ public void setScriptService(ScriptService scriptService) {
470477
m_scriptService = scriptService;
471478
}
472479

480+
public void setClientApiEnabled(boolean clientApiEnabled) { m_clientAPIEnabled = clientApiEnabled; }
481+
473482
public void setScriptsDir(String scriptsDir) {
474-
m_scriptsDir = scriptsDir;
483+
if ( scriptsDir == null || scriptsDir.isEmpty())
484+
m_scriptsDir = null;
485+
else
486+
m_scriptsDir = scriptsDir;
475487
}
476488

477489
public void setMenuTitle( String title) {
@@ -972,5 +984,4 @@ public ClientAPIResponse processRunAction( RunActionRequest req, ClientAPINetwor
972984
// Return an unsupported error
973985
return new ErrorResponse("Unknown action - '" + req.getAction() + "'", true);
974986
}
975-
976987
}

src/main/resources/alfresco/subsystems/fileserversng/default/file-servers-ng-context.xml

+3
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,9 @@
12711271
<property name="contentContexts"><ref bean="filesystemContexts" /></property>
12721272
<property name="scriptService"><ref bean="scriptService" /></property>
12731273

1274+
<property name="clientApiEnabled">
1275+
<value>${smb.clientAPI.enabled}</value>
1276+
</property>
12741277
<property name="filesystemName">
12751278
<value>${filesystem.name}</value>
12761279
</property>

src/main/resources/alfresco/subsystems/fileserversng/default/file-servers-ng.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ smb.statecache.expiryInterval=300000
108108
smb.statecache.checkInterval=60000
109109

110110
# Client API
111-
smb.clientAPI.enabled=true
111+
smb.clientAPI.enabled=false
112112
smb.clientAPI.debug=false
113113
smb.clientAPI.shareBaseURL=
114114
smb.clientAPI.scriptsDir=

0 commit comments

Comments
 (0)