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 CoreResources method copyFiles.
/**
* @deprecated. ByteArrayInputStream keeps the whole file in memory needlessly. Use Commons IO's
* {@link IOUtils#copy(java.io.InputStream, java.io.OutputStream)} instead.
*/
@Deprecated
private void copyFiles(ByteArrayInputStream fis, File dest) {
FileOutputStream fos = null;
// Buffer 4K at a time (you can change this).
byte[] buffer = new byte[512];
int bytesRead;
logger.debug("fis?" + fis);
try {
fos = new FileOutputStream(dest);
while ((bytesRead = fis.read(buffer)) >= 0) {
fos.write(buffer, 0, bytesRead);
}
} catch (IOException ioe) {
// error while copying files
OpenClinicaSystemException oe = new OpenClinicaSystemException("Unable to copy file: " + fis + "to" + dest.getAbsolutePath() + "." + dest.getAbsolutePath() + ".");
oe.initCause(ioe);
oe.setStackTrace(ioe.getStackTrace());
throw oe;
} finally {
// Ensure that the files are closed (if they were open).
if (fis != null) {
try {
fis.close();
} catch (IOException ioe) {
OpenClinicaSystemException oe = new OpenClinicaSystemException("Unable to copy file: " + fis + "to" + dest.getAbsolutePath() + "." + dest.getAbsolutePath() + ".");
oe.initCause(ioe);
oe.setStackTrace(ioe.getStackTrace());
logger.debug(ioe.getMessage());
throw oe;
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException ioe) {
OpenClinicaSystemException oe = new OpenClinicaSystemException("Unable to copy file: " + fis + "to" + dest.getAbsolutePath() + "." + dest.getAbsolutePath() + ".");
oe.initCause(ioe);
oe.setStackTrace(ioe.getStackTrace());
logger.debug(ioe.getMessage());
throw oe;
}
}
}
}
use of org.akaza.openclinica.exception.OpenClinicaSystemException in project OpenClinica by OpenClinica.
the class CoreResources method setODM_MAPPING_DIR.
/**
* @pgawade 18-April-2011 - Fix for issue 8394 Method to set the absolute file path value to point to "odm_mapping"
* in resources. cd_odm_mapping.xml file used by Castor API during CRF data import will be copied to this
* location during application initialization
*/
public void setODM_MAPPING_DIR() {
String resource = "classpath:datainfo.properties";
Resource scr = resourceLoader.getResource(resource);
String absolutePath = null;
try {
absolutePath = scr.getFile().getAbsolutePath();
ODM_MAPPING_DIR = getField("filePath");
// System.out.println("ODM_MAPPING_DIR: " + ODM_MAPPING_DIR);
} catch (IOException e) {
throw new OpenClinicaSystemException(e.getMessage(), e.fillInStackTrace());
}
}
Aggregations