// @Exposed(accessLevel = AccessLevel.PUBLIC) public void listParameters( final OutputStream out, final String path, final String solution, final String file, final String outputType, final String dataAccessId) throws Exception { final CdaEngine engine = CdaEngine.getInstance(); // final ICommonParameterProvider requestParams = requParam; final String relativePath = getRelativePath(path, solution, file); IRepositoryAccess repAccess = CdaEngine.getEnvironment().getRepositoryAccess(); logger.debug("Do Query: getRelativePath:" + relativePath); final CdaSettings cdaSettings = SettingsManager.getInstance().parseSettingsFile(relativePath); // Handle the query itself and its output format... final DiscoveryOptions discoveryOptions = new DiscoveryOptions(); discoveryOptions.setOutputType(outputType); discoveryOptions.setDataAccessId(dataAccessId); String mimeType = ExporterEngine.getInstance().getExporter(discoveryOptions.getOutputType()).getMimeType(); setResponseHeaders(mimeType); engine.listParameters(out, cdaSettings, discoveryOptions); }
// @Exposed(accessLevel = AccessLevel.PUBLIC) public void unwrapQuery( final OutputStream out, final String path, final String solution, final String file, final String uuid) throws Exception { final CdaEngine engine = CdaEngine.getInstance(); // final ICommonParameterProvider requestParams = requParam; final String relativePath = getRelativePath(path, solution, file); final CdaSettings cdaSettings = SettingsManager.getInstance().parseSettingsFile(relativePath); // String uuid = requestParams.getStringParameter("uuid", null); QueryOptions queryOptions = engine.unwrapQuery(uuid); if (queryOptions != null) { Exporter exporter = ExporterEngine.getInstance() .getExporter(queryOptions.getOutputType(), queryOptions.getExtraSettings()); String attachmentName = exporter.getAttachmentName(); String mimeType = (attachmentName == null) ? null : getMimeType(attachmentName); if (StringUtils.isEmpty(mimeType)) { mimeType = exporter.getMimeType(); } if (relativePath != null && uuid != null) ; // XXX == if (this.parameterProviders != null) { setResponseHeaders(mimeType, attachmentName); } engine.doQuery(out, cdaSettings, queryOptions); } else { logger.error("unwrapQuery: uuid " + uuid + " not found."); } }
// @Exposed(accessLevel = AccessLevel.PUBLIC) public void getCdaList(final OutputStream out, final String outputType) throws Exception { final CdaEngine engine = CdaEngine.getInstance(); final DiscoveryOptions discoveryOptions = new DiscoveryOptions(); discoveryOptions.setOutputType(outputType); ISessionUtils sessionUtils = CdaEngine.getEnvironment().getSessionUtils(); String mimeType = ExporterEngine.getInstance().getExporter(discoveryOptions.getOutputType()).getMimeType(); setResponseHeaders(mimeType); engine.getCdaList(out, discoveryOptions, sessionUtils.getCurrentSession()); }
public void doQuery(final OutputStream out, DoQueryParameters parameters) throws Exception { final CdaEngine engine = CdaEngine.getInstance(); final QueryOptions queryOptions = new QueryOptions(); final String path = getRelativePath(parameters.getPath(), parameters.getSolution(), parameters.getFile()); final CdaSettings cdaSettings = SettingsManager.getInstance().parseSettingsFile(path); // Handle paging options // We assume that any paging options found mean that the user actively wants paging. final long pageSize = parameters.getPageSize(); final long pageStart = parameters.getPageStart(); final boolean paginate = parameters.isPaginateQuery(); if (pageSize > 0 || pageStart > 0 || paginate) { if (pageSize > Integer.MAX_VALUE || pageStart > Integer.MAX_VALUE) { throw new ArithmeticException("Paging values too large"); } queryOptions.setPaginate(true); queryOptions.setPageSize(pageSize > 0 ? (int) pageSize : paginate ? DEFAULT_PAGE_SIZE : 0); queryOptions.setPageStart( pageStart > 0 ? (int) pageStart : paginate ? DEFAULT_START_PAGE : 0); } // Support for bypassCache (we'll maintain the name we use in CDE /*if(requestParams.hasParameter("bypassCache")){ queryOptions.setCacheBypass(Boolean.parseBoolean(requestParams.getStringParameter("bypassCache","false"))); }*/ queryOptions.setCacheBypass(parameters.isBypassCache()); // Handle the query itself and its output format... queryOptions.setOutputType(parameters.getOutputType()); queryOptions.setDataAccessId(parameters.getDataAccessId()); try { queryOptions.setOutputIndexId(parameters.getOutputIndexId()); } catch (NumberFormatException e) { logger.error("Illegal outputIndexId '" + parameters.getOutputIndexId() + "'"); } final ArrayList<String> sortBy = new ArrayList<String>(); String[] def = {}; for (Object obj : parameters.getSortBy()) { if (!((String) obj).equals("")) { sortBy.add((String) obj); } } queryOptions.setSortBy(sortBy); // ... and the query parameters // We identify any pathParams starting with "param" as query parameters and extra settings // prefixed with "setting" @SuppressWarnings("unchecked") final Iterator settings = parameters.getExtraSettings().entrySet().iterator(); while (settings.hasNext()) { Map.Entry<String, Object> pairs = (Map.Entry) settings.next(); final String name = pairs.getKey(); final Object parameter = pairs.getValue(); queryOptions.addSetting(name, (String) parameter); } final Iterator params = parameters.getExtraParams().entrySet().iterator(); while (params.hasNext()) { Map.Entry<String, Object> pairs = (Map.Entry) params.next(); final String name = pairs.getKey(); final Object parameter = pairs.getValue(); queryOptions.addParameter(name, parameter); // if(name.startsWith(PREFIX_PARAMETER)){ // queryOptions.addParameter(name.substring(PREFIX_PARAMETER.length()), parameter); // logger.debug("##########"+name+"##############"); } /* if (param.startsWith(PREFIX_PARAMETER)) { queryOptions.addParameter(param.substring(PREFIX_PARAMETER.length()), requestParams.getParameter(param)); } else if (param.startsWith(PREFIX_SETTING)) { queryOptions.addSetting(param.substring(PREFIX_SETTING.length()), requestParams.getStringParameter(param, "")); }*/ if (parameters.isWrapItUp()) { String uuid = engine.wrapQuery(out, cdaSettings, queryOptions); logger.debug("doQuery: query wrapped as " + uuid); writeOut(out, uuid); return; } // we'll allow for the special "callback" param to be used, and passed as settingcallback to // jsonp exports if (!parameters.getJsonCallback().equals("<blank>")) { queryOptions.addSetting(JSONP_CALLBACK, parameters.getJsonCallback()); } Exporter exporter = ExporterEngine.getInstance() .getExporter(queryOptions.getOutputType(), queryOptions.getExtraSettings()); String attachmentName = exporter.getAttachmentName(); String mimeType = (attachmentName == null) ? null : getMimeType(attachmentName); if (StringUtils.isEmpty(mimeType)) { mimeType = exporter.getMimeType(); } if (parameters != null) ; // XXX + FIXME == if (this.parameterProviders != null) { setResponseHeaders(mimeType, attachmentName); } // Finally, pass the query to the engine engine.doQuery(out, cdaSettings, queryOptions); }