public void createStudyDefinition(Message message) throws RemoteException { List<Study> objects = xmUtils.getDomainObjectsFromList(Study.class, xmUtils.getArguments(message)); if (objects.size() != 1) { throw new RemoteException( "Illegal Argument(s). Make sure there is exactly one study defination in the message."); } WebRequest webRequest = SessionAndAuditHelper.setupHibernateSessionAndAudit( interceptor, "C3PR Admin", "Coordinating Center", new Date(), "Coordinating Center"); try { Study study = objects.get(0); studyFactory.buildStudy(study); for (StudySite studySite : study.getStudySites()) { studySite.setHostedMode(false); // TODO fix it later // studySite.setSiteStudyStatus(SiteStudyStatus.PENDING); } for (StudyCoordinatingCenter studyCoordinatingCenter : study.getStudyCoordinatingCenters()) { studyCoordinatingCenter.setHostedMode(false); } study.setCoordinatingCenterStudyStatus(CoordinatingCenterStudyStatus.PENDING); studyDao.save(study); studyRepository.createStudy(study.getIdentifiers()); } catch (C3PRCodedException e) { throw new RemoteException("error building the study", e); } finally { SessionAndAuditHelper.tearDownHibernateSession(interceptor, webRequest); } }