Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oc 6735 Capture number of OC studies by type and phase_Master #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.akaza.openclinica.designer.core.NaiveTrustProvider;
import org.akaza.openclinica.designer.web.HostAccessService;
import org.cdisc.ns.odm.v130.ODM;
import org.codehaus.jackson.map.ObjectMapper;
import org.openclinica.ns.response.v31.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -23,6 +24,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URI;

import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -50,7 +52,7 @@ public class AccessResourceController {
private static final String PARAM_RUN_TIME = "runTime";
private static final String PARAM_MESSAGE = "msg";
private static final String SESSION_ATTR_FORM = "form";

protected final Logger logger = LoggerFactory.getLogger(getClass().getName());

public AccessResourceController() {
Expand All @@ -61,16 +63,17 @@ public AccessResourceController() {
public String createForm(Model model, HttpSession session, HttpServletRequest request, @RequestParam(PARAM_HOST) String providerHost,
@RequestParam(PARAM_APP) String providerApp, @RequestParam(PARAM_STUDY_OID) String studyOid,
@RequestParam(PARAM_PROVIDER_USER) String providerUser, @RequestParam(value = PARAM_APP_PATH, required = false) String path,
@RequestParam(value = PARAM_RULE_OID, required = false) String ruleOid, @RequestParam(value = PARAM_TARGET, required = false) String target, @RequestParam(value = PARAM_RUN_TIME, required = false) String runTime, @RequestParam(value = PARAM_MESSAGE, required = false) String message)
@RequestParam(value = PARAM_RULE_OID, required = false) String ruleOid, @RequestParam(value = PARAM_TARGET, required = false) String target,
@RequestParam(value = PARAM_RUN_TIME, required = false) String runTime, @RequestParam(value = PARAM_MESSAGE, required = false) String message)
throws Exception {

if (!hostAccessService.isHostAllowedAccess(providerHost)) {
return "index";
}
logger.debug("Host is Valid ...");
if (message != null) {
message = message.replace("-0-","\n");
message = message.replace("-1-"," ");
message = message.replace("-0-", "\n");
message = message.replace("-1-", " ");
}
userPreferences.setAppName(providerApp);
userPreferences.setPath(path);
Expand Down Expand Up @@ -102,8 +105,7 @@ public String exit(HttpServletRequest request, HttpSession session) throws Excep
}

@RequestMapping(value = "/refreshSession", method = RequestMethod.GET)
public @ResponseBody
String refreshSession() throws IOException {
public @ResponseBody String refreshSession() throws IOException {
return "sessionRefreshed";
}

Expand All @@ -120,7 +122,7 @@ private void doRest() {
@RequestMapping(value = "/initMetadata", method = RequestMethod.GET)
public ModelAndView initMetadata(Model model, HttpSession session, @RequestParam("host") String providerHost, @RequestParam("app") String providerApp,
@RequestParam("study_oid") String studyOid) throws Exception {
// model.addAttribute("contact", new Contact());
// model.addAttribute("contact", new Contact());`
userPreferences.setAppName(providerApp);
userPreferences.setHost(providerHost);
userPreferences.setStudyOid(studyOid);
Expand All @@ -138,10 +140,16 @@ private ODM getMetadata() {
ODM odm = null;
String uri = userPreferences.getMetadataURL();
InputStream studyMetadataXML = new ByteArrayInputStream(userPreferences.getRestTemplate().getForObject(URI.create(uri), byte[].class));

try {
InputStreamReader isr = new InputStreamReader(studyMetadataXML, "UTF-8");
odm = (ODM) this.unMarshaller.unmarshal(new StreamSource(isr));
// odm = (ODM) this.unMarshaller.unmarshal(new StreamSource(studyMetadataXML));
if (odm != null) {
ObjectMapper mapper = new ObjectMapper();
String jsonInString = mapper.writeValueAsString(odm);
logger.debug(jsonInString);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down
47 changes: 0 additions & 47 deletions src/main/resources/logback.groovy

This file was deleted.

31 changes: 31 additions & 0 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">

<property resource="resources.properties" />

<appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<Pattern>%d %-4relative [%thread] %-5level %logger{35} - %msg%n</Pattern>
</encoder>
</appender>

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover. Make sure the path matches the one in the file element or else
the rollover logs are placed in the working directory. -->
<fileNamePattern>${logFilePath}application_%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>

<encoder>
<charset>UTF-8</charset>
<pattern>%d %-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>

<logger name="org.akaza.openclinica.designer" level="DEBUG">
<appender-ref ref="FILE"/>
re </logger>
</configuration>
12 changes: 7 additions & 5 deletions src/main/resources/resources.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
allowHosts=localhost:8080,svn.akazaresearch.com:8444,svn.akazaresearch.com:8081,64.119.157.114:8060,64.119.157.114:8061,64.119.157.114:8062,64.119.157.114:8063,64.119.157.114:8064,64.119.157.114:8065,64.119.157.114:8066,64.119.157.114:8067,64.119.157.114:8068,64.119.157.114:8069,64.119.157.114:8070,64.119.157.114:8071,64.119.157.114:8072,64.119.157.114:8073,192.168.15.66:8080
hostlist.url=
hostlist.port=
hostlist.username=
hostlist.password=
allowHosts=localhost:8080,svn.akazaresearch.com:8444,svn.akazaresearch.com:8081,64.119.157.114:8060,64.119.157.114:8061,64.119.157.114:8062,64.119.157.114:8063,64.119.157.114:8064,64.119.157.114:8065,64.119.157.114:8066,64.119.157.114:8067,64.119.157.114:8068,64.119.157.114:8069,64.119.157.114:8070,64.119.157.114:8071,64.119.157.114:8072,64.119.157.114:8073,192.168.15.66:8080,oc.local:8081
hostlist.url=http://oc.local:8081
hostlist.port=1234
hostlist.username=1234
hostlist.password=1234
logFilePath=/usr/local/tomcat/