public void msetex(Map<String, String> keysvalues, int expireTime) { Jedis j = null; try { j = getWClient(); String[] keysValuesArr = new String[keysvalues.size()]; Set<Entry<String, String>> set = keysvalues.entrySet(); Iterator<Entry<String, String>> it = set.iterator(); int index = 0; while (it.hasNext()) { Entry<String, String> entry = it.next(); keysValuesArr[index++] = entry.getKey(); keysValuesArr[index++] = entry.getValue(); } j.mset(keysValuesArr); if (expireTime > 0) { for (int i = 0; i < keysValuesArr.length; i = i + 2) { // jedis没看到msetex和mexpire 所以只能多次rpc j.expire(keysValuesArr[i], expireTime); } } getWritePool().returnResource(j); } catch (Exception e) { logger.error(e.getMessage(), e); getWritePool().returnBrokenResource(j); try { getLatestRedis(); } catch (Exception e1) { logger.error(e1.getMessage(), e1); } } }
public void turlRetrievalFailed( String surl, String reason, String remoteRequestId, String remoteFileId) { synchronized (remoteSurlToFileReqIds) { Collection<Long> fileRequestSet = remoteSurlToFileReqIds.get(surl); if (fileRequestSet == null || fileRequestSet.isEmpty()) { LOG.error("turlArrived for unknown SURL = " + surl); return; } for (long id : fileRequestSet) { CopyFileRequest cfr = getFileRequest(id); try { String type = isSourceSrm() && !isSourceLocal() ? "source" : "destination"; String error = "retrieval of " + type + " TURL failed with error " + reason; LOG.error(error); cfr.setState(State.FAILED, error); } catch (IllegalStateTransition ist) { LOG.error("Illegal State Transition : " + ist.getMessage()); } cfr.saveJob(); remoteSurlToFileReqIds.remove(surl, id); } } remoteFileRequestDone(surl, remoteRequestId, remoteFileId); }
public void mset(Map<String, String> keysvalues) { Jedis j = null; try { j = getWClient(); String[] keysValuesArr = new String[2 * keysvalues.size()]; Set<Entry<String, String>> set = keysvalues.entrySet(); Iterator<Entry<String, String>> it = set.iterator(); int index = 0; while (it.hasNext()) { Entry<String, String> entry = it.next(); keysValuesArr[index++] = entry.getKey(); keysValuesArr[index++] = entry.getValue(); } j.mset(keysValuesArr); getWritePool().returnResource(j); } catch (Exception e) { logger.error(e.getMessage(), e); getWritePool().returnBrokenResource(j); try { getLatestRedis(); } catch (Exception e1) { logger.error(e1.getMessage(), e1); } } }
private void sendMaybeEmail(String to) { String subject = "Processing is taking a long time"; StringBuilder content = new StringBuilder(); content.append("Your process is taking longer than expected."); content.append(" It might finish in a bit, but here is the status so far"); content.append("\n\tUpload: ").append((uploadSuccessful) ? "success" : "waiting"); content.append("\n\tParse: ").append((netcdfSuccessful) ? "success" : "waiting"); content.append("\n\tStatistics: ").append((rStatsSuccessful) ? "success" : "waiting"); content.append("\n\tMetadata: ").append((cswTransSuccessful) ? "success" : "waiting"); content.append( "\n\nYou will receive another email if there is a success, but may not receive a failure notification."); List<String> bcc = new ArrayList<String>(); String from = props.getProperty("watersmart.email.from"); String bccAddr = props.getProperty("watersmart.email.tracker"); if (!"".equals(bccAddr)) { bcc.add(bccAddr); } EmailMessage message = new EmailMessage(from, to, null, bcc, subject, content.toString()); try { EmailHandler.sendMessage(message); } catch (AddressException ex) { log.error("Unable to send maybe e-mail:\n" + message, ex); } catch (MessagingException ex) { log.error("Unable to send maybe e-mail:\n" + message, ex); } }
public int update(String sql, Object... params) throws SystemError, LogicError { try { Connection conn = getConnection(); try { PreparedStatement stm = conn.prepareStatement(sql); try { setParams(stm, params); return stm.executeUpdate(); } finally { stm.close(); } } finally { conn.close(); } } catch (LogicError e) { logger.error("Error", e); throw e; } catch (SystemError e) { logger.error("Error", e); throw e; } catch (SQLException e) { logger.error("Error", e); throw new SystemError("Error in update:" + e, MODULO, DaoUtils.getMethod(e), e); } catch (Exception e) { logger.error("Error", e); throw new SystemError("Error in update:" + e, MODULO, DaoUtils.getMethod(e), e); } }
/** * Get the ModelParameter Struct for a given parameter name based on a given data model. * * @param model * @param paramName * @return */ public static ModelParameter getModelParameter(Model model, String paramName) { /** Get the parameter's parent object in the data model */ ModelObject modelObject = getObjectByParamName(model, paramName); if (modelObject == null) { log.error("Unable to find parent object for parameter " + paramName); return null; } /** Short Parameter name within the object */ String paramShortName = paramName.substring(paramName.lastIndexOf(".") + 1, paramName.length()); /* log.debug("paramName " + paramName + ": modelObjectName " + modelObject.getName() + ", parameterShortName " + paramShortName); */ /** lookup the parameter within the parent object */ for (ModelParameter modelParameter : modelObject.getParameterArray()) { if (paramShortName.equals(modelParameter.getName())) { return modelParameter; } } log.error( "Unable to find parameter " + paramShortName + " within object " + modelObject.getName() + "!"); return null; }
@Override protected void shutDown() throws Exception { LOG.info("Stopping Metrics Processor ..."); Throwable throwable = null; try { Services.chainStop(election, resourceClient).get(); } catch (Throwable th) { throwable = th; LOG.error("Exception while shutting down.", th); } try { cancelResourceHandler.cancel(); } catch (Throwable th) { throwable = th; LOG.error("Exception while shutting down.", th); } try { cancelDiscoverable.cancel(); } catch (Throwable th) { throwable = th; LOG.error("Exception while shutting down.", th); } if (throwable != null) { throw Throwables.propagate(throwable); } }
public TmxReader(String tmxContent) throws TmxReadException { // 解析文件 VTDGen vg = new VTDGen(); vg.setDoc(tmxContent.getBytes()); String message = ""; try { vg.parse(true); } catch (EncodingException e) { logger.error(Messages.getString("document.ImportAbstract.logger1"), e); message = Messages.getString("document.ImportAbstract.msg1"); throw new TmxReadException(message + e.getMessage()); } catch (ParseException e) { logger.error(Messages.getString("document.ImportAbstract.logger3"), e); String errMsg = e.getMessage(); if (errMsg.indexOf("invalid encoding") != -1) { // 编码异常 message = Messages.getString("document.ImportAbstract.msg1"); } else { message = Messages.getString("document.ImportAbstract.msg3"); } throw new TmxReadException(message + e.getMessage()); } header = new TmxHeader(); validateTmxAndParseHeader(vg); tuAp = new AutoPilot(vu.getVTDNav()); try { tuAp.selectXPath("./tu"); } catch (XPathParseException e) { throw new TmxReadException(Messages.getString("document.TmxReader.parseTmxFileError")); } }
@Override public Object update(String directory, String newName) throws ModuleException { BundleContainer container = bundles.get(directory); if (container == null) { LOG.error("Missing bundle durign update."); // bundle is not loaded yet .. this should not happen throw new ModuleException("No record about bundle."); } try { container.update(context, createUri(directory, newName)); } catch (BundleException e) { throw new ModuleException("Failed to update bundle.", e); } // try to load main class final String mainClassName = container.getMainClassName(); try { return container.loadClass(mainClassName); } catch (ModuleException e) { // unload DPU try { container.uninstall(); } catch (BundleException uninstallEx) { LOG.error("Failed to uninstall bundle in: {}", directory, uninstallEx); } // re-throw throw e; } }
@Override public String process( HttpServletRequest request, HttpServletResponse response, String data, ObjectMapper mapper, String pathInfo) { LOG.debug("Start process Query :" + pathInfo); String result = ""; try { LoginData loginData = mapper.readValue(data, LoginData.class); loginData = loginService.login(loginData); String x = mapper.writeValueAsString(loginData); result = MessageUtils.handleSuccess(x, mapper); } catch (ParkingEngineException e) { LOG.error("ParkingEngineException when processing " + pathInfo, e); result = MessageUtils.handleException(e, "", mapper); } catch (Exception e) { LOG.error("Unexpected exception when processing " + pathInfo, e); result = MessageUtils.handleException( e, "Unexpected exception when processing " + e.getMessage(), mapper); } return result; }
@Override public BlueprintResponse convert(Blueprint entity) { BlueprintResponse blueprintJson = new BlueprintResponse(); blueprintJson.setId(entity.getId()); blueprintJson.setBlueprintName(entity.getBlueprintName()); blueprintJson.setName(entity.getName()); blueprintJson.setPublicInAccount(entity.isPublicInAccount()); blueprintJson.setDescription(entity.getDescription() == null ? "" : entity.getDescription()); blueprintJson.setHostGroupCount(entity.getHostGroupCount()); blueprintJson.setStatus(entity.getStatus()); try { blueprintJson.setInputs(convertInputParameters(entity.getInputParameters())); } catch (IOException e) { LOGGER.error( String.format( "Blueprint's (%s, id:%s) input parameters could not be converted to JSON.", entity.getName(), entity.getId()), e); } try { blueprintJson.setAmbariBlueprint(jsonHelper.createJsonFromString(entity.getBlueprintText())); } catch (Exception e) { LOGGER.error("Blueprint cannot be converted to JSON.", e); blueprintJson.setAmbariBlueprint(new TextNode(e.getMessage())); } return blueprintJson; }
/** Un-initialization. */ @Override public void destroy() throws Exception { log.debug("TomcatVHostLoader un-init"); Container[] children = host.findChildren(); for (Container c : children) { if (c instanceof StandardContext) { try { ((StandardContext) c).stop(); host.removeChild(c); } catch (Exception e) { log.error("Could not stop context: {}", c.getName(), e); } } } // remove system prop String propertyPrefix = name; if (domain != null) { propertyPrefix += '_' + domain.replace('.', '_'); } System.clearProperty(propertyPrefix + ".webapp.root"); // stop the host try { ((StandardHost) host).stop(); } catch (LifecycleException e) { log.error("Could not stop host: {}", host.getName(), e); } // remove host engine.removeChild(host); // unregister jmx unregisterJMX(); }
public void insertOracle(Connection con, Double orderAmountTotal, long orderNumTotal) { Statement statement = null; try { statement = con.createStatement(); String date_time_id = DateUtil.getFmtDate(null, DateUtil.YYYY_MM_DD_HH_MM_STR); String sql = "insert into rpt.rpt_realtime_mp_sale(date_time_id,ordr_num,pm_amt)" + " values (to_date('" + date_time_id + "','yyyy-MM-dd hh24:mi'),'" + orderNumTotal + "','" + orderAmountTotal + "')"; // LOG.info(sql); try { statement.execute(sql); } catch (Exception e) { logger.error("error: OrderInfoBolt rpt.rpt_realtime_mp_sale error ! ", e); } } catch (Exception e) { logger.error("error: OrderInfoBolt rpt.rpt_realtime_mp_sale error ! ", e); // e.printStackTrace() ; } finally { try { statement.close(); } catch (SQLException e) { e.printStackTrace(); } } }
/** * Determine the text being shown for given panel. * * @param panel * @return The text shown, i18n. */ public Map getHtmlCode(Panel panel) { PanelSession pSession = SessionManager.getPanelSession(panel); Map m = (Map) pSession.getAttribute(ATTR_TEXT); if (m != null) return m; HTMLText text = load(panel.getInstance()); if (text != null) return text.getText(); try { HTMLText textToCreate = new HTMLText(); textToCreate.setPanelInstance(panel.getInstance()); Locale[] locales = LocaleManager.lookup().getPlatformAvailableLocales(); for (int i = 0; i < locales.length; i++) { Locale locale = locales[i]; ResourceBundle i18n = localeManager.getBundle("org.jboss.dashboard.ui.panel.advancedHTML.messages", locale); textToCreate.setText(locale.getLanguage(), i18n.getString("defaultContent")); } textToCreate.save(); } catch (Exception e) { log.error("Error creating empty text for panel: ", e); } text = load(panel.getInstance()); if (text != null) return text.getText(); log.error("Current HTML code is null for panel " + panel); return null; }
@SuppressWarnings("unchecked") @Override public Map<String, Object> getProvinceList() throws ApiRemoteCallFailedException { logger.info("进入调用API查询省信息"); ApiRequest request = new ApiRequest(); request.setUrl(ApiConstant.API_URL_AREA_GET_PROVINCE_LIST); logger.info("Request Query String: {}", request.toQueryString()); ApiResponse response = apiRequestService.request(request, ApiConstant.API_REQUEST_TIME_OUT_DEFAULT); if (response == null) { logger.error("API获取省信息失败"); throw new ApiRemoteCallFailedException("API获取省信息失败"); } if (response.getCode() != ApiConstant.RC_SUCCESS) { logger.error("调用API获取省信息请求出错, rc={}, message={}", response.getCode(), response.getMessage()); throw new ApiRemoteCallFailedException("调用API获取省信息请求出错"); } List<Province> list = Province.convertFromJSONObjectMap(JSONObject.fromObject(response.getData().get(0))); for (Province p : list) { Map<String, Object> map = getCityListByProvince(p.getProvinceId()); if (map != null && map.size() > 0) { List<City> cities = (List<City>) map.get(Global.API_MAP_KEY_LIST); p.setCities(cities); } } Map<String, Object> map = new HashMap<String, Object>(); map.put(Global.API_MAP_KEY_LIST, list); logger.info("结束调用API查询省信息"); return map; }
/** Start the OSGI framework. */ public void start() throws FrameworkStartFailedException { FrameworkFactory frameworkFactory = null; // org.eclipse.osgi.launch.EquinoxFactory try { frameworkFactory = java.util.ServiceLoader.load(FrameworkFactory.class).iterator().next(); } catch (Exception ex) { LOG.error("Failed to load osgi framework class.", ex); // failed to load FrameworkFactory class throw new FrameworkStartFailedException("Can't load class FrameworkFactory.", ex); } framework = frameworkFactory.newFramework(prepareSettings()); context = null; try { // start OSGi container .. framework.start(); } catch (org.osgi.framework.BundleException ex) { LOG.error("Failed to start OSGI framework.", ex); // failed to start/initiate framework throw new FrameworkStartFailedException("Failed to start OSGi framework.", ex); } try { context = framework.getBundleContext(); } catch (SecurityException ex) { LOG.error("Failed to get osgi context.", ex); // we have to stop framework .. stop(); throw new FrameworkStartFailedException("Failed to get OSGi context.", ex); } // load resources startUpLoad(); }
@Override public final boolean formatTheData(final DataSet[] theData) throws IOException { final String usedStyle = globalStyleDefinition; if (null == usedStyle) { log.error("Global Style Definition is Null !"); return false; } log.debug("Using Global Style : " + usedStyle); final String[] globalParts = usedStyle.split("%", 3); for (int i = 0; i < globalParts.length; i++) { log.debug("globalParts[" + i + "] = " + globalParts[i]); } // Global Prefix out.write(globalParts[0].getBytes()); // TODO charset ? if (globalParts.length > 1) { if (false == "ROW".equalsIgnoreCase(globalParts[1])) { log.error("Global Style Definition invalid ! (" + globalParts[1] + ") !"); return false; } } for (int g = 0; g < theData.length; g++) { if (false == formatARow(theData[g])) { log.error("Row output failed at row " + g + " !"); return false; } } if (globalParts.length > 2) { // Global Postfix out.write(globalParts[2].getBytes()); // TODO charset ? } return true; }
public <K> void publish( QueueConsumer<K> queueConsumer, Map<String, String> headers, Class<K> clazz, K pojo, long timeSinceEpoch) throws KafkaException { QueueItem inner = null; try { inner = QueueItem.build(mapper, headers, clazz, pojo); } catch (IOException e) { logger.error("Unable to map/ build queueItem", e); throw new KafkaException("Unable to map/ build queueItem", e); } QueueItem outer = new QueueItem(); outer.setClassName(this.getClass().getCanonicalName()); outer.setTryNumber(0); outer.setJsonObject( Json.createObjectBuilder() .add(QUEUE, queueConsumer.queue()) .add(PAYLOAD, Json.createReader(new StringReader(inner.toString())).read()) .build()); logger.debug("queuing delayQ message: {}", outer); try { delayQ.put(outer.toString(), timeSinceEpoch); } catch (Exception e) { logger.error("Unable to set timer for delayQ", e); throw new KafkaException("Unable to set timer for delayQ", e); } }
@Override public Connection<CL> createConnection() { try { Connection<CL> connection = connFactory.createConnection((HostConnectionPool<CL>) pool, null); connection.open(); availableConnections.add(connection); monitor.incConnectionCreated(host); numActiveConnections.incrementAndGet(); return connection; } catch (DynoConnectException e) { if (Logger.isDebugEnabled()) { if (monitor.getConnectionCreateFailedCount() % 10000 == 0) { Logger.error("Failed to create connection", e); } } monitor.incConnectionCreateFailed(host, e); throw e; } catch (RuntimeException e) { if (Logger.isDebugEnabled()) { if (monitor.getConnectionCreateFailedCount() % 10000 == 0) { Logger.error("Failed to create connection", e); } } monitor.incConnectionCreateFailed(host, e); throw new DynoConnectException(e); } }
public Map<String, Object> consumeMessage( String topic, String consumerGroupId, boolean consumeFromBeginning) throws KafkaException { Map<String, Object> message = new HashMap<String, Object>(); QueueItem queueItem = null; KafkaMessage msg = null; try { msg = kafkaClient.consumeMessage( consumerGroupId, consumeFromBeginning, topic, 3, TimeUnit.SECONDS); } catch (InterruptedException e) { logger.error("Unable to read from message from kafka", e); throw new KafkaException("Unable to read from message from kafka", e); } if (msg != null) { queueItem = QueueItem.build(msg.contentAsString()); message.put("headers", queueItem.getHeaders()); try { message.put("payload", queueItem.payload(mapper)); } catch (ClassNotFoundException e) { logger.error("Unable to map message from kafka to class", e); throw new KafkaException("Unable to map message from kafka to class", e); } catch (IOException e) { logger.error("Unable to convert json into class instance", e); throw new KafkaException("Unable to convert json into class instance", e); } return message; } return null; }
@Override public boolean process(Record record) { temporaryRecord = null; LOGGER.debug("Record received: {}", record); List fields = record.get(Fields.ATTACHMENT_BODY); if (fields.size() != 1) { LOGGER.error("Record [ {} ] had incorrect number of fields - [{}]", record, fields.size()); return false; } try { byte[] byteArray = (byte[]) fields.get(0); SeekableByteArrayInput inputStream = new SeekableByteArrayInput(byteArray); DatumReader<T> userDatumReader = new SpecificDatumReader<T>(this.recordClass); DataFileReader<T> dataFileReader = new DataFileReader<T>(inputStream, userDatumReader); temporaryRecord = dataFileReader.next(); } catch (Exception e) { LOGGER.error("Unable to process {}, exception: {}", record, e); return false; } return true; }
/** * saveEdit * * <p>Updates the object given the specified parameters, and form values. * * <pre> * Version Date Developer Description * 0.1 26/04/2012 Genevieve Turner (GT) Initial * 0.7 04/06/2012 Genevieve Turner (GT) Fixed an issue where the fedora object was not returned in the values map * 0.8 20/06/2012 Genevieve Turner (GT) Updated so that page retrieval is now using a map * 0.13 25/07/2012 Genevieve Turner (GT) Added removing of ready for review/publish * 0.16 27/08/2012 Genevieve Turner (GT) Fixed issue where group was not updated when editing * 0.22 06/11/2012 Genevieve Turner (GT) Updated to check if the user has permissions to update the group if not remove those permissions * 0.23 12/11/2012 Genevieve Turner (GT) Added the request id * </pre> * * @param fedoraObject The fedora object to get the page for * @param tmplt The template that determines the fields on the screen * @param form The form fields of the screen * @param rid The request id * @return Returns the viewable for the jsp file to pick up. */ @Override public Map<String, Object> saveEdit( FedoraObject fedoraObject, String tmplt, Map<String, List<String>> form, Long rid) { Map<String, Object> values = new HashMap<String, Object>(); ViewTransform viewTransform = new ViewTransform(); try { if (form.containsKey("ownerGroup")) { // TODO Update this so that an error is thrown if the user does not have permissions to // update the group if (!permissionService.hasSetGroupPermissionsForObject(fedoraObject)) { form.remove("ownerGroup"); } } fedoraObject = viewTransform.saveData(tmplt, fedoraObject, form, rid); removeReviewReady(fedoraObject); removePublishReady(fedoraObject); if (form.containsKey("ownerGroup")) { permissionService.saveObjectPermissions(fedoraObject); } } catch (JAXBException e) { LOGGER.error("Exception transforming jaxb", e); values.put("error", "true"); } catch (FedoraClientException e) { LOGGER.error("Exception creating/retrieving objects", e); values.put("error", "true"); } return values; }
public <T extends PersistentObject> int updateObject( String sql, BeanSqlSetter<T> sqlSetter, T bean) throws SystemError, LogicError { try { Connection conn = getConnection(); try { PreparedStatement stm = conn.prepareStatement(sql); try { sqlSetter.setParams(stm, bean); int res = stm.executeUpdate(); if (res == 1) bean.saved(); return res; } finally { stm.close(); } } finally { conn.close(); } } catch (LogicError e) { logger.error("Error", e); throw e; } catch (SystemError e) { logger.error("Error", e); throw e; } catch (SQLException e) { logger.error("Error", e); throw new SystemError("Error in update:" + e, MODULO, DaoUtils.getMethod(e), e); } catch (Exception e) { logger.error("Error", e); throw new SystemError("Error in update:" + e, MODULO, DaoUtils.getMethod(e), e); } }
public void rescanBlockchain(long rescanTime) { mLogger.info(String.format("RESCANNING from %d", rescanTime)); // Make sure we are in a good state for this. if (mState != State.READY) { mLogger.warn("can't rescan until the wallet is ready"); return; } switch (mSyncState) { case SYNCHRONIZED: mSyncState = SyncState.RESCAN; break; default: mSyncState = SyncState.RERESCAN; break; } // Remove our wallet event listener. mKit.wallet().removeEventListener(mWalletListener); // Persist and remove our HDWallet. // // NOTE - It's best not to clear the balances here. When the // transactions are filling in on the transactions screen it's // disturbing to see negative historical balances. They'll // get completely refigured when the sync is done anyway ... // mHDWallet.persist(mApp); mHDWallet = null; mLogger.info("resetting wallet state"); mKit.wallet().clearTransactions(0); mKit.wallet().setLastBlockSeenHeight(-1); // magic value mKit.wallet().setLastBlockSeenHash(null); mLogger.info("shutting kit down"); try { mKit.shutDown(); mKit = null; } catch (Exception ex) { mLogger.error("kit shutdown failed: " + ex.toString()); return; } File dir = mApp.getWalletDir(); String spvpath = mApp.getWalletPrefix() + ".spvchain"; mLogger.info("removing spvchain file " + dir + spvpath); File chainFile = new File(dir, spvpath); if (!chainFile.delete()) mLogger.error("delete of spvchain file failed"); mLogger.info("restarting wallet"); mKeyCrypter = mApp.mKeyCrypter; mAesKey = mApp.mAesKey; setState(State.SETUP); mTask = new SetupWalletTask(); mTask.execute(rescanTime); }
/** * Unregisters all JSP page servlets for a plugin. * * @param webXML the web.xml file containing JSP page names to servlet class file mappings. */ public static void unregisterServlets(File webXML) { if (!webXML.exists()) { Log.error( "Could not unregister plugin servlets, file " + webXML.getAbsolutePath() + " does not exist."); return; } // Find the name of the plugin directory given that the webXML file // lives in plugins/[pluginName]/web/web.xml String pluginName = webXML.getParentFile().getParentFile().getParentFile().getName(); try { SAXReader saxReader = new SAXReader(false); saxReader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); Document doc = saxReader.read(webXML); // Find all <servelt-mapping> entries to discover name to URL mapping. List names = doc.selectNodes("//servlet-mapping"); for (int i = 0; i < names.size(); i++) { Element nameElement = (Element) names.get(i); String url = nameElement.element("url-pattern").getTextTrim(); // Destroy the servlet than remove from servlets map. GenericServlet servlet = servlets.get(pluginName + url); if (servlet != null) { servlet.destroy(); } servlets.remove(pluginName + url); servlet = null; } } catch (Throwable e) { Log.error(e.getMessage(), e); } }
/** @param args */ public static void main(String[] args) { // TODO Auto-generated method stub CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); try { config.addConfiguration(new PropertiesConfiguration("storage.properties")); } catch (ConfigurationException e) { // TODO Auto-generated catch block logger.error(e.getMessage()); } String rootFolder = config.getString("bp.root.folder"); String altpartyid = args[0]; SqlSession sqlSession = RazorServer.openSession(); try { if (StringUtils.isBlank(altpartyid)) { // altpartyid = "231051"; //NextPax partner GA altpartyid = "179795"; } Partner partner = sqlSession.getMapper(PartnerMapper.class).exists(altpartyid); if (partner == null) { throw new ServiceException(Error.party_id, altpartyid); } A_Handler handler = new A_Handler(partner); handler.downloadImages(rootFolder); } catch (Exception e) { logger.error(e.getMessage()); } }
@RequestMapping( value = "", method = {RequestMethod.PUT}) @ResponseBody public StreamingRequest updateStreamingConfig(@RequestBody StreamingRequest streamingRequest) throws JsonProcessingException { StreamingConfig streamingConfig = deserializeSchemalDesc(streamingRequest); KafkaConfig kafkaConfig = deserializeKafkaSchemalDesc(streamingRequest); if (streamingConfig == null) { return streamingRequest; } try { streamingConfig = streamingService.updateStreamingConfig(streamingConfig); } catch (AccessDeniedException accessDeniedException) { throw new ForbiddenException("You don't have right to update this StreamingConfig."); } catch (Exception e) { logger.error("Failed to deal with the request:" + e.getLocalizedMessage(), e); throw new InternalErrorException( "Failed to deal with the request: " + e.getLocalizedMessage()); } try { kafkaConfig = kafkaConfigService.updateKafkaConfig(kafkaConfig); } catch (AccessDeniedException accessDeniedException) { throw new ForbiddenException("You don't have right to update this KafkaConfig."); } catch (Exception e) { logger.error("Failed to deal with the request:" + e.getLocalizedMessage(), e); throw new InternalErrorException( "Failed to deal with the request: " + e.getLocalizedMessage()); } streamingRequest.setSuccessful(true); return streamingRequest; }
@Override public Map<String, Object> getCityListByProvince(Integer province) throws ApiRemoteCallFailedException { logger.info("进入调用API根据省信息查询市信息信息"); ApiRequest request = new ApiRequest(); request.setUrl(ApiConstant.API_URL_AREA_GET_CITY_LIST_BY_PROVINCE); if (province == null || province == 0) { logger.error("省ID为0"); throw new ApiRemoteCallFailedException("省ID为0"); } else { request.setParameter(Province.SET_PROVINCE_ID, province + ""); } logger.info("Request Query String: {}", request.toQueryString()); ApiResponse response = apiRequestService.request(request, ApiConstant.API_REQUEST_TIME_OUT_DEFAULT); if (response == null) { logger.error("API根据省信息查询市信息失败"); throw new ApiRemoteCallFailedException("API根据省信息查询市信息失败"); } if (response.getCode() != ApiConstant.RC_SUCCESS) { logger.error( "调用API根据省信息查询市信息请求出错, rc={}, message={}", response.getCode(), response.getMessage()); throw new ApiRemoteCallFailedException("调用API根据省信息查询市信息请求出错"); } List<City> list = City.convertFromJSONObjectMap(JSONObject.fromObject(response.getData().get(0))); Map<String, Object> map = new HashMap<String, Object>(); map.put(Global.API_MAP_KEY_LIST, list); logger.info("结束调用API根据省信息查询市信息"); return map; }
public void fileRequestCompleted() { resetRetryDeltaTime(); if (isProcessingDone()) { try { boolean hasOnlyFinalFileRequests = true; for (CopyFileRequest request : getFileRequests()) { State state = request.getState(); if (!(state.isFinal())) { hasOnlyFinalFileRequests = false; } } State state = getState(); if (!state.isFinal() && hasOnlyFinalFileRequests) { setState(State.DONE, "All transfers have completed."); } } catch (IllegalStateTransition e) { LOG.error("setting to done anyway: {}", e.toString()); try { State state = getState(); if (!state.isFinal()) { setState(State.DONE, e.toString()); } } catch (IllegalStateTransition ist) { LOG.error("Illegal State Transition : {}", ist.getMessage()); } } } }
/* * (non-Javadoc) * @see * au.org.aurin.wif.svc.ManualDemandScenarioService#updateManualDemandScenario * (au.org.aurin.wif.model.allocation.ManualDemandScenario, java.lang.String) */ public void updateDemandOutcome(final DemandOutcome demandOutcome, final String projectId) throws WifInvalidInputException, WifInvalidConfigException, ParsingException { LOGGER.info( "updating ManualDemandScenario: {}, with id: {}", demandOutcome.getLabel(), demandOutcome.getId()); try { if (demandOutcome.getProjectId().equals(projectId)) { demandOutcome.setRevision( demandOutcomeDao.findDemandOutcomeById(demandOutcome.getId()).getRevision()); demandOutcomeDao.updateDemandOutcome(demandOutcome); } else { LOGGER.error( "illegal argument, the ManualDemandScenario supplied doesn't belong to project: " + projectId); throw new WifInvalidInputException( "illegal argument, the ManualDemandScenario supplied doesn't belong to project: " + projectId); } } catch (final IllegalArgumentException e) { LOGGER.error("illegal argument, the ManualDemandScenario supplied is invalid "); throw new WifInvalidInputException( "illegal argument, the ManualDemandScenario supplied is invalid ", e); } }