List of usage examples for java.util Properties toString
@Override public synchronized String toString()
From source file:de.zib.gndms.infra.system.GNDMSystem.java
/** * Creates an EntityManagerFactory./*from w w w . j av a 2 s. co m*/ * * @return an EntityManagerFactory * @throws Exception */ @SuppressWarnings({ "ResultOfMethodCallIgnored" }) public @NotNull EntityManagerFactory createEMF() throws Exception { final String gridName = sharedConfig.getGridName(); final Properties map = new Properties(); map.put("openjpa.Id", gridName); map.put("openjpa.ConnectionURL", "jdbc:derby:" + gridName + ";create=true"); if (isDebugging()) { File jpaLogFile = new File(getLogDir(), "jpa.log"); if (!jpaLogFile.exists()) jpaLogFile.createNewFile(); map.put("openjpa.Log", "File=" + jpaLogFile + ", DefaultLevel=INFO, Runtime=TRACE, Tool=INFO"); } logger.info("Opening JPA Store: " + map.toString()); return createEntityManagerFactory(gridName, map); }
From source file:com.redsqirl.auth.UserInfoBean.java
/** * login// w w w . j a v a 2s .co m * * Method to validate permission of the user and call init. * * @return String - success or failure * @author Igor.Souza */ public String login() { logger.warn("login"); setMsnError(null); cancel = false; checkPassword = false; buildBackend = true; setAlreadySignedInOtherMachine(null); setAlreadySignedIn(null); String licenseKey = null; String licence = ""; if (getUserName() == null || "".equals(getUserName())) { setMsnError(getMessageResources("login_error_user_required")); return "failure"; } if (getPassword() == null || "".equals(getPassword())) { setMsnError(getMessageResources("login_error_password_required")); return "failure"; } FacesContext fCtx = FacesContext.getCurrentInstance(); ServletContext sc = (ServletContext) fCtx.getExternalContext().getContext(); HttpSession session = (HttpSession) fCtx.getExternalContext().getSession(true); try { Connection conn = new Connection(hostname); conn.connect(); if (conn.isAuthMethodAvailable(userName, "publickey")) { logger.debug("--> public key auth method supported by server"); } else { logger.debug("--> public key auth method not supported by server"); } if (conn.isAuthMethodAvailable(userName, "keyboard-interactive")) { logger.debug("--> keyboard interactive auth method supported by server"); } else { logger.debug("--> keyboard interactive auth method not supported by server"); } if (conn.isAuthMethodAvailable(userName, "password")) { logger.debug("--> password auth method supported by server"); } else { logger.warn("--> password auth method not supported by server"); } checkPassword = conn.authenticateWithPassword(userName, password); if (!checkPassword) { setMsnError("Authentication Error"); setAlreadySignedInOtherMachine(null); logger.warn("Authentication Error"); return "failure"; } try { File licenseP = new File(WorkflowPrefManager.getPathSystemLicence()); logger.warn("path licence " + WorkflowPrefManager.getPathSystemLicence()); Properties props = new Properties(); logger.warn(ProjectID.get()); String[] value = ProjectID.get().trim().split("-"); if (value != null && value.length > 1) { licenseKey = value[0].replaceAll("[0-9]", "") + value[value.length - 1]; if (licenseP.exists()) { props.load(new FileInputStream(licenseP)); logger.warn(props.toString()); licenseKey = licenseKey.replaceAll("[^A-Za-z0-9]", "").toLowerCase(); logger.warn(licenseKey); licence = props.getProperty(licenseKey); } else { setMsnError("Could not find license key"); logger.warn("Could not find license key"); invalidateSession(); return "failure"; } if (licence == null || licence.isEmpty()) { setMsnError("License key was empty"); logger.warn("License key was empty"); invalidateSession(); return "failure"; } Decrypter decrypt = new Decrypter(); decrypt.decrypt(licence); //setNumberCluster(decrypt.getNumberCluster()); /*File file = new File(WorkflowPrefManager.getPathUsersFolder()); int homes = 0; if(file.exists()){ homes = file.list().length; }*/ Map<String, String> params = new HashMap<String, String>(); //params.put(Decrypter.clusterNb, String.valueOf(homes)); //params.put(Decrypter.mac, decrypt.getMACAddress()); params.put(Decrypter.name, licenseKey); DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd"); params.put(Decrypter.date, formatter.format(new Date())); if (!decrypt.validateExpiredKey(params)) { setMsnError("License Key is expired"); logger.warn("License Key is expired"); invalidateSession(); return "failure"; } boolean valid = decrypt.validateAllValuesSoft(params); if (!valid) { setMsnError("License Key is Invalid"); logger.warn("License Key is Invalid"); invalidateSession(); return "failure"; } } else { setMsnError("Project Version is Invalid"); logger.warn("Project Version is Invalid"); invalidateSession(); return "failure"; } } catch (Exception e) { logger.error(e.getMessage(), e); setMsnError("Failed to get license"); invalidateSession(); return "failure"; } } catch (IOException e) { logger.error(e.getMessage(), e); invalidateSession(); setMsnError("error - Please Contact Your Administrator"); return "failure"; } UsageRecordWriter usageRecordLog = new UsageRecordWriter(licence, userName); Map<String, UsageRecordWriter> sessionUsageRecordWriter = (Map<String, UsageRecordWriter>) sc .getAttribute("usageRecordLog"); if (sessionUsageRecordWriter == null) { sessionUsageRecordWriter = new HashMap<String, UsageRecordWriter>(); } sessionUsageRecordWriter.put(userName, usageRecordLog); sc.setAttribute("usageRecordLog", sessionUsageRecordWriter); @SuppressWarnings("unchecked") Map<String, HttpSession> sessionLoginMap = (Map<String, HttpSession>) sc.getAttribute("sessionLoginMap"); HttpSession sessionLogin = sessionLoginMap.get(userName); if (sessionLogin != null) { logger.warn("validateSecondLogin sessionLogin"); if (sessionLogin.getId().equals(session.getId())) { setAlreadySignedInOtherMachine(null); setAlreadySignedIn("twice"); logger.warn("Already Authenticated twice"); usageRecordLog().addError("ERROR LOGIN", "Already Authenticated twice"); return "failure"; } else if (forceSignIn.equalsIgnoreCase("T")) { //Invalidate the session invalidateSession(sessionLogin); } else { setAlreadySignedInOtherMachine("two"); logger.warn("Already Authenticated two"); usageRecordLog().addError("ERROR LOGIN", "Already Authenticated two"); return "failure"; } } logger.info("update progressbar"); setValueProgressBar(5); logger.info("validateSecondLogin end"); usageRecordLog().addSuccess("LOGIN"); return init(); }
From source file:com.fer.hr.service.datasource.ClassPathResourceDatasourceManager.java
public void init() { if (repoURL == null) { File f = new File(System.getProperty("java.io.tmpdir") + "/files/"); f.mkdir();/*from w ww . j a v a 2s . c o m*/ setPath(System.getProperty("java.io.tmpdir") + "/files/"); InputStream inputStream = ClassPathResourceDatasourceManager.class .getResourceAsStream("/connection.properties"); Properties testProps = new Properties(); try { testProps.load(inputStream); } catch (IOException e) { e.printStackTrace(); } String connStr = System.getenv("DATABASE_URL"); if (connStr != null && !connStr.isEmpty()) { URI dbUri = null; try { dbUri = new URI(connStr); } catch (URISyntaxException e) { e.printStackTrace(); } String username = dbUri.getUserInfo().split(":")[0]; String password = dbUri.getUserInfo().split(":")[1]; String mondrianJdbcKey = "jdbc:mondrian:Jdbc="; String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':' + dbUri.getPort() + dbUri.getPath(); String catalog = ";Catalog=res:schemas/MondrianSalesSchema.xml;"; String dbConnStr = mondrianJdbcKey + dbUrl + catalog; testProps.replace("location", dbConnStr); testProps.replace("username", username); testProps.replace("password", password); System.out.println("ClassPathResourceDatasourceManager -> init() -> props=" + testProps.toString()); } setDatasource(new SaikuDatasource("test", SaikuDatasource.Type.OLAP, testProps)); } }
From source file:dk.defxws.fedoragsearch.server.Config.java
public Config(String configNameIn) throws ConfigException { configName = configNameIn;// w ww .ja v a 2s .c o m if (configName == null || configName.equals("")) { //MIH use default config-name configName = getDefaultConfigName(); } errors = new StringBuffer(); // Get fedoragsearch properties try { InputStream propStream = getResourceInputStream("/fedoragsearch.properties"); fgsProps = new Properties(); fgsProps.load(propStream); propStream.close(); //MIH convertProperties(fgsProps); } catch (IOException e) { throw new ConfigException( "*** Error loading " + configName + "/fedoragsearch.properties:\n" + e.toString()); } if (logger.isInfoEnabled()) logger.info("fedoragsearch.properties=" + fgsProps.toString()); // Get repository properties repositoryNameToProps = new Hashtable(); defaultRepositoryName = null; StringTokenizer repositoryNames = new StringTokenizer( fgsProps.getProperty("fedoragsearch.repositoryNames")); while (repositoryNames.hasMoreTokens()) { String repositoryName = repositoryNames.nextToken(); if (defaultRepositoryName == null) defaultRepositoryName = repositoryName; try { InputStream propStream = null; try { propStream = getResourceInputStream("/repository/" + repositoryName + "/repository.properties"); } catch (ConfigException e) { errors.append("\n" + e.getMessage()); } Properties props = new Properties(); props.load(propStream); propStream.close(); //MIH convertProperties(props); if (logger.isInfoEnabled()) logger.info(configName + "/repository/" + repositoryName + "/repository.properties=" + props.toString()); repositoryNameToProps.put(repositoryName, props); } catch (IOException e) { errors.append("\n*** Error loading " + configName + "/repository/" + repositoryName + ".properties:\n" + e.toString()); } } // Get index properties indexNameToProps = new Hashtable(); indexNameToUriResolvers = new Hashtable(); defaultIndexName = null; StringTokenizer indexNames = new StringTokenizer(fgsProps.getProperty("fedoragsearch.indexNames")); while (indexNames.hasMoreTokens()) { String indexName = indexNames.nextToken(); if (defaultIndexName == null) defaultIndexName = indexName; try { InputStream propStream = null; try { propStream = getResourceInputStream("/index/" + indexName + "/index.properties"); } catch (ConfigException e) { errors.append("\n" + e.getMessage()); } Properties props = new Properties(); props = new Properties(); props.load(propStream); propStream.close(); //MIH convertProperties(props); if (logger.isInfoEnabled()) logger.info(configName + "/index/" + indexName + "/index.properties=" + props.toString()); indexNameToProps.put(indexName, props); } catch (IOException e) { errors.append("\n*** Error loading " + configName + "/index/" + indexName + "/index.properties:\n" + e.toString()); } } if (logger.isDebugEnabled()) logger.debug("config created configName=" + configName + " errors=" + errors.toString()); }
From source file:fll.scheduler.GreedySolver.java
/** * @param datafile the datafile for the schedule to solve * @throws ParseException/*from w ww . j a v a 2 s .com*/ * @throws InvalidParametersException */ public GreedySolver(final File datafile, final boolean optimize) throws IOException, ParseException, InvalidParametersException { this.datafile = datafile; this.optimize = optimize; if (this.optimize) { LOGGER.info("Optimization is turned on"); } final Properties properties = new Properties(); try (final Reader reader = new InputStreamReader(new FileInputStream(datafile), Utilities.DEFAULT_CHARSET)) { properties.load(reader); } if (LOGGER.isDebugEnabled()) { LOGGER.debug(properties.toString()); } this.solverParameters = new SolverParams(); this.solverParameters.load(properties); final List<String> parameterErrors = this.solverParameters.isValid(); if (!parameterErrors.isEmpty()) { throw new InvalidParametersException(parameterErrors); } subjectiveAttemptOffset = solverParameters.getSubjectiveAttemptOffsetMinutes(); numTimeslots = (solverParameters.getTMaxHours() * 60 + solverParameters.getTMaxMinutes()); performanceDuration = this.solverParameters.getPerformanceMinutes(); changetime = this.solverParameters.getChangetimeMinutes(); performanceChangetime = this.solverParameters.getPerformanceChangetimeMinutes(); sz = new boolean[solverParameters.getNumGroups()][][][]; sy = new boolean[solverParameters.getNumGroups()][][][]; pz = new boolean[solverParameters.getNumGroups()][][][][]; py = new boolean[solverParameters.getNumGroups()][][][][]; subjectiveScheduled = new boolean[solverParameters.getNumGroups()][][]; subjectiveStations = new int[solverParameters.getNumGroups()][getNumSubjectiveStations()]; performanceScheduled = new int[solverParameters.getNumGroups()][]; final List<Integer> performanceOffsets = new ArrayList<Integer>(); performanceOffsets.addAll(solverParameters.getPerformanceAttemptOffsetMinutes()); for (int table = 0; table < solverParameters.getNumTables(); ++table) { int timeslot; // determine the first timeslot for the table if (solverParameters.getAlternateTables()) { // even is 0, odd is 1/2 performance duration if ((table & 1) == 1) { timeslot = performanceDuration / 2; } else { timeslot = 0; } LOGGER.debug("Setting table " + table + " start to " + timeslot); } else { timeslot = 0; } // compute all possible performance time slots for the table List<Integer> possibleTimeSlots = new LinkedList<>(); int perfOffsetIndex = 0; while (timeslot < getNumTimeslots()) { possibleTimeSlots.add(timeslot); final int perfOffset = performanceOffsets.get(perfOffsetIndex); timeslot += perfOffset; // cycle through the pattern for performance offset ++perfOffsetIndex; if (perfOffsetIndex >= performanceOffsets.size()) { perfOffsetIndex = 0; } } performanceTables.put(table, possibleTimeSlots); } final Map<String, Integer> judgingGroups = solverParameters.getJudgingGroups(); int group = 0; groupNames = new String[judgingGroups.size()]; for (final Map.Entry<String, Integer> entry : judgingGroups.entrySet()) { final int count = entry.getValue(); groupNames[group] = entry.getKey(); sz[group] = new boolean[count][getNumSubjectiveStations()][getNumTimeslots()]; sy[group] = new boolean[count][getNumSubjectiveStations()][getNumTimeslots()]; pz[group] = new boolean[count][solverParameters.getNumTables()][2][getNumTimeslots()]; py[group] = new boolean[count][solverParameters.getNumTables()][2][getNumTimeslots()]; subjectiveScheduled[group] = new boolean[count][getNumSubjectiveStations()]; for (int team = 0; team < count; ++team) { teams.add(new SchedTeam(team, group)); for (int station = 0; station < getNumSubjectiveStations(); ++station) { Arrays.fill(sz[group][team][station], false); Arrays.fill(sy[group][team][station], false); } for (int table = 0; table < solverParameters.getNumTables(); ++table) { Arrays.fill(pz[group][team][table][0], false); Arrays.fill(pz[group][team][table][1], false); Arrays.fill(py[group][team][table][0], false); Arrays.fill(py[group][team][table][1], false); } Arrays.fill(subjectiveScheduled[group][team], false); Arrays.fill(subjectiveStations[group], 0); } // foreach team in a judging group performanceScheduled[group] = new int[count]; Arrays.fill(performanceScheduled[group], 0); ++group; } // foreach judging group populatePerfEarliestTimes(); // sort list of teams to make sure that the scheduler is deterministic Collections.sort(teams, lowestTeamIndex); }
From source file:org.apache.openaz.xacml.rest.XACMLPapServlet.java
/** * Called by: - PDP nodes to register themselves with the PAP, and - Admin Console to make changes in the * PDP Groups.// ww w . j ava 2s . c o m * * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { XACMLRest.dumpRequest(request); // since getParameter reads the content string, explicitly get the content before doing that. // Simply getting the inputStream seems to protect it against being consumed by getParameter. request.getInputStream(); // // Is this from the Admin Console? // String groupId = request.getParameter("groupId"); if (groupId != null) { // // this is from the Admin Console, so handle separately // doACPost(request, response, groupId); return; } // // Request is from a PDP. // It is coming up and asking for its config // // // Get the PDP's ID // String id = this.getPDPID(request); logger.info("doPost from: " + id); // // Get the PDP Object // PDP pdp = this.papEngine.getPDP(id); // // Is it known? // if (pdp == null) { logger.info("Unknown PDP: " + id); try { this.papEngine.newPDP(id, this.papEngine.getDefaultGroup(), id, "Registered on first startup"); } catch (NullPointerException | PAPException e) { logger.error("Failed to create new PDP", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); return; } // get the PDP we just created pdp = this.papEngine.getPDP(id); if (pdp == null) { String message = "Failed to create new PDP for id: " + id; logger.error(message); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message); return; } } // // Get the PDP's Group // PDPGroup group = this.papEngine.getPDPGroup(pdp); if (group == null) { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "PDP not associated with any group, even the default"); return; } // // Determine what group the PDP node is in and get // its policy/pip properties. // Properties policies = group.getPolicyProperties(); Properties pipconfig = group.getPipConfigProperties(); // // Get the current policy/pip configuration that the PDP has // Properties pdpProperties = new Properties(); pdpProperties.load(request.getInputStream()); logger.info("PDP Current Properties: " + pdpProperties.toString()); logger.info("Policies: " + (policies != null ? policies.toString() : "null")); logger.info("Pip config: " + (pipconfig != null ? pipconfig.toString() : "null")); // // Validate the node's properties // boolean isCurrent = this.isPDPCurrent(policies, pipconfig, pdpProperties); // // Send back current configuration // if (!isCurrent) { // // Tell the PDP we are sending back the current policies/pip config // logger.info("PDP configuration NOT current."); if (policies != null) { // // Put URL's into the properties in case the PDP needs to // retrieve them. // this.populatePolicyURL(request.getRequestURL(), policies); // // Copy the properties to the output stream // policies.store(response.getOutputStream(), ""); } if (pipconfig != null) { // // Copy the properties to the output stream // pipconfig.store(response.getOutputStream(), ""); } // // We are good - and we are sending them information // response.setStatus(HttpServletResponse.SC_OK); // TODO - Correct? setPDPSummaryStatus(pdp, PDPStatus.Status.OUT_OF_SYNCH); } else { // // Tell them they are good // response.setStatus(HttpServletResponse.SC_NO_CONTENT); // TODO - Correct? setPDPSummaryStatus(pdp, PDPStatus.Status.UP_TO_DATE); } // // tell the AC that something changed // notifyAC(); } catch (PAPException e) { logger.debug("POST exception: " + e, e); response.sendError(500, e.getMessage()); return; } }
From source file:org.apache.stratos.messaging.broker.publish.TopicPublisher.java
private void doPublish(String message, Properties headers) throws Exception, JMSException { if (!initialized) { // Initialize a topic connection to the message broker connector.init(getName());// ww w.j ava2 s. c om initialized = true; if (log.isDebugEnabled()) { log.debug(String.format("Topic publisher connector initialized: [topic] %s", getName())); } } try { // Create a new session topicSession = createSession(connector); if (log.isDebugEnabled()) { log.debug(String.format("Topic publisher session created: [topic] %s", getName())); } // Create a publisher from session topicPublisher = createPublisher(topicSession); if (log.isDebugEnabled()) { log.debug(String.format("Topic publisher created: [topic] %s", getName())); } // Create text message TextMessage textMessage = topicSession.createTextMessage(message); if (headers != null) { // Add header properties @SuppressWarnings("rawtypes") Enumeration e = headers.propertyNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); textMessage.setStringProperty(key, headers.getProperty(key)); } } topicPublisher.publish(textMessage); if (log.isDebugEnabled()) { log.debug(String.format("Message published: [topic] %s [header] %s [body] %s", getName(), (headers != null) ? headers.toString() : "null", message)); } } finally { if (topicPublisher != null) { topicPublisher.close(); if (log.isDebugEnabled()) { log.debug(String.format("Topic publisher closed: [topic] %s", getName())); } } if (topicSession != null) { topicSession.close(); if (log.isDebugEnabled()) { log.debug(String.format("Topic publisher session closed: [topic] %s", getName())); } } } }
From source file:de.fhg.fokus.odp.portal.managedatasets.controller.ManageController.java
/** * Inits the.//from ww w.java 2s . co m * */ @PostConstruct private void init() { LiferayFacesContext lfc = LiferayFacesContext.getInstance(); PortletRequest request = (PortletRequest) lfc.getExternalContext().getRequest(); ThemeDisplay td = lfc.getThemeDisplay(); Properties props = new Properties(); if (metadataController.getMetadata().getType().equals(MetadataEnumType.APPLICATION)) { props.setProperty("ckan.authorization.key", PropsUtil.get("authenticationKeyApps")); } else { props.setProperty("ckan.authorization.key", PropsUtil.get("authenticationKey")); } props.setProperty("ckan.url", PropsUtil.get("cKANurl")); LOG.debug("odRClient props:" + props.toString()); odrClient = OpenDataRegistry.getClient(); odrClient.init(props); redakteur = false; try { for (Role role : RoleLocalServiceUtil.getUserRoles(td.getUserId())) { if (role.getName().equals("Redakteur") && RoleLocalServiceUtil.hasUserRole(role.getRoleId(), td.getUserId())) { redakteur = true; } } } catch (SystemException e) { LOG.error(e.getMessage(), e); } selectedTags = new ArrayList<String>(); selectedCategories = new ArrayList<String>(); selectedManyCategories = new ArrayList<String>(); licences = new ArrayList<Licence>(); /* * Sets caption according to create/edit metadata for * dataset/app/document */ if (metadataController.getMetadata().getTitle() == null || metadataController.getMetadata().getTitle().isEmpty()) { /* * Create */ author = metadataController.getMetadata().newContact(RoleEnumType.AUTHOR); maintainer = metadataController.getMetadata().newContact(RoleEnumType.MAINTAINER); distributor = metadataController.getMetadata().newContact(RoleEnumType.DISTRIBUTOR); editMode = false; LicenceBean lb = new LicenceBean(); Licence emptyLicence = new LicenceImpl(lb); metadataController.getMetadata().setLicence(emptyLicence); emptyLicence.setTitle(LanguageUtil.get(request.getLocale(), "od.licence.select")); licences.add(emptyLicence); if (metadataController.getMetadata().getType().equals(MetadataEnumType.DATASET) || metadataController.getMetadata().getType().equals(MetadataEnumType.UNKNOWN)) { metadataController.getMetadata().newResource(); caption = LanguageUtil.get(request.getLocale(), "od.create.metadata.data"); submitquestion = LanguageUtil.get(request.getLocale(), "od.create.metadata.data.submit"); metadataType = "dataset"; } else if (metadataController.getMetadata().getType().equals(MetadataEnumType.APPLICATION)) { caption = LanguageUtil.get(request.getLocale(), "od.create.metadata.app"); submitquestion = LanguageUtil.get(request.getLocale(), "od.create.metadata.app.submit"); metadataType = "app"; usedDatasetUris = new ArrayList<String>(); } else if (metadataController.getMetadata().getType().equals(MetadataEnumType.DOCUMENT)) { metadataController.getMetadata().newResource(); caption = LanguageUtil.get(request.getLocale(), "od.create.metadata.document"); submitquestion = LanguageUtil.get(request.getLocale(), "od.create.metadata.document.submit"); metadataType = "document"; } } else { /* * Edit */ try { for (Contact contact : metadataController.getMetadata().getContacts()) { if (contact.getRole().equals(RoleEnumType.AUTHOR)) { author = contact; } else if (contact.getRole().equals(RoleEnumType.MAINTAINER)) { maintainer = contact; } else if (contact.getRole().equals(RoleEnumType.DISTRIBUTOR)) { distributor = contact; } else if (contact.getRole().equals(RoleEnumType.PUBLISHER)) { LOG.info("Handle metadata contact PUBLISHER [" + contact.getName() + "] now as AUTHOR"); } } } catch (OpenDataRegistryException e) { LOG.error("Contact role", e); } finally { metadataController.getMetadata().getContacts().clear(); } if (author == null) { author = metadataController.getMetadata().newContact(RoleEnumType.AUTHOR); } if (maintainer == null) { maintainer = metadataController.getMetadata().newContact(RoleEnumType.MAINTAINER); } if (distributor == null) { distributor = metadataController.getMetadata().newContact(RoleEnumType.DISTRIBUTOR); } editMode = true; selectedLicence = metadataController.getMetadata().getLicence().getName(); unknownLicenceText = metadataController.getMetadata().getLicence().getTitle(); unknownLicenceUrl = metadataController.getMetadata().getLicence().getUrl(); for (Tag t : metadataController.getMetadata().getTags()) { selectedTags.add(t.getName()); } for (Category c : metadataController.getMetadata().getCategories()) { selectedCategories.add(c.getName()); selectedManyCategories.add(c.getName()); } submitquestion = LanguageUtil.get(request.getLocale(), "od.edit.any.data.save.changes"); if (metadataController.getMetadata().getType().equals(MetadataEnumType.DATASET) || metadataController.getMetadata().getType().equals(MetadataEnumType.UNKNOWN)) { caption = LanguageUtil.get(request.getLocale(), "od.edit.metadata.data"); metadataType = "dataset"; } else if (metadataController.getMetadata().getType().equals(MetadataEnumType.APPLICATION)) { caption = LanguageUtil.get(request.getLocale(), "od.edit.metadata.app"); metadataType = "app"; usedDatasetUris = ((Application) metadataController.getMetadata()).getUsedDatasets(); if (((Application) metadataController.getMetadata()).getUsedDatasets().size() < 1) { } } else if (metadataController.getMetadata().getType().equals(MetadataEnumType.DOCUMENT)) { caption = LanguageUtil.get(request.getLocale(), "od.edit.metadata.document"); metadataType = "document"; } unknownLicence = unknownLicence(metadataController.getMetadata().getLicence().getName()); } /* * Fill licences accordingly to the metadata type: dataset, app, * document */ if (metadataController.getMetadata().getType().equals(MetadataEnumType.DATASET) || metadataController.getMetadata().getType().equals(MetadataEnumType.UNKNOWN)) { for (Licence licence : odrClient.listLicenses()) { if (licence.isDomainData()) { licences.add(licence); } } } else if (metadataController.getMetadata().getType().equals(MetadataEnumType.APPLICATION)) { for (Licence licence : odrClient.listLicenses()) { if (licence.isDomainSoftware()) { licences.add(licence); } } } else if (metadataController.getMetadata().getType().equals(MetadataEnumType.DOCUMENT)) { for (Licence licence : odrClient.listLicenses()) { if (licence.isDomainContent()) { licences.add(licence); } } } /* Mark restricted licences */ for (Licence licence : licences) { if (!licence.isOpen() && !licence.getTitle().equals(LanguageUtil.get(request.getLocale(), "od.licence.select"))) { licence.setTitle( LanguageUtil.get(request.getLocale(), "od.restricted").toUpperCase(request.getLocale()) + " - " + licence.getTitle()); } } categories = new ArrayList<Category>(); List<Category> cats = odrClient.listCategories(); for (Category c : cats) { if ("group".equals(c.getType())) { categories.add(c); } } sectors = new ArrayList<SectorEnumType>(); for (SectorEnumType sector : SectorEnumType.values()) { sectors.add(sector); } geoGranularities = new ArrayList<GeoGranularityEnumType>(); for (GeoGranularityEnumType geoType : GeoGranularityEnumType.values()) { geoGranularities.add(geoType); } temporalGranularityEnumTypes = new ArrayList<TemporalGranularityEnumType>(); for (TemporalGranularityEnumType t : TemporalGranularityEnumType.values()) { temporalGranularityEnumTypes.add(t); } }
From source file:fll.scheduler.SchedulerUI.java
private void loadScheduleDescription(final File file) { final Properties properties = new Properties(); try (final Reader reader = new InputStreamReader(new FileInputStream(file), Utilities.DEFAULT_CHARSET)) { properties.load(reader);/* w w w.j ava2 s . c o m*/ } catch (final IOException e) { final Formatter errorFormatter = new Formatter(); errorFormatter.format("Error loading file: %s", e.getMessage()); LOGGER.error(errorFormatter, e); JOptionPane.showMessageDialog(SchedulerUI.this, errorFormatter, "Error loading file", JOptionPane.ERROR_MESSAGE); return; } if (LOGGER.isDebugEnabled()) { LOGGER.debug(properties.toString()); } try { final SolverParams params = new SolverParams(); params.load(properties); mScheduleDescriptionEditor.setParams(params); } catch (final ParseException pe) { final Formatter errorFormatter = new Formatter(); errorFormatter.format("Error parsing file: %s", pe.getMessage()); LOGGER.error(errorFormatter, pe); JOptionPane.showMessageDialog(SchedulerUI.this, errorFormatter, "Error parsing file", JOptionPane.ERROR_MESSAGE); return; } mScheduleDescriptionFile = file; mDescriptionFilename.setText(file.getName()); }
From source file:com.att.android.arodatacollector.main.AROCollectorService.java
/** * Sample file content: FLURRY_API_KEY=YKN7M4TDXRKXH97PX565 * Each Flurry API Key corresponds to an Application on Flurry site. It is absolutely * necessary that the Flurry API Key-value from user's device is correct in order to log to the Flurry application. * /* w w w . jav a2s .c o m*/ * No validation on the API key allows creation of a new Flurry application by client at any time * The API key is communicated to the user group who would put the API key name-value pair into * properties file specified by variable flurryFileName below. * * If no key-value is found, the default API key is used below. Default is intended for users of * ATT Developer Program. */ private void setFlurryApiKey() { if (DEBUG) { Log.d(TAG, "entered setFlurryApiKey"); } final String flurryFileName = ARODataCollector.ARO_TRACE_ROOTDIR + ARODataCollector.FLURRY_API_KEY_REL_PATH; InputStream flurryFileReaderStream = null; try { final ClassLoader loader = ClassLoader.getSystemClassLoader(); flurryFileReaderStream = loader.getResourceAsStream(flurryFileName); Properties prop = new Properties(); try { if (flurryFileReaderStream != null) { prop.load(flurryFileReaderStream); mApp.app_flurry_api_key = prop.containsKey(ARODataCollector.FLURRY_API_KEY_NAME) && !prop.getProperty(ARODataCollector.FLURRY_API_KEY_NAME) .equals(AROCollectorUtils.EMPTY_STRING) ? prop.getProperty(ARODataCollector.FLURRY_API_KEY_NAME).trim() : mApp.app_flurry_api_key; if (DEBUG) { Log.d(TAG, "flurry Property String: " + prop.toString()); Log.d(TAG, "flurry app_flurry_api_key: " + mApp.app_flurry_api_key); } } else { if (DEBUG) { Log.d(TAG, "flurryFileReader stream is null. Using default: " + mApp.app_flurry_api_key); } } } catch (IOException e) { Log.d(TAG, e.getClass().getName() + " thrown trying to load file "); } } finally { try { if (flurryFileReaderStream != null) { flurryFileReaderStream.close(); } } catch (IOException e) { //log and exit method-nothing else to do. if (DEBUG) { Log.d(TAG, "setFlurryApiKey method reached catch in finally method, trying to close flurryFileReader"); } } Log.d(TAG, "exiting setFlurryApiKey"); } }