@Priority(AAIRequestFilterPriority.AUTHORIZATION)
public class AuthInterceptor extends AAIContainerFilter implements ContainerRequestFilter {
- private static final Pattern PATTERN_ECHO = Pattern.compile("^.*/util/echo$");
- private static final Pattern PATTERN_ACTUATOR = Pattern.compile("^.*/actuator/.*$");
+ private static final String ECHO_SEGMENT = "/util/echo";
+ private static final String ACTUATOR_SEGMENT = "/actuator/";
private static final AAIException AAI_EXCEPTION = new AAIException("AAI_3300");
private final AuthorizationService authorizationService;
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
String path = requestContext.getUriInfo().getRequestUri().getPath();
- if (PATTERN_ECHO.matcher(path).matches() || PATTERN_ACTUATOR.matcher(path).matches()) {
+ if (path.endsWith(ECHO_SEGMENT) || path.contains(ACTUATOR_SEGMENT)) {
return;
}
}
// clean up
- payloadFile.delete();
-
+ if (!payloadFile.delete()) {
+ log.warn("Failed to delete payload file: {}", payloadFile.getAbsolutePath());
+ }
}
/**
int count = 0;
try {
- process = new ProcessBuilder().command("bash", "-c", "ps -ef | grep 'addManualData'").start();
+ process = new ProcessBuilder().command("/bin/bash", "-c", "ps -ef | grep 'addManualData'").start();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
- while (br.readLine() != null) {
+ String line;
+ while ((line = br.readLine()) != null) {
count++;
}
int exitVal = process.waitFor();
log.info("Check if dataImport is running returned: " + exitVal);
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ log.warn("Thread interrupted while checking if dataImport is running", ie);
+ return false;
} catch (Exception e) {
ErrorLogHelper.logError("AAI_8002",
"Exception while running the check to see if dataImport is running " + e.getMessage());
if (!foundTheLatestPayload && isTargzExtension(f.getAbsolutePath())) {
payloadFile = f;
foundTheLatestPayload = true;
- } else // delete all files except the latest payload file!
- f.delete();
+ } else {
+ if (!f.delete()) {
+ log.warn("Failed to delete old payload file: {}", f.getAbsolutePath());
+ }
+ }
}
} else {
if (isTargzExtension(allFilesArr[0].getAbsolutePath()))
try {
process =
- new ProcessBuilder().command("bash", "-c", "gzip –d < " + payLoadFileName + " | tar xf -").start();
+ new ProcessBuilder().command("/bin/bash", "-c", "gzip –d < " + payLoadFileName + " | tar xf -").start();
int exitVal = process.waitFor();
log.info("gzip -d returned: " + exitVal);
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ log.warn("Thread interrupted while running the unzip {}", payLoadFileName, ie);
+ return false;
} catch (Exception e) {
ErrorLogHelper.logError("AAI_8002", "Exception while running the unzip " + e.getMessage());
log.info("Exception while running the unzip " + e.getMessage());
process = new ProcessBuilder().command(script).start();
int exitVal = process.waitFor();
log.info("addManualData.sh returned: " + exitVal);
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ log.warn("Thread interrupted while running addManualData.sh", ie);
} catch (Exception e) {
ErrorLogHelper.logError("AAI_8002", "Exception while running addManualData.sh " + e.getMessage());
log.info("Exception while running addManualData.sh" + e.getMessage());