use of org.akaza.openclinica.exception.OpenClinicaSystemException in project OpenClinica by OpenClinica.
the class ExpressionService method getValueFromDb.
private String getValueFromDb(String expression, List<ItemDataBean> itemData, Map<Integer, ItemBean> itemBeans) throws OpenClinicaSystemException {
if (isExpressionPartial(expression)) {
throw new OpenClinicaSystemException("getValueFromDb:We cannot get the Value of a PARTIAL expression : " + expression);
}
try {
Integer index = getItemGroupOidOrdinalFromExpression(expression).equals("") ? 0 : Integer.valueOf(getItemGroupOidOrdinalFromExpression(expression)) - 1;
ItemDataBean itemDataBean = itemData.get(index);
String value = itemData.get(index).getValue();
if (itemBeans.containsKey(itemDataBean.getItemId())) {
value = ifValueIsDate(itemBeans.get(itemDataBean.getItemId()), value);
}
return value;
} catch (NullPointerException npe) {
logger.error("NullPointerException was thrown ");
return null;
} catch (IndexOutOfBoundsException ioobe) {
logger.error("IndexOutOfBoundsException was thrown ");
return null;
}
}
use of org.akaza.openclinica.exception.OpenClinicaSystemException in project OpenClinica by OpenClinica.
the class ExpressionService method getEventDefinitionCRF.
public EventDefinitionCRFBean getEventDefinitionCRF(String expression) {
if (expression.split(ESCAPED_SEPERATOR).length < 4) {
return null;
}
StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionFromExpression(expression);
CRFBean crf = getCRFFromExpression(expression);
if (studyEventDefinition == null || crf == null)
throw new OpenClinicaSystemException("OCRERR_0020");
return getEventDefinitionCRFDao().findByStudyEventDefinitionIdAndCRFId(this.expressionWrapper.getStudyBean(), studyEventDefinition.getId(), crf.getId());
}
use of org.akaza.openclinica.exception.OpenClinicaSystemException in project OpenClinica by OpenClinica.
the class SpringServletAccess method getPropertiesDir.
public static String getPropertiesDir(ServletContext servletContext) {
String resource = "properties/placeholder.properties";
ServletContextResource scr = (ServletContextResource) getApplicationContext(servletContext).getResource(resource);
String absolutePath = null;
try {
absolutePath = scr.getFile().getAbsolutePath();
} catch (IOException e) {
throw new OpenClinicaSystemException(e.getMessage(), e.fillInStackTrace());
}
absolutePath = absolutePath.replaceAll("placeholder.properties", "");
return absolutePath;
}
use of org.akaza.openclinica.exception.OpenClinicaSystemException in project OpenClinica by OpenClinica.
the class MetaDataReportBean method handleLoadCastor.
private String handleLoadCastor(RulesPostImportContainer rpic) {
try {
// Create Mapping
Mapping mapping = new Mapping();
mapping.loadMapping(getCoreResources().getURL("mappingMarshallerMetadata.xml"));
// Create XMLContext
XMLContext xmlContext = new XMLContext();
xmlContext.setProperty(XMLConfiguration.NAMESPACES, "true");
xmlContext.addMapping(mapping);
StringWriter writer = new StringWriter();
Marshaller marshaller = xmlContext.createMarshaller();
// marshaller.setNamespaceMapping("castor", "http://castor.org/sample/mapping/");
marshaller.setWriter(writer);
marshaller.marshal(rpic);
String result = writer.toString();
String newResult = result.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "");
return newResult;
} catch (FileNotFoundException ex) {
throw new OpenClinicaSystemException(ex.getMessage(), ex.getCause());
} catch (IOException ex) {
throw new OpenClinicaSystemException(ex.getMessage(), ex.getCause());
} catch (MarshalException e) {
throw new OpenClinicaSystemException(e.getMessage(), e.getCause());
} catch (ValidationException e) {
throw new OpenClinicaSystemException(e.getMessage(), e.getCause());
} catch (MappingException e) {
throw new OpenClinicaSystemException(e.getMessage(), e.getCause());
} catch (Exception e) {
throw new OpenClinicaSystemException(e.getMessage(), e.getCause());
}
}
use of org.akaza.openclinica.exception.OpenClinicaSystemException in project OpenClinica by OpenClinica.
the class FileUploadHelper method getFiles.
@SuppressWarnings("unchecked")
private List<File> getFiles(HttpServletRequest request, ServletContext context, String dirToSaveUploadedFileIn) {
List<File> files = new ArrayList<File>();
// FileCleaningTracker fileCleaningTracker =
// FileCleanerCleanup.getFileCleaningTracker(context);
// Create a factory for disk-based file items
DiskFileItemFactory factory = new DiskFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setFileSizeMax(getFileProperties().getFileSizeMax());
try {
// Parse the request
List<FileItem> items = upload.parseRequest(request);
// Process the uploaded items
Iterator<FileItem> iter = items.iterator();
while (iter.hasNext()) {
FileItem item = iter.next();
if (item.isFormField()) {
request.setAttribute(item.getFieldName(), item.getString());
// DO NOTHING , THIS SHOULD NOT BE Handled here
} else {
getFileProperties().isValidExtension(item.getName());
files.add(processUploadedFile(item, dirToSaveUploadedFileIn));
}
}
return files;
} catch (FileSizeLimitExceededException slee) {
throw new OpenClinicaSystemException("exceeds_permitted_file_size", new Object[] { String.valueOf(getFileProperties().getFileSizeMaxInMb()) }, slee.getMessage());
} catch (FileUploadException fue) {
throw new OpenClinicaSystemException("file_upload_error_occured", new Object[] { fue.getMessage() }, fue.getMessage());
}
}
Aggregations