@@ -94,6 +94,9 @@ public class AlfrescoClientApi extends JSONClientAPI {
94
94
// Filesystem device name, from the filesystem.name property value
95
95
private String m_filesystemName ;
96
96
97
+ // Client API enable
98
+ private boolean m_clientAPIEnabled ;
99
+
97
100
// Base URL for Share, in the format protocol://host:port/webapp
98
101
private String m_shareBaseURL ;
99
102
@@ -154,43 +157,47 @@ private void init() {
154
157
if (m_filesysContext == null )
155
158
throw new RuntimeException ("fileserversNG Failed to find context for filesystem '" + m_filesystemName + "'" );
156
159
157
- // Check the scripts folder
158
- if (m_scriptsDir != null ) {
160
+ // Check if the client API is enabled
161
+ if ( m_clientAPIEnabled ) {
159
162
160
- Path scriptsPath = Path .of (m_scriptsDir );
163
+ // Check the scripts folder
164
+ if (m_scriptsDir != null ) {
161
165
162
- if ( Files . exists ( scriptsPath ) && Files . isDirectory ( scriptsPath )) {
166
+ Path scriptsPath = Path . of ( m_scriptsDir );
163
167
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 )) {
166
169
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 ( );
169
172
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 );
173
175
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 ());
178
179
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 ;
181
184
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 );
190
187
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
+ }
194
201
}
195
202
196
203
// Create the node script helper object
@@ -470,8 +477,13 @@ public void setScriptService(ScriptService scriptService) {
470
477
m_scriptService = scriptService ;
471
478
}
472
479
480
+ public void setClientApiEnabled (boolean clientApiEnabled ) { m_clientAPIEnabled = clientApiEnabled ; }
481
+
473
482
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 ;
475
487
}
476
488
477
489
public void setMenuTitle ( String title ) {
@@ -972,5 +984,4 @@ public ClientAPIResponse processRunAction( RunActionRequest req, ClientAPINetwor
972
984
// Return an unsupported error
973
985
return new ErrorResponse ("Unknown action - '" + req .getAction () + "'" , true );
974
986
}
975
-
976
987
}
0 commit comments