public static SelectionPolicy newInstance(JUniformObject configObject) throws InvalidAttributesException { if (configObject == null) { throw new InvalidAttributesException("EnvironmentSelectionPolicy is null"); } String policyType = configObject.getProperty("Type").toStringDefault(""); if (policyType == null) { throw new InvalidAttributesException("EnvironmentSelectionPolicy.Type is null"); } switch(policyType) { default: throw new InvalidAttributesException("Unknown environment selection policy type: "+policyType); case "random": return new SelectionPolicyRandom(configObject); } }
/** * Instantiates a new object of this class * * @param station The station name identifier (such as SPVM, etc) */ public Officer(ORB orb, StationType.StationServerName stationName) throws IOException, InvalidAttributesException { this.stationName = stationName; ior = IORLogger.getReference(stationName); if(ior == null || ior.isEmpty()) { throw new InvalidAttributesException("There was an error with the IOR for this client"); } synchronized(this) { officerId = officerCount++; } log = new Logger(System.getProperty("user.dir") + "/", stationName.name() + officerId); org.omg.CORBA.Object obj = orb.string_to_object(ior); IRecordManager myManager = IRecordManagerHelper.narrow(obj); this.manager = myManager; }
public DistributedServerGroup build() throws InvalidAttributesException { if (code == null || code.isEmpty()) { throw new InvalidAttributesException("DistributedServerGroup.code is empty or null"); } if (servers == null || servers.isEmpty()) { throw new InvalidAttributesException("DistributedServerGroup.servers is empty or null"); } if (selectionPolicy == null) { throw new InvalidAttributesException("DistributedServerGroup.selectionPolicy is empty or null"); } return new DistributedServerGroup(this); }
private void findDataStoreWriter() throws InvalidAttributesException { if (getDataStoreType().equals(DataStoreType.MONGO)) { writer = new MongoWriter(); } else if (getDataStoreType().equals(DataStoreType.ES)) { writer = new ESWriter(); } else if(getDataStoreType().equals(DataStoreType.COUCH)) { writer = new CouchWriter(); } else { throw new InvalidAttributesException("The requested datastore support is not available !."); } }
public static void main(String[] args) throws MongoException, IOException, InvalidAttributesException { ResourceBundle rb = ResourceBundle.getBundle("import", Locale.US); DataImporter importer = new DataImporter(rb); importer.setAutoCommitSize(Integer.valueOf(rb.getString("autoCommitSize"))); importer.doDataImport(rb.getString("sql-data-config-file")); }
@RequestMapping(value = "/get", method = RequestMethod.GET, produces = "application/json; charset=UTF-8") public @ResponseBody String home(@RequestParam(value = "feed", required = false, defaultValue = "") String key, @RequestParam(value = "limit", required = false, defaultValue = "5") int limit, @RequestParam(value = "offset", required = false, defaultValue = "0") int offset) throws InvalidAttributesException { return new Gson().toJson(repo.getNewsFeed(key, limit, offset)); }
@RequestMapping(value = "/{semester}", method = RequestMethod.GET, produces = { "application/json; charset=UTF-8" }) public @ResponseBody ResponseEntity getSemGroups(@PathVariable(value = "semester") String semester) throws IOException, URISyntaxException, InvalidAttributesException { List<Faculty> faculties = repo.getSemGroups(semester); if (faculties.isEmpty()) { if(semester.equalsIgnoreCase("cal")){ return new ResponseEntity(getCalendar(), HttpStatus.OK); } throw new InvalidAttributesException(); } return new ResponseEntity(faculties, HttpStatus.OK); }
@RequestMapping(value = "/{semester}/{fak}", method = RequestMethod.GET, produces = { "application/json; charset=UTF-8" }) public @ResponseBody Faculty getSemGroupByFaculty(@PathVariable(value = "semester") String semester, @PathVariable(value = "fak") String fak) throws IOException, URISyntaxException, InvalidAttributesException { Faculty factulty = repo.getSemGroups(semester, fak); if (factulty == null) { throw new InvalidAttributesException(); } return factulty; }
@RequestMapping(value = "/{semester}/{fak}/courses/{id}", method = RequestMethod.GET, produces = { "application/json; charset=UTF-8" }) public @ResponseBody Subject getCourse(@PathVariable(value = "semester") String semester, @PathVariable(value = "fak") String fak, @RequestParam(value = "semgroup") String semgroup, @PathVariable(value = "id") String id) throws InvalidAttributesException, IOException { return repo.getCourse(semester, semgroup, id); }
public List<News> getNews() throws UnsupportedEncodingException, InvalidAttributesException { Map<String, String> rssMap = getNewsCategories(); List<News> news = new ArrayList<News>(); for (Entry<String, String> entry : rssMap.entrySet()) { JsonObject response = getNewsFeed(entry.getKey(), 1, 0); int status = response.get("responseStatus").getAsInt(); if (response != null && response.has("responseData")) { response = response.get("responseData").getAsJsonObject(); } News newsFeed = new News(); newsFeed.setId(entry.getKey()); newsFeed.setLink(entry.getValue()); String title = null; if (status == 200 && response != null && response.has("feed")) { title = response.get("feed").getAsJsonObject().get("title").getAsString(); title = (!title.isEmpty()) ? title : response.get("feed").getAsJsonObject().get("description") .getAsString(); } newsFeed.setTitle("" + title); news.add(newsFeed); } return news; }
public JsonObject getNewsFeed(String key, int limit, int offset) throws InvalidAttributesException { limit = limit + offset; JsonObject response = parser.parse(getFeed(key, limit, offset)).getAsJsonObject(); JsonObject responseData = null; int status = response.get("responseStatus").getAsInt(); if (status == 200 && response != null && response.has("responseData") && response.get("responseData") != null) { responseData = response.get("responseData").getAsJsonObject(); } else { throw new InvalidAttributesException("the given feed-key was not found"); } if (offset > 0) { if (status == 200 && responseData != null && responseData.has("feed")) { JsonObject feed = responseData.get("feed").getAsJsonObject(); JsonArray entries = feed.get("entries").getAsJsonArray(); JsonArray responseEntries = new JsonArray(); for (int i = 0; i < entries.size(); i++) { if (i >= offset) { responseEntries.add(entries.get(i)); } } feed.add("entries", responseEntries); } } response.add("responseData", responseData); return response; }
public SelectionPolicyRandom(JUniformObject configObject) throws InvalidAttributesException { // no attributes required }
public DataImporter(ResourceBundle rb) throws MongoException, InvalidAttributesException, MalformedURLException, IOException { dataStoreType = DataStoreType.valueOf(rb.getString("dataStoreType").toUpperCase()); findDataStoreWriter(); getWriter().initConnection(rb); }
@RequestMapping(value = "", method = RequestMethod.GET, produces = "application/json; charset=UTF-8") public @ResponseBody List<News> home() throws UnsupportedEncodingException, InvalidAttributesException { return repo.getNews(); }
@RequestMapping(value = "", method = RequestMethod.GET, produces = { "application/json; charset=UTF-8" }) public @ResponseBody String home() throws InvalidAttributesException, IOException { return ""; }
@RequestMapping(value = "/cal", method = RequestMethod.GET, produces = { "application/json; charset=UTF-8" }) public @ResponseBody Map<String, String> getCalendar() throws InvalidAttributesException, IOException { return repo.getCalendar(); }
/** * <p> * Registers a new action to be executed on receiving the given command. * </p> * * @param command * The command to link to the action * @param action * The action * @throws InvalidAttributesException * @since 0.0.1 */ public void registerCommandAction(String command, TelegramActionHandler action) throws InvalidAttributesException { if (actionConnector.containsKey(command)) { throw new InvalidAttributesException("Command already registered!"); } actionConnector.put(command, action); }