@SuppressWarnings("unchecked") @Override public BusinessServicesSerializer<?> getSerializerOfType(String type) { BusinessServicesSerializer<?> serializer = serializers.get(type); if (serializer == null) { throw new GeneralBusinessException("Serializer of type {} not found.", type); } return serializer; }
@Override public SearchHandler resolve(SearchViewConfiguration searchConfiguration) { SearchHandler handler = builderViewHandlers.get(searchConfiguration); if (handler == null){ throw new GeneralBusinessException("Unknown search type {}", searchConfiguration); } return handler; }
@Override public InterlocutorSendingPolicy getSendingPolicyForInterlocutorType(InterlocutorType interType) { InterlocutorSendingPolicy sendingPolicy = sendingPolicies.get(interType); if (sendingPolicy == null) { throw new GeneralBusinessException("Sending policy for interlocutor of type {} not found.", interType); } return sendingPolicy; }
@SuppressWarnings("unchecked") @Override public PortalSerializer<?> getSerializerOfType(String type) { PortalSerializer<?> serializer = serializers.get(type); if (serializer == null) { throw new GeneralBusinessException("Serializer of type {} not found.", type); } return serializer; }
@Override public Object transform(ServiceDeployment serviceDeployment) { StringWriter sw = new StringWriter(); try { objectMapper.writeValue(sw, serviceDeployment); } catch (IOException e) { throw new GeneralBusinessException(e); } return sw.toString(); }
@Override public T apply(Set<DBUserProfileCustomProperty> input) { if(input.size()>1) { throw new GeneralBusinessException("Too many parameters for single property"); } if(input.isEmpty()) { return null; } DBUserProfileCustomProperty property = input.iterator().next(); return doApply(property); }
public Properties getProperties() { try { return mergeProperties(); } catch (IOException e) { throw new GeneralBusinessException(e); } }
private List<String> pickObviousServices(boolean forceChoosing, Map<String, List<String>> serviceOptionMap) { List<String> pickedServices = new LinkedList<String>(); for (Map.Entry<String, List<String>> servicesEntries : serviceOptionMap.entrySet()) { if (servicesEntries.getValue().size() == 0) { throw new GeneralBusinessException("No deployed service with type {}", servicesEntries.getKey()); } else if (!forceChoosing && servicesEntries.getValue().size() == 1) { serviceChooser.setService(servicesEntries.getKey(), servicesEntries.getValue().get(0)); pickedServices.add(servicesEntries.getKey()); } } return pickedServices; }
private SearchHandler getSearchHandler(String searchConfiguration) { final SearchViewConfiguration searchConf = SearchViewConfiguration.fromCode(searchConfiguration); SearchHandler handler = advancedSearchBuilderViewHandlers.get(searchConf); if (handler == null) throw new GeneralBusinessException("Unsupported advanced search type {}", searchConfiguration); return handler; }
@Override public synchronized void removeService(final String serviceId) { ServiceDeployment removed = currentConfigurationMap.remove(serviceId); if (removed == null) { throw new GeneralBusinessException("Unable to remove service [{}]", serviceId); } saveConfiguration(); }
private YElement prepareYElement(List<Video> videosList) { YElement yElement = new YElement(); if (videosList != null) { Video video = videosList.get(FIRST); try { prepareYElementFromApi(video, yElement); } catch(ParseException e) { throw new GeneralBusinessException(e); } } return yElement; }
@RequestMapping(value = TabConstants.THUMBNAIL_URL_PREFIX + "{elementId:.+}", method = RequestMethod.GET) public void partContent(@PathVariable("elementId") String elementId, HttpServletRequest request, HttpServletResponse response) throws IOException { logger.debug("Displaying thumbnail of {}", elementId); try { HttpContent content = thumbnailService.fetchThumbnailContent(elementId); rangeResponseUtil.sendStreamingData(request, response, content, true); } catch (ExternalThumbnailException externalEx) { response.sendRedirect(externalEx.getExternalUrl()); } catch (IOException e) { throw new GeneralBusinessException(e, "Error while fetching thumbnail of {}", elementId); } }
private ObservationView getObservationView(ObservationObjectType objectType) { ObservationView observationView = ObservationView.getObservationView(objectType); if (observationView == null) { throw new GeneralBusinessException("Cannot determine observation view for observation object type '{}'", objectType.name()); } return observationView; }
private ProcessStats prepareStatsFromJobExecution(final Long jobInstanceId) { final JobExecution jobExecution = processDataStorage.getJobExecution(jobInstanceId); if (jobExecution == null) { throw new GeneralBusinessException("Process [" + jobInstanceId + "] not found!"); } return getProcessStats(jobExecution); }
protected void performAction(String actionName, HttpServletRequest request) { ActionPerformer actionPerformer = actionPerformers.get(actionName); if (actionPerformer == null) { throw new GeneralBusinessException("Unknown action type {}", actionName); } boolean performActionOnAllResources = ServletRequestUtils.getBooleanParameter(request, UriParamConst.PARAM_ALL_RESOURCES, false); String[] resourcesId = request.getParameterValues(UriParamConst.PARAM_RESOURCE_ID); if (ArrayUtils.isNotEmpty(resourcesId) || performActionOnAllResources) { actionPerformer.performAction(null, performActionOnAllResources, resourcesId); } }
private OpenUrlFieldDefinition getFieldConditionDefinition(Version version, String genre, String param) { switch (version) { case v0_1: return getOneDefinition(genre, fieldDefinitions.get(param)); case v1_0: return getOneDefinition(genre, fieldDefinitions.get(extractBaseFromParam(param))); } throw new GeneralBusinessException("OpenUrl version not supported"); }
@SuppressWarnings("unchecked") @Override public List<YElement> getMetadata(String doi) { String requestUrl = crossrefBaseUrl + "?" + buildQuery(doi); ResponseEntity<String> result = crossrefClient.getForEntity(requestUrl, String.class); if (HttpStatus.OK != result.getStatusCode()) { throw new GeneralBusinessException("Error retrieving crossref element with doi: " + doi + ". Response status: " + result.getStatusCode().name()); } List<?> exportables = transformer.read(result.getBody()); return (List<YElement>)exportables; }
private ConfigurationNode acquireConfiguration() { final String configurationPath = configuration.getString("configurationPath"); ConfigurationFactory processesConfigurationFactory; try { processesConfigurationFactory = new ConfigurationFactoryOaccXml(resourceLoader.getResource(configurationPath)); } catch (ConfigurationException | IOException e) { throw new GeneralBusinessException(e, "Exception while startingup ScriptSourceProvider"); } final ConfigurationNode processesConfiguration = processesConfigurationFactory.retrieveConfiguration("ScriptSourceProvider"); return processesConfiguration; }
/** * @return value or null if not present */ private String getConditionValue(Version version, Map<String, String[]> params, String fieldName) { switch (version) { case v0_1: return getOneValue(params, fieldName); case v1_0: return getOneValue(params, fetchParameterName(fieldName)); } throw new GeneralBusinessException("OpenUrl version not supported"); }
public void writeContent(Document document, InputStream inputStream, String contentFormat) { YElement metadata = (YElement) document.getMetadata(); String contentPartName = addOrReplaceYContent(metadata, contentFormat); document.setMetadata(metadata); try { document.addBinaryAttachment(contentPartName, new InputStreamResource(inputStream)); } catch (IOException e) { throw new GeneralBusinessException("Encountered a problem while adding attachment: {} to document: {}", contentPartName, document.getId()); } repository.storeDocument(document, null); }