org.codehaus.jackson.map.type.CollectionType Java Examples
The following examples show how to use
org.codehaus.jackson.map.type.CollectionType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserManager.java From query2report with GNU General Public License v3.0 | 6 votes |
private void init(){ logger.info("Initializing user manager from "+new File(fileName).getAbsolutePath()); try { ObjectMapper objectMapper = new ObjectMapper(); TypeFactory typeFactory = objectMapper.getTypeFactory(); CollectionType collectionType = typeFactory.constructCollectionType(Set.class, User.class); users = objectMapper.readValue(new File(fileName), collectionType); } catch (IOException e) { logger.error("Unable to initialize user manager",e); } if(users == null || users.isEmpty()){ logger.info("Adding default admin user"); String encPassword = EncryptionUtil.encrypt("admin"); User adminUser = new User("Administrator","admin",encPassword,"admin",DashboardConstants.HTML_GOOGLE); users.add(adminUser); } }
Example #2
Source File: TestSwiftFileSystemDirectories.java From sahara-extra with Apache License 2.0 | 6 votes |
private String[] getRawObjectNames() throws Exception { SwiftRestClient client; client = SwiftRestClient.getInstance(fs.getUri(), fs.getConf()); SwiftObjectPath path = SwiftObjectPath.fromPath(fs.getUri(), new Path("/")); byte[] bytes = client.listDeepObjectsInDirectory(path, true, true); final CollectionType collectionType = JSONUtil.getJsonMapper(). getTypeFactory().constructCollectionType(List.class, SwiftObjectFileStatus.class); final List<SwiftObjectFileStatus> fileStatusList = JSONUtil.toObject(new String(bytes), collectionType); final ArrayList<String> objects = new ArrayList(); for (SwiftObjectFileStatus status : fileStatusList) { if (status.getName() != null) { objects.add(status.getName()); } else if (status.getSubdir() != null) { objects.add(status.getSubdir()); } } return objects.toArray(new String[objects.size()]); }
Example #3
Source File: ConnectionManager.java From query2report with GNU General Public License v3.0 | 5 votes |
private void init(){ logger.info("Initializing connection manager from "+new File(fileName).getAbsolutePath()); try { ObjectMapper objectMapper = new ObjectMapper(); TypeFactory typeFactory = objectMapper.getTypeFactory(); CollectionType collectionType = typeFactory.constructCollectionType(Set.class, ConnectionParams.class); connParams = objectMapper.readValue(new File(fileName), collectionType); } catch (IOException e) { logger.error("Unable to initialize connection manager",e); } }
Example #4
Source File: DriverManager.java From query2report with GNU General Public License v3.0 | 5 votes |
private void init(){ logger.info("Initializing driver manager from "+new File(fileName).getAbsolutePath()); try { ObjectMapper objectMapper = new ObjectMapper(); TypeFactory typeFactory = objectMapper.getTypeFactory(); CollectionType collectionType = typeFactory.constructCollectionType(Set.class, DriverParams.class); driverParams = objectMapper.readValue(new File(fileName), collectionType); } catch (IOException e) { logger.error("Unable to initialize driver manager",e); } }
Example #5
Source File: ReportManager.java From query2report with GNU General Public License v3.0 | 5 votes |
private void init(String userName) { String dirName = DashboardConstants.PUBLIC_REPORT_DIR; if(!userName.equalsIgnoreCase(DashboardConstants.PUBLIC_USER)) dirName = DashboardConstants.PRIVATE_REPORT_DIR+userName; logger.debug("Initializing report manager for user "+userName+" from "+new File(dirName).getAbsolutePath()); Map<String,Report> reportMap = new LinkedHashMap<String,Report>(); File dir = new File(dirName); dir.mkdirs(); String reportFiles[] = dir.list(); if(reportFiles == null || reportFiles.length==0){ logger.warn("Got 0 reports for user "+userName); return; } logger.debug("Got "+reportFiles.length+" reports for user "+userName); for(String reportFile : reportFiles){ File f = new File(reportFile); if(f.isDirectory() || reportFile.equalsIgnoreCase("schedule")) continue; try { File fn = new File(dir.getAbsolutePath()+File.separatorChar+reportFile); logger.info("Loading report template from file '"+fn.getAbsolutePath()+"'"); ObjectMapper objectMapper = new ObjectMapper(); TypeFactory typeFactory = objectMapper.getTypeFactory(); CollectionType collectionType = typeFactory.constructCollectionType(Set.class, Report.class); Set<Report> reports = objectMapper.readValue(fn, collectionType); for (Report report : reports) reportMap.put(report.getTitle(), report); } catch (IOException e) { logger.error("Error while loading report from template "+dir.getAbsoluteFile(),e); } } userReportMap.put(userName, reportMap); }