/** * @param URI * @return * @throws VtnServiceWebAPIException */ public static boolean validateGetAPI(String URI) throws VtnServiceWebAPIException { LOG.trace("Start VtnServiceCommonUtil#validateGetAPI()"); boolean status = false; if (null != URI && !URI.isEmpty()) { if (URI.trim().contains(ApplicationConstants.CONTROLLERSTR) && URI.trim().contains(ApplicationConstants.DOMAINSTR) && URI.trim().contains(ApplicationConstants.LOGICALPORTSSTR)) { status = true; } else if (URI.trim().startsWith(ApplicationConstants.SESSIONSTR) && URI.trim().length() > ApplicationConstants.SESSIONSTR.length()) { status = true; } else { final String getListAPI = ConfigurationManager.getInstance().getConfProperty(ApplicationConstants.GETLISTAPI); if (null != getListAPI && !getListAPI.isEmpty()) { final String[] tempList = getListAPI.split(ApplicationConstants.COMMA_STR); for (int i = 0; i < tempList.length; i++) { final String getStr = tempList[i]; if (URI.trim().equals(getStr.trim())) { status = true; break; } } } } } LOG.trace("Complete VtnServiceCommonUtil#validateGetAPI()"); return status; }
/** * Authorize user. * * @param bean the bean * @param httpMethod the http method * @return true, if successful * @throws VtnServiceWebAPIException the vtn service web api exception */ public static boolean authoriseUser(SessionBean bean, String httpMethod) throws VtnServiceWebAPIException { LOG.trace("Start VtnServiceCommonUtil#authoriseUser()"); boolean ipStatus = false; final ConfigurationManager configurationManager = ConfigurationManager.getInstance(); final String ipAddresses = configurationManager.getAccessProperty(ApplicationConstants.ACCESS_ALL); LOG.debug("Authorized IP Address from Configuration : " + ipAddresses); final String httpMethodAccessIpAddress = configurationManager.getAccessProperty(httpMethod.toUpperCase()); LOG.debug("Authorized methods from Configuration : " + ipAddresses); if (ipAddresses != null && ApplicationConstants.WILD_CARD_STAR.equals(ipAddresses.trim())) { ipStatus = true; } else if (ipAddresses.indexOf(bean.getIpAddress()) != -1) { ipStatus = true; } else if (null != httpMethodAccessIpAddress && !httpMethodAccessIpAddress.isEmpty() && ApplicationConstants.WILD_CARD_STAR.equals(httpMethodAccessIpAddress.trim())) { ipStatus = true; } else if (null != httpMethodAccessIpAddress && !httpMethodAccessIpAddress.isEmpty() && httpMethodAccessIpAddress.indexOf(bean.getIpAddress()) != -1) { ipStatus = true; } LOG.debug("Authorize User Result : " + ipStatus); LOG.trace("Complete VtnServiceCommonUtil#authoriseUser()"); return ipStatus; }
private Configurable getComponentFromAnnotation(String name, S4Component s4Component) { Configurable configurable; Class<? extends Configurable> defClass = s4Component.defaultClass(); if (defClass.equals(Configurable.class) && s4Component.mandatory()) { throw new InternalConfigurationException( getInstanceName(), name, "mandatory property is not set!"); } if (Modifier.isAbstract(defClass.getModifiers()) && s4Component.mandatory()) throw new InternalConfigurationException( getInstanceName(), name, defClass.getName() + " is abstract!"); // because we're forced to use the default type, make sure that it // is set if (defClass.equals(Configurable.class)) { if (s4Component.mandatory()) { throw new InternalConfigurationException( getInstanceName(), name, instanceName + ": no default class defined for " + name); } else { return null; } } configurable = ConfigurationManager.getInstance(defClass); if (configurable == null) { throw new InternalConfigurationException( getInstanceName(), name, "instantiation of referenenced configurable failed"); } return configurable; }
public ParameterTypeConfigurable(String key, String description, String typeId) { super(key, description); if (!ConfigurationManager.getInstance().hasTypeId(typeId)) { throw new IllegalArgumentException("Unknown configurable type: " + typeId); } this.typeId = typeId; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.about); // set display size final Display display = getWindowManager().getDefaultDisplay(); ThumbSize.setScreenSize(display.getWidth(), display.getHeight()); try { mEventClientManager = ManagerFactory.getEventClientManager(null); final String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; final int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; ((TextView) findViewById(R.id.about_version)).setText("v" + versionName); ((TextView) findViewById(R.id.about_revision)).setText("Revision " + versionCode); TextView message = (TextView) findViewById(R.id.about_url_message); message.setText( Html.fromHtml( "Visit our project page at <a href=\"http://code.google.com/p/android-xbmcremote\">Google Code</a>.")); message.setMovementMethod(LinkMovementMethod.getInstance()); } catch (NameNotFoundException e) { ((TextView) findViewById(R.id.about_version)).setText("Error reading version"); } mConfigurationManager = ConfigurationManager.getInstance(this); }
public T loadExistingOrCreateNewConfiguration() throws JAXBException { ConfigurationManager configurationManager = ConfigurationManager.getInstance(); Object confObject = configurationManager.loadConfiguration(configPath, defaultConfiguration.getClass()); T configuration = null; // existuje konfigurační soubor ? if (confObject == null) { // neexistuje - vytvoř implicitní a ulož configuration = defaultConfiguration; configurationManager.storeConfiguration(configPath, configuration); } else { configuration = (T) confObject; } return configuration; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.moviedetails); // set display size final Display display = getWindowManager().getDefaultDisplay(); ThumbSize.setScreenSize(display.getWidth(), display.getHeight()); // remove nasty top fading edge FrameLayout topFrame = (FrameLayout) findViewById(android.R.id.content); topFrame.setForeground(null); final Movie movie = (Movie) getIntent().getSerializableExtra(ListController.EXTRA_MOVIE); mMovieDetailsController = new MovieDetailsController(this, movie); ((TextView) findViewById(R.id.titlebar_text)).setText(movie.getName()); Log.i( "MovieDetailsActivity", "rating = " + movie.rating + ", index = " + ((int) Math.round(movie.rating % 10)) + "."); if (movie.rating > -1) { ((ImageView) findViewById(R.id.moviedetails_rating_stars)) .setImageResource(sStarImages[(int) Math.round(movie.rating % 10)]); } ((TextView) findViewById(R.id.moviedetails_director)) .setText(StringUtil.join(", ", movie.director)); ((TextView) findViewById(R.id.moviedetails_genre)) .setText(StringUtil.join(" / ", movie.genres)); ((TextView) findViewById(R.id.moviedetails_runtime)).setText(movie.runtime); ((TextView) findViewById(R.id.moviedetails_rating)).setText(String.valueOf(movie.rating)); mMovieDetailsController.setupPlayButton((Button) findViewById(R.id.moviedetails_playbutton)); mMovieDetailsController.loadCover((JewelView) findViewById(R.id.moviedetails_jewelcase)); mMovieDetailsController.updateMovieDetails( new Handler(), (TextView) findViewById(R.id.moviedetails_rating_numvotes), (TextView) findViewById(R.id.moviedetails_studio), (TextView) findViewById(R.id.moviedetails_plot), (TextView) findViewById(R.id.moviedetails_parental), (Button) findViewById(R.id.moviedetails_trailerbutton), (LinearLayout) findViewById(R.id.moviedetails_datalayout)); mConfigurationManager = ConfigurationManager.getInstance(this); }
/** * Get the last map element * * @return */ public MapElement getLastMapElement() { if (lastMapElement != null) { return (lastMapElement); } if (lastMapElementName == null) { return (null); } if (lastMapElementType == null) { return (null); } MapElementState meState = ConfigurationManager.getInstance() .getCurrentConfiguration() .findMapElementState(lastMapElementType, lastMapElementName); if (meState != null) { lastMapElement = meState.getMapElement(); } return (lastMapElement); }
@BeforeMethod public void setUp() throws Exception { PropertyConfigurator.configure( ConfigurationManager.getInstance().getHubConfigDir() + "/log4j.properties"); }
@BeforeTest public void setUp() { LOGGER.info("=========" + System.getProperty("user.dir")); configurationManager = ConfigurationManager.getInstance(CONFIG_FILE); }
/** * Gets a list of components associated with the given parameter name * * @param <T> parent component * @param name the parameter name * @param tclass the class of the list elements * @return the component associated with the name * @throws PropertyException if the component does not exist or is of the wrong type. */ public <T> List<T> getComponentList(String name, Class<T> tclass) throws InternalConfigurationException { getProperty(name, S4ComponentList.class); List<?> components = (List<?>) propValues.get(name); assert registeredProperties.get(name).getAnnotation() instanceof S4ComponentList; S4ComponentList annotation = (S4ComponentList) registeredProperties.get(name).getAnnotation(); // no components names are available and no component list was yet // loaded therefore load the default list of components from the // annotation if (components == null) { List<Class<? extends Configurable>> defClasses = Arrays.asList(annotation.defaultList()); // if (annotation.mandatory() && defClasses.isEmpty()) // throw new InternalConfigurationException(getInstanceName(), name, // "mandatory property is not set!"); List<Configurable> defaultComponents = new ArrayList<Configurable>(); for (Class<? extends Configurable> defClass : defClasses) { defaultComponents.add(ConfigurationManager.getInstance(defClass)); } propValues.put(name, defaultComponents); } else if (!components.isEmpty() && !(components.get(0) instanceof Configurable)) { List<Configurable> resolvedComponents = new ArrayList<Configurable>(); for (Object componentName : components) { Configurable configurable = cm.lookup((String) componentName); if (configurable != null) { resolvedComponents.add(configurable); } else if (!annotation.beTolerant()) { throw new InternalConfigurationException( name, (String) componentName, "lookup of list-element '" + componentName + "' failed!"); } } propValues.put(name, resolvedComponents); } List<?> values = (List<?>) propValues.get(name); ArrayList<T> result = new ArrayList<T>(); for (Object obj : values) { if (tclass.isInstance(obj)) { result.add(tclass.cast(obj)); } else { throw new InternalConfigurationException( getInstanceName(), name, "Not all elements have required type " + tclass + " Found one of type " + obj.getClass()); } } return result; }