Add RequestId and InvocationId to DR
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / InternalServlet.java
1 /*******************************************************************************
2  * ============LICENSE_START==================================================
3  * * org.onap.dmaap
4  * * ===========================================================================
5  * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * * ===========================================================================
7  * * Licensed under the Apache License, Version 2.0 (the "License");
8  * * you may not use this file except in compliance with the License.
9  * * You may obtain a copy of the License at
10  * *
11  *  *      http://www.apache.org/licenses/LICENSE-2.0
12  * *
13  *  * Unless required by applicable law or agreed to in writing, software
14  * * distributed under the License is distributed on an "AS IS" BASIS,
15  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * * See the License for the specific language governing permissions and
17  * * limitations under the License.
18  * * ============LICENSE_END====================================================
19  * *
20  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  * *
22  ******************************************************************************/
23
24
25 package org.onap.dmaap.datarouter.provisioning;
26
27 import java.io.ByteArrayOutputStream;
28 import java.io.File;
29 import java.io.IOException;
30 import java.io.InputStream;
31 import java.nio.file.FileStore;
32 import java.nio.file.FileSystem;
33 import java.nio.file.Files;
34 import java.nio.file.Path;
35 import java.nio.file.Paths;
36 import java.nio.file.StandardCopyOption;
37 import java.util.Properties;
38
39 import javax.servlet.http.HttpServletRequest;
40 import javax.servlet.http.HttpServletResponse;
41
42 import org.json.JSONArray;
43 import org.onap.dmaap.datarouter.provisioning.beans.EventLogRecord;
44 import org.onap.dmaap.datarouter.provisioning.beans.LogRecord;
45 import org.onap.dmaap.datarouter.provisioning.beans.Parameters;
46 import org.onap.dmaap.datarouter.provisioning.eelf.EelfMsgs;
47 import org.onap.dmaap.datarouter.provisioning.utils.DB;
48 import org.onap.dmaap.datarouter.provisioning.utils.LogfileLoader;
49 import org.onap.dmaap.datarouter.provisioning.utils.RLEBitSet;
50
51 import com.att.eelf.configuration.EELFLogger;
52 import com.att.eelf.configuration.EELFManager;
53
54 import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
55
56 /**
57  * <p>
58  * This servlet handles requests to URLs under /internal on the provisioning server. These include:
59  * </p>
60  * <div class="contentContainer">
61  * <table class="packageSummary" border="0" cellpadding="3" cellspacing="0">
62  * <caption><span>URL Path Summary</span><span class="tabEnd">&nbsp;</span></caption>
63  * <tr>
64  * <th class="colFirst" width="15%">URL Path</th>
65  * <th class="colOne">Method</th>
66  * <th class="colLast">Purpose</th>
67  * </tr>
68  * <tr class="altColor">
69  * <td class="colFirst">/internal/prov</td>
70  * <td class="colOne">GET</td>
71  * <td class="colLast">used to GET a full JSON copy of the provisioning data.</td>
72  * </tr>
73  * <tr class="rowColor">
74  * <td class="colFirst">/internal/fetchProv</td>
75  * <td class="colOne">GET</td>
76  * <td class="colLast">used to signal to a standby POD that the provisioning data should be fetched from the active
77  * POD.</td>
78  * </tr>
79  * <tr class="altColor">
80  * <td class="colFirst" rowspan="2">/internal/logs</td>
81  * <td class="colOne">GET</td>
82  * <td class="colLast">used to GET an index of log files and individual logs for this provisioning server.</td>
83  * </tr>
84  * <tr class="altColor">
85  * <td class="colOne">POST</td>
86  * <td class="colLast">used to POST log files from the individual nodes to this provisioning server.</td>
87  * </tr>
88  * <tr class="rowColor">
89  * <td class="colFirst" rowspan="4">/internal/api</td>
90  * <td class="colOne">GET</td>
91  * <td class="colLast">used to GET an individual parameter value. The parameter name is specified by the path after
92  * /api/.</td>
93  * </tr>
94  * <tr class="rowColor">
95  * <td class="colOne">PUT</td>
96  * <td class="colLast">used to set an individual parameter value. The parameter name is specified by the path after
97  * /api/.</td>
98  * </tr>
99  * <tr class="rowColor">
100  * <td class="colOne">DELETE</td>
101  * <td class="colLast">used to remove an individual parameter value. The parameter name is specified by the path after
102  * /api/.</td>
103  * </tr>
104  * <tr class="rowColor">
105  * <td class="colOne">POST</td>
106  * <td class="colLast">used to create a new individual parameter value. The parameter name is specified by the path
107  * after /api/.</td>
108  * </tr>
109  * <tr class="altColor">
110  * <td class="colFirst">/internal/halt</td>
111  * <td class="colOne">GET</td>
112  * <td class="colLast">used to halt the server (must be accessed from 127.0.0.1).</td>
113  * </tr>
114  * <tr class="rowColor">
115  * <td class="colFirst" rowspan="2">/internal/drlogs</td>
116  * <td class="colOne">GET</td>
117  * <td class="colLast">used to get a list of DR log entries available for retrieval.
118  * Note: these are the actual data router log entries sent to the provisioning server by the nodes, not the provisioning
119  * server's internal logs (access via /internal/logs above). The range is returned as a list of record sequence
120  * numbers.</td>
121  * </tr>
122  * <tr class="rowColor">
123  * <td class="colOne">POST</td>
124  * <td class="colLast">used to retrieve specific log entries.
125  * The sequence numbers of the records to fetch are POST-ed; the records matching the sequence numbers are
126  * returned.</td>
127  * </tr>
128  * <tr class="altColor">
129  * <td class="colFirst">/internal/route/*</td>
130  * <td class="colOne">*</td>
131  * <td class="colLast">URLs under this path are handled via the {@link org.onap.dmaap.datarouter.provisioning.RouteServlet}</td>
132  * </tr>
133  * </table>
134  * </div>
135  * <p>
136  * Authorization to use these URLs is a little different than for other URLs on the provisioning server. For the most
137  * part, the IP address that the request comes from should be either:
138  * </p>
139  * <ol>
140  * <li>an IP address of a provisioning server, or</li>
141  * <li>the IP address of a node (to allow access to /internal/prov), or</li>
142  * <li>an IP address from the "<i>special subnet</i>" which is configured with
143  * the PROV_SPECIAL_SUBNET parameter.
144  * </ol>
145  * <p>
146  * In addition, requests to /internal/halt can ONLY come from localhost (127.0.0.1) on the HTTP port.
147  * </p>
148  * <p>
149  * All DELETE/GET/PUT/POST requests made to /internal/api on this servlet on the standby server are proxied to the
150  * active server (using the {@link ProxyServlet}) if it is up and reachable.
151  * </p>
152  *
153  * @author Robert Eby
154  * @version $Id: InternalServlet.java,v 1.23 2014/03/24 18:47:10 eby Exp $
155  */
156 @SuppressWarnings("serial")
157 public class InternalServlet extends ProxyServlet {
158
159     private static final Object lock = new Object();
160     private static Integer logseq = 0; // another piece of info to make log spool file names unique
161     //Adding EELF Logger Rally:US664892
162     private static EELFLogger eelflogger = EELFManager.getInstance()
163         .getLogger(InternalServlet.class);
164
165     /**
166      * Delete a parameter at the address /internal/api/&lt;parameter&gt;. See the <b>Internal API</b> document for
167      * details on how this method should be invoked.
168      */
169     @Override
170     public void doDelete(HttpServletRequest req, HttpServletResponse resp) {
171         setIpFqdnRequestIDandInvocationIDForEelf("doDelete", req);
172         eelflogger.info(EelfMsgs.ENTRY);
173         try {
174             eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
175             EventLogRecord elr = new EventLogRecord(req);
176             if (!isAuthorizedForInternal(req)) {
177                 elr.setMessage("Unauthorized.");
178                 elr.setResult(HttpServletResponse.SC_FORBIDDEN);
179                 eventlogger.info(elr);
180                 sendResponseError(resp, HttpServletResponse.SC_FORBIDDEN, "Unauthorized.", eventlogger);
181                 return;
182             }
183
184             String path = req.getPathInfo();
185             if (path.startsWith("/api/")) {
186                 if (isProxyOK(req) && isProxyServer()) {
187                     super.doDelete(req, resp);
188                     return;
189                 }
190                 String key = path.substring(5);
191                 if (key.length() > 0) {
192                     Parameters param = Parameters.getParameter(key);
193                     if (param != null) {
194                         if (doDelete(param)) {
195                             elr.setResult(HttpServletResponse.SC_OK);
196                             eventlogger.info(elr);
197                             resp.setStatus(HttpServletResponse.SC_OK);
198                             provisioningDataChanged();
199                             provisioningParametersChanged();
200                         } else {
201                             // Something went wrong with the DELETE
202                             elr.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
203                             eventlogger.info(elr);
204                             sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG, eventlogger);
205                         }
206                         return;
207                     }
208                 }
209             }
210             sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Bad URL.", eventlogger);
211         } finally {
212             eelflogger.info(EelfMsgs.EXIT);
213         }
214     }
215
216     /**
217      * Get some information (such as a parameter) underneath the /internal/ namespace. See the <b>Internal API</b>
218      * document for details on how this method should be invoked.
219      */
220     @Override
221     public void doGet(HttpServletRequest req, HttpServletResponse resp) {
222         setIpFqdnRequestIDandInvocationIDForEelf("doGet",req);
223         eelflogger.info(EelfMsgs.ENTRY);
224         try {
225             eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
226             String path = req.getPathInfo();
227             Properties props = (new DB()).getProperties();
228             if (path.equals("/halt") && !req.isSecure()) {
229                 // request to halt the server - can ONLY come from localhost
230                 String remote = req.getRemoteAddr();
231                 if (remote.equals(props.getProperty("org.onap.dmaap.datarouter.provserver.localhost"))) {
232                     intlogger.info("PROV0009 Request to HALT received.");
233                     resp.setStatus(HttpServletResponse.SC_OK);
234                     Main.shutdown();
235                 } else {
236                     intlogger.info("PROV0010 Disallowed request to HALT received from " + remote);
237                     resp.setStatus(HttpServletResponse.SC_FORBIDDEN);
238                 }
239                 return;
240             }
241
242             EventLogRecord elr = new EventLogRecord(req);
243             if (!isAuthorizedForInternal(req)) {
244                 elr.setMessage("Unauthorized.");
245                 elr.setResult(HttpServletResponse.SC_FORBIDDEN);
246                 eventlogger.info(elr);
247                 sendResponseError(resp, HttpServletResponse.SC_FORBIDDEN, "Unauthorized.", eventlogger);
248                 return;
249             }
250             if (path.equals("/fetchProv") && !req.isSecure()) {
251                 // if request came from active_pod or standby_pod and it is not us, reload prov data
252                 SynchronizerTask s = SynchronizerTask.getSynchronizer();
253                 s.doFetch();
254                 resp.setStatus(HttpServletResponse.SC_OK);
255                 return;
256             }
257             if (path.equals("/prov")) {
258                 if (isProxyOK(req) && isProxyServer()) {
259                     if (super.doGetWithFallback(req, resp)) {
260                         return;
261                     }
262                     // fall back to returning the local data if the remote is unreachable
263                     intlogger.info("Active server unavailable; falling back to local copy.");
264                 }
265                 Poker p = Poker.getPoker();
266                 resp.setStatus(HttpServletResponse.SC_OK);
267                 resp.setContentType(PROVFULL_CONTENT_TYPE2);
268                 try {
269                     resp.getOutputStream().print(p.getProvisioningString());
270                 } catch (IOException ioe) {
271                     intlogger.error("IOException" + ioe.getMessage());
272                 }
273                 return;
274             }
275             if (path.equals("/logs") || path.equals("/logs/")) {
276                 resp.setStatus(HttpServletResponse.SC_OK);
277                 resp.setContentType("application/json");
278                 try {
279                     resp.getOutputStream().print(generateLogfileList().toString());
280                 } catch (IOException ioe) {
281                     intlogger.error("IOException" + ioe.getMessage());
282                 }
283                 return;
284             }
285             if (path.startsWith("/logs/")) {
286                 String logdir = props.getProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir");
287                 String logfile = path.substring(6);
288                 if (logdir != null && logfile != null && logfile.indexOf('/') < 0) {
289                     File log = new File(logdir + "/" + logfile);
290                     if (log.exists() && log.isFile()) {
291                         resp.setStatus(HttpServletResponse.SC_OK);
292                         resp.setContentType("text/plain");
293                         Path logpath = Paths.get(log.getAbsolutePath());
294                         try {
295                             Files.copy(logpath, resp.getOutputStream());
296                         } catch (IOException ioe) {
297                             intlogger.error("IOException" + ioe.getMessage());
298                         }
299                         return;
300                     }
301                 }
302                 sendResponseError(resp, HttpServletResponse.SC_NO_CONTENT, "No file.", eventlogger);
303                 return;
304             }
305             if (path.startsWith("/api/")) {
306                 if (isProxyOK(req) && isProxyServer()) {
307                     super.doGet(req, resp);
308                     return;
309                 }
310                 String key = path.substring(5);
311                 if (key.length() > 0) {
312                     Parameters param = Parameters.getParameter(key);
313                     if (param != null) {
314                         resp.setStatus(HttpServletResponse.SC_OK);
315                         resp.setContentType("text/plain");
316                         try {
317                             resp.getOutputStream().print(param.getValue() + "\n");
318                         } catch (IOException ioe) {
319                             intlogger.error("IOException" + ioe.getMessage());
320                         }
321                         return;
322                     }
323                 }
324             }
325             if (path.equals("/drlogs") || path.equals("/drlogs/")) {
326                 // Special POD <=> POD API to determine what log file records are loaded here
327                 LogfileLoader lfl = LogfileLoader.getLoader();
328                 resp.setStatus(HttpServletResponse.SC_OK);
329                 resp.setContentType("text/plain");
330                 try {
331                     resp.getOutputStream().print(lfl.getBitSet().toString());
332                 } catch (IOException ioe) {
333                     intlogger.error("IOException" + ioe.getMessage());
334                 }
335                 return;
336             }
337             sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Bad URL.", eventlogger);
338         } finally {
339             eelflogger.info(EelfMsgs.EXIT);
340         }
341     }
342
343     /**
344      * Modify a parameter at the address /internal/api/&lt;parameter&gt;. See the <b>Internal API</b> document for
345      * details on how this method should be invoked.
346      */
347     @Override
348     public void doPut(HttpServletRequest req, HttpServletResponse resp) {
349         setIpFqdnRequestIDandInvocationIDForEelf("doPut", req);
350         eelflogger.info(EelfMsgs.ENTRY);
351         try {
352             eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
353             EventLogRecord elr = new EventLogRecord(req);
354             if (!isAuthorizedForInternal(req)) {
355                 elr.setMessage("Unauthorized.");
356                 elr.setResult(HttpServletResponse.SC_FORBIDDEN);
357                 eventlogger.info(elr);
358                 sendResponseError(resp, HttpServletResponse.SC_FORBIDDEN, "Unauthorized.", eventlogger);
359                 return;
360             }
361             String path = req.getPathInfo();
362             if (path.startsWith("/api/")) {
363                 if (isProxyOK(req) && isProxyServer()) {
364                     super.doPut(req, resp);
365                     return;
366                 }
367                 String key = path.substring(5);
368                 if (key.length() > 0) {
369                     Parameters param = Parameters.getParameter(key);
370                     if (param != null) {
371                         String t = catValues(req.getParameterValues("val"));
372                         param.setValue(t);
373                         if (doUpdate(param)) {
374                             elr.setResult(HttpServletResponse.SC_OK);
375                             eventlogger.info(elr);
376                             resp.setStatus(HttpServletResponse.SC_OK);
377                             provisioningDataChanged();
378                             provisioningParametersChanged();
379                         } else {
380                             // Something went wrong with the UPDATE
381                             elr.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
382                             eventlogger.info(elr);
383                             sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG, eventlogger);
384                         }
385                         return;
386                     }
387                 }
388             }
389             sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Bad URL.", eventlogger);
390         } finally {
391             eelflogger.info(EelfMsgs.EXIT);
392         }
393     }
394
395     /**
396      * Create some new information (such as a parameter or log entries) underneath the /internal/ namespace. See the
397      * <b>Internal API</b> document for details on how this method should be invoked.
398      */
399     @SuppressWarnings("resource")
400     @Override
401     public void doPost(HttpServletRequest req, HttpServletResponse resp) {
402         setIpFqdnRequestIDandInvocationIDForEelf("doPost", req);
403         eelflogger.info(EelfMsgs.ENTRY);
404         try {
405             eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF, req.getHeader(BEHALF_HEADER));
406             EventLogRecord elr = new EventLogRecord(req);
407             if (!isAuthorizedForInternal(req)) {
408                 elr.setMessage("Unauthorized.");
409                 elr.setResult(HttpServletResponse.SC_FORBIDDEN);
410                 eventlogger.info(elr);
411                 sendResponseError(resp, HttpServletResponse.SC_FORBIDDEN, "Unauthorized.", eventlogger);
412                 return;
413             }
414
415             String path = req.getPathInfo();
416             if (path.startsWith("/api/")) {
417                 if (isProxyOK(req) && isProxyServer()) {
418                     super.doPost(req, resp);
419                     return;
420                 }
421                 String key = path.substring(5);
422                 if (key.length() > 0) {
423                     Parameters param = Parameters.getParameter(key);
424                     if (param == null) {
425                         String t = catValues(req.getParameterValues("val"));
426                         param = new Parameters(key, t);
427                         if (doInsert(param)) {
428                             elr.setResult(HttpServletResponse.SC_OK);
429                             eventlogger.info(elr);
430                             resp.setStatus(HttpServletResponse.SC_OK);
431                             provisioningDataChanged();
432                             provisioningParametersChanged();
433                         } else {
434                             // Something went wrong with the INSERT
435                             elr.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
436                             eventlogger.info(elr);
437                             sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG, eventlogger);
438                         }
439                         return;
440                     }
441                 }
442             }
443
444             if (path.equals("/logs") || path.equals("/logs/")) {
445                 String ctype = req.getHeader("Content-Type");
446                 if (ctype == null || !ctype.equals("text/plain")) {
447                     elr.setResult(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
448                     elr.setMessage("Bad media type: " + ctype);
449                     resp.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
450                     eventlogger.info(elr);
451                     return;
452                 }
453                 String spooldir = (new DB()).getProperties().getProperty("org.onap.dmaap.datarouter.provserver.spooldir");
454                 String spoolname = String.format("%d-%d-", System.currentTimeMillis(), Thread.currentThread().getId());
455                 synchronized (lock) {
456                     // perhaps unnecessary, but it helps make the name unique
457                     spoolname += logseq.toString();
458                     logseq++;
459                 }
460                 String encoding = req.getHeader("Content-Encoding");
461                 if (encoding != null) {
462                     if (encoding.trim().equals("gzip")) {
463                         spoolname += ".gz";
464                     } else {
465                         elr.setResult(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
466                         resp.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
467                         eventlogger.info(elr);
468                         return;
469                     }
470                 }
471                 // Determine space available -- available space must be at least 5%
472                 FileSystem fs = (Paths.get(spooldir)).getFileSystem();
473                 long total = 0;
474                 long avail = 0;
475                 for (FileStore store : fs.getFileStores()) {
476                     try {
477                         total += store.getTotalSpace();
478                         avail += store.getUsableSpace();
479                     } catch (IOException ioe) {
480                         intlogger.error("IOException" + ioe.getMessage());
481                     }
482                 }
483                 try {
484                     fs.close();
485                 } catch (Exception e) {
486                 }
487                 if (((avail * 100) / total) < 5) {
488                     elr.setResult(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
489                     resp.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
490                     eventlogger.info(elr);
491                     return;
492                 }
493                 Path tmppath = Paths.get(spooldir, spoolname);
494                 Path donepath = Paths.get(spooldir, "IN." + spoolname);
495                 try {
496                     Files.copy(req.getInputStream(), Paths.get(spooldir, spoolname), StandardCopyOption.REPLACE_EXISTING);
497                     Files.move(tmppath, donepath, StandardCopyOption.REPLACE_EXISTING);
498                     elr.setResult(HttpServletResponse.SC_CREATED);
499                     resp.setStatus(HttpServletResponse.SC_CREATED);
500                     eventlogger.info(elr);
501                     LogfileLoader.getLoader();    // This starts the logfile loader "task"
502                 } catch (IOException ioe) {
503                     intlogger.error("IOException" + ioe.getMessage());
504                 }
505                 return;
506             }
507
508             if (path.equals("/drlogs") || path.equals("/drlogs/")) {
509                 // Receive post request and generate log entries
510                 String ctype = req.getHeader("Content-Type");
511                 if (ctype == null || !ctype.equals("text/plain")) {
512                     elr.setResult(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
513                     elr.setMessage("Bad media type: " + ctype);
514                     resp.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
515                     eventlogger.info(elr);
516                     return;
517                 }
518                 try {
519                     InputStream is = req.getInputStream();
520                     ByteArrayOutputStream bos = new ByteArrayOutputStream();
521                     int ch;
522                     while ((ch = is.read()) >= 0) {
523                         bos.write(ch);
524                     }
525                     RLEBitSet bs = new RLEBitSet(bos.toString());    // The set of records to retrieve
526                     elr.setResult(HttpServletResponse.SC_OK);
527                     resp.setStatus(HttpServletResponse.SC_OK);
528                     resp.setContentType("text/plain");
529                     LogRecord.printLogRecords(resp.getOutputStream(), bs);
530                     eventlogger.info(elr);
531                 } catch (IOException ioe) {
532                     intlogger.error("IOException" + ioe.getMessage());
533                 }
534                 return;
535             }
536
537             elr.setResult(HttpServletResponse.SC_NOT_FOUND);
538             sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Bad URL.", eventlogger);
539             eventlogger.info(elr);
540         } finally {
541             eelflogger.info(EelfMsgs.EXIT);
542         }
543     }
544
545     private String catValues(String[] v) {
546         StringBuilder sb = new StringBuilder();
547         if (v != null) {
548             String pfx = "";
549             for (String s : v) {
550                 sb.append(pfx);
551                 sb.append(s);
552                 pfx = "|";
553             }
554         }
555         return sb.toString();
556     }
557
558     private JSONArray generateLogfileList() {
559         JSONArray ja = new JSONArray();
560         Properties p = (new DB()).getProperties();
561         String s = p.getProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir");
562         if (s != null) {
563             String[] dirs = s.split(",");
564             for (String dir : dirs) {
565                 File f = new File(dir);
566                 String[] list = f.list();
567                 if (list != null) {
568                     for (String s2 : list) {
569                         if (!s2.startsWith(".")) {
570                             ja.put(s2);
571                         }
572                     }
573                 }
574             }
575         }
576         return ja;
577     }
578 }