// Process form submission, parsing text strings from values.
MultivaluedMap<String, Object> formFields = HttpUtil.retrieveMultiPartFormValues(multiPartForm, String.class);
// Check request contains valid input parameters, value and type.
InputType inputType = retrieveInputType(formFields);
String inputValue = retrieveInputValue(formFields);
logger.log(Level.INFO, String.format(analyseDependenciesLogMsg, inputType.name(), inputValue));
// Invoke analysis based upon input type (web_page, url or profile).
switch(inputType) {
case WEB_PAGE:
moduleAnalysis = analyseModulesFromWebpage(inputValue);
break;
case URL:
moduleAnalysis = analyseModulesFromUrl(inputValue);
break;
}
// Convert Java Map to Json object and then encode inside HTML.
// If parsing errors are thrown, return an internal server error
// HTTP response.
try {
DependenciesResponse response;
String customPackageIdentifier = null;
if (moduleAnalysis instanceof RecursiveModuleAnalysis) {
customPackageIdentifier = createTemporaryPackageForRetrievedSource((RecursiveModuleAnalysis) moduleAnalysis);
}
if (customPackageIdentifier != null) {
response = new ExplicitModuleFormatAnalysisDependenciesResponse(moduleAnalysis,
customPackageIdentifier, ModuleFormat.NON_AMD);
} else {
response = new ExplicitModuleFormatAnalysisDependenciesResponse(moduleAnalysis, ModuleFormat.NON_AMD);
}
encodedJson = JsonUtil.writeJavaToHtmlEncodedJson(response);
} catch (FatalAnalysisError e) {
logger.log(Level.SEVERE, String.format(errorGeneratingJsonLogMsg, inputType.name(), inputValue));
throw new ConfigurationException(internalServerErrorText);
} catch (JsonParseException e) {
logger.log(Level.SEVERE, String.format(errorGeneratingJsonLogMsg, inputType.name(), inputValue));
throw new ConfigurationException(internalServerErrorText);
} catch (JsonMappingException e) {
logger.log(Level.SEVERE, String.format(errorGeneratingJsonLogMsg, inputType.name(), inputValue));
throw new ConfigurationException(internalServerErrorText);
} catch (IOException e) {
logger.log(Level.SEVERE, String.format(errorGeneratingJsonLogMsg, inputType.name(), inputValue));
throw new ConfigurationException(internalServerErrorText);
} catch (UnknownModuleIdentifier e) {
logger.log(Level.SEVERE, String.format(errorGeneratingJsonLogMsg, inputType.name(), inputValue));
throw new ConfigurationException(internalServerErrorText);
} catch (ModuleSourceNotAvailable e) {
logger.log(Level.SEVERE, String.format(errorGeneratingJsonLogMsg, inputType.name(), inputValue));
throw new ConfigurationException(internalServerErrorText);
}
logger.exiting(this.getClass().getName(), "analyseDependencies");