List of usage examples for java.util HashMap containsKey
public boolean containsKey(Object key)
From source file:com.krawler.spring.profileHandler.profileHandlerDAOImpl.java
public KwlReturnObject changePassword(HashMap<String, Object> requestParams) throws ServiceException { JSONObject jobj = new JSONObject(); String password = ""; String userid = ""; String companyid = ""; String pwd = ""; String msg = ""; String platformURL = ""; List ll = new ArrayList(); int dl = 0;//from w w w . j a va 2s . com boolean isSuccess = false; try { if (requestParams.containsKey("currentpassword") && requestParams.get("currentpassword") != null) { password = requestParams.get("currentpassword").toString(); } if (requestParams.containsKey("userid") && requestParams.get("userid") != null) { userid = requestParams.get("userid").toString(); } if (requestParams.containsKey("companyid") && requestParams.get("companyid") != null) { companyid = requestParams.get("companyid").toString(); } if (requestParams.containsKey("changepassword") && requestParams.get("changepassword") != null) { pwd = requestParams.get("changepassword").toString(); } if (requestParams.containsKey("platformURL") && requestParams.get("platformURL") != null) { platformURL = requestParams.get("platformURL").toString(); } if (password == null || password.length() <= 0) { msg = "Invalid Password"; } else { if (!StringUtil.isNullOrEmpty(platformURL)) { JSONObject userData = new JSONObject(); userData.put("pwd", pwd); userData.put("oldpwd", password); userData.put("userid", userid); userData.put("remoteapikey", storageHandlerImpl.GetRemoteAPIKey()); String action = "3"; JSONObject resObj = apiCallHandlerService.callApp(platformURL, userData, companyid, action, true); if (!resObj.isNull("success") && resObj.getBoolean("success")) { User user = (User) get(User.class, userid); UserLogin userLogin = user.getUserLogin(); userLogin.setPassword(pwd); saveOrUpdate(userLogin); msg = "Password Changed Successfully"; isSuccess = true; } else { if (resObj.has("errorcode") && resObj.get("errorcode").equals("e12")) { msg = "This is a Demo account. You do not have sufficient permissions to edit this field."; } else if (resObj.has("errorcode") && resObj.get("errorcode").equals("e10")) { msg = "Old password is incorrect. Please try again."; } else { msg = "Error in changing Password"; } } } else { User user = (User) get(User.class, userid); UserLogin userLogin = user.getUserLogin(); String currentpass = userLogin.getPassword(); if (StringUtil.equal(password, currentpass)) { userLogin.setPassword(pwd); saveOrUpdate(userLogin); msg = "Password Changed Successfully"; } else { msg = "Old password is incorrect. Please try again."; } } } jobj.put("msg", msg); ll.add(jobj); } catch (Exception e) { throw ServiceException.FAILURE("ProfileHandler.changePassword", e); } return new KwlReturnObject(isSuccess, KWLErrorMsgs.S01, "", ll, dl); }
From source file:com.microsoft.alm.plugin.idea.git.ui.vcsimport.ImportPageModelImpl.java
private boolean projectSupportsGitRepos(final Project project, final ServerContext localContext, final ProgressIndicator indicator) { if (localContext.getType() != ServerContext.Type.TFS) { return true; //VSO - team services supports hybrid projects, so git and tfvc are both supported }//from w w w . j a va 2 s. co m //TFS on premise server final CoreHttpClient client = new CoreHttpClient(localContext.getClient(), localContext.getCollectionURI()); final TeamProject tp = client.getProject(localContext.getTeamProjectReference().getId().toString(), true); HashMap<String, HashMap<String, String>> capabilities = tp.getCapabilities(); //TODO: make the containsKey and get case insensitive if (capabilities != null && capabilities.containsKey(PROJECT_CAPABILITY_VC)) { final HashMap<String, String> vcCapabilities = capabilities.get(PROJECT_CAPABILITY_VC); if (vcCapabilities != null && vcCapabilities.containsKey(PROJECT_CAPABILITY_VC_TYPE)) { final String sourceControlType = vcCapabilities.get(PROJECT_CAPABILITY_VC_TYPE); if (StringUtils.equalsIgnoreCase(sourceControlType, PROJECT_CAPABILITY_VC_GIT)) { //sourceControlType=git, so git is supported return true; } } } // Capability sourceControlType=TFvc, we are not sure if hybrid projects are supported or not on this server // Hybrid projects were introduced in TFS 2015 Update1 // They are not officially supported by TFS 2015 RTM, creating repo will succeed but web access does not show the git repos // warn user to verify their project is a hybrid project final List<String> proceed = new ArrayList<String>(); IdeaHelper.runOnUIThread(new Runnable() { @Override public void run() { final boolean response = IdeaHelper.showConfirmationDialog(project, TfPluginBundle.message(TfPluginBundle.KEY_IMPORT_TEAM_PROJECT_GIT_SUPPORT, tp.getName()), TfPluginBundle.message(TfPluginBundle.KEY_IMPORT_DIALOG_TITLE), Icons.VSLogo, TfPluginBundle.message(TfPluginBundle.KEY_IMPORT_PROCEED), TfPluginBundle.message(TfPluginBundle.KEY_IMPORT_CANCEL)); if (response) { proceed.add("true"); } } }, true, indicator.getModalityState()); if (proceed.size() == 0) { //user chose to cancel import logger.warn("projectSupportsGitRepos: User chose to cancel import into team project: {}", localContext.getTeamProjectReference().getName()); notifyImportError(project, TfPluginBundle.message(TfPluginBundle.KEY_IMPORT_CANCELED), TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_IMPORT), localContext); return false; } return true; }
From source file:com.krawler.spring.documents.documentDAOImpl.java
public KwlReturnObject addTag(HashMap<String, Object> requestParams) throws ServiceException { String tag = requestParams.containsKey("tag") ? requestParams.get("tag").toString() : ""; List ll = new ArrayList(); int dl = 0;//from w w w.j a va 2 s . c om try { String tags[] = tag.split(",,"); Docs c = (Docs) get(Docs.class, tags[0]); c.setTags(tags[1]); ll.add(c); } catch (Exception ex) { throw ServiceException.FAILURE("documentDAOImpl.addTag", ex); } return new KwlReturnObject(true, KWLErrorMsgs.S01, "", ll, dl); }
From source file:com.krawler.spring.profileHandler.profileHandlerDAOImpl.java
public KwlReturnObject saveUser(HashMap<String, Object> requestParams) throws ServiceException { String id = ""; String dateid = ""; User user = null;/*from w w w. j a va2s. c o m*/ UserLogin userLogin = null; String pwd = null; boolean userLoginFlag = false; List ll = new ArrayList(); try { if (requestParams.containsKey("addUser") && (Boolean) requestParams.get("addUser")) { String userID = UUID.randomUUID().toString(); if (requestParams.containsKey("userid") && requestParams.get("userid") != null) { userID = requestParams.get("userid").toString(); } user = new User(); userLogin = new UserLogin(); userLogin.setUserID(userID); userLogin.setUserName((String) requestParams.get("username")); if (requestParams.containsKey("password") && requestParams.get("password") != null) { userLogin.setPassword(requestParams.get("password").toString()); } else { pwd = authHandler.generateNewPassword(); userLogin.setPassword(authHandler.getSHA1(pwd)); } userLoginFlag = true; user.setUserLogin(userLogin); } else { if (requestParams.containsKey("userid") && requestParams.get("userid") != null) { id = requestParams.get("userid").toString(); user = (User) get(User.class, id); if (requestParams.containsKey("userlogin") && requestParams.get("userlogin") != null) { String userLoginId = requestParams.get("userlogin").toString(); user.setUserLogin((UserLogin) get(UserLogin.class, userLoginId)); } } } if (requestParams.containsKey("dateformat") && requestParams.get("dateformat") != null) { dateid = requestParams.get("dateformat").toString(); user.setDateFormat((KWLDateFormat) get(KWLDateFormat.class, dateid)); } if (requestParams.containsKey("image") && requestParams.get("image") != null) { String imageName = requestParams.get("image").toString(); if (imageName != null && imageName.length() > 0) { try { String fileName = user.getUserID() + FileUploadHandler.getImageExt(); user.setImage(com.krawler.common.util.Constants.ImgBasePath + fileName); new FileUploadHandler().uploadImage((FileItem) requestParams.get("image"), fileName, storageHandlerImpl.GetProfileImgStorePath(), 100, 100, false, false); } catch (Exception e) { } } } if (requestParams.containsKey("firstName") && requestParams.get("firstName") != null) { String firstName = requestParams.get("firstName").toString(); user.setFirstName(firstName); } if (requestParams.containsKey("lastName") && requestParams.get("lastName") != null) { String lastName = requestParams.get("lastName").toString(); user.setLastName(lastName); } if (requestParams.containsKey("role") && requestParams.get("role") != null) { String role = requestParams.get("role").toString(); user.setRoleID(role); } if (requestParams.containsKey("emailID") && requestParams.get("emailID") != null) { String emailID = requestParams.get("emailID").toString(); user.setEmailID(emailID); } if (requestParams.containsKey("address") && requestParams.get("address") != null) { String address = requestParams.get("address").toString(); user.setAddress(address); } if (requestParams.containsKey("designation") && requestParams.get("designation") != null) { String designation = requestParams.get("designation").toString(); user.setDesignation(designation); } if (requestParams.containsKey("contactNumber") && requestParams.get("contactNumber") != null) { String contactNumber = requestParams.get("contactNumber").toString(); user.setContactNumber(contactNumber); } if (requestParams.containsKey("aboutUser") && requestParams.get("aboutUser") != null) { String aboutUser = requestParams.get("aboutUser").toString(); user.setAboutUser(aboutUser); } if (requestParams.containsKey("userStatus") && requestParams.get("userStatus") != null) { String userStatus = requestParams.get("userStatus").toString(); user.setUserStatus(userStatus); } if (requestParams.containsKey("timeZone") && requestParams.get("timeZone") != null) { String timeZone = requestParams.get("timeZone").toString(); user.setTimeZone((KWLTimeZone) get(KWLTimeZone.class, timeZone)); } if (requestParams.containsKey("company") && requestParams.get("company") != null) { String company = requestParams.get("company").toString(); user.setCompany((Company) get(Company.class, company)); } if (requestParams.containsKey("fax") && requestParams.get("fax") != null) { String fax = requestParams.get("fax").toString(); user.setFax(fax); } if (requestParams.containsKey("alternateContactNumber") && requestParams.get("alternateContactNumber") != null) { String alternateContactNumber = requestParams.get("alternateContactNumber").toString(); user.setAlternateContactNumber(alternateContactNumber); } if (requestParams.containsKey("phpBBID") && requestParams.get("phpBBID") != null) { int phpBBID = Integer.parseInt(requestParams.get("phpBBID").toString()); user.setPhpBBID(phpBBID); } if (requestParams.containsKey("panNumber") && requestParams.get("panNumber") != null) { String panNumber = requestParams.get("panNumber").toString(); user.setPanNumber(panNumber); } if (requestParams.containsKey("ssnNumber") && requestParams.get("ssnNumber") != null) { String ssnNumber = requestParams.get("ssnNumber").toString(); user.setSsnNumber(ssnNumber); } if (requestParams.containsKey("dateFormat") && requestParams.get("dateFormat") != null) { String dateFormat = requestParams.get("dateFormat").toString(); user.setDateFormat((KWLDateFormat) get(KWLDateFormat.class, dateFormat)); } if (requestParams.containsKey("timeformat") && requestParams.get("timeformat") != null) { int timeformat = Integer.parseInt(requestParams.get("timeformat").toString()); user.setTimeformat(timeformat); } if (requestParams.containsKey("createdon") && requestParams.get("createdon") != null) { Date created = (Date) requestParams.get("createdon"); user.setCreatedon(created); } else { user.setCreatedon(new Date()); } if (requestParams.containsKey("updatedon") && requestParams.get("updatedon") != null) { Date updatedon = (Date) requestParams.get("updatedon"); user.setUpdatedon(updatedon); } else { user.setUpdatedon(new Date()); } if (requestParams.containsKey("deleteflag") && requestParams.get("deleteflag") != null) { int deleteflag = Integer.parseInt(requestParams.get("deleteflag").toString()); user.setDeleteflag(deleteflag); } if (requestParams.containsKey("helpflag") && requestParams.get("helpflag") != null) { int helpflag = Integer.parseInt(requestParams.get("helpflag").toString()); user.setHelpflag(helpflag); } if (requestParams.containsKey("callwith") && requestParams.get("callwith") != null) { int callwith = Integer.parseInt(requestParams.get("callwith").toString()); user.setCallwith(callwith); } if (requestParams.containsKey("userhash") && requestParams.get("userhash") != null) { String user_hash = requestParams.get("userhash").toString(); user.setUser_hash(user_hash); } if (requestParams.containsKey("user_id") && requestParams.get("user_id") != null) { Long userId = (Long) requestParams.get("user_id"); user.setUserId(userId); } if (requestParams.containsKey("notificationtype") && requestParams.get("notificationtype") != null) { Integer notificationType = (Integer) requestParams.get("notificationtype"); user.setNotificationtype(notificationType); } if (userLoginFlag) { save(userLogin); } save(user); ll.add(user); } catch (Exception e) { throw ServiceException.FAILURE("profileHandlerDAOImpl.saveUser", e); } return new KwlReturnObject(true, KWLErrorMsgs.S01, "", ll, 1); }
From source file:azkaban.project.JdbcProjectLoaderTest.java
private void assertUserPermissionsEqual(Project p1, Project p2) { List<Pair<String, Permission>> perm1 = p1.getUserPermissions(); List<Pair<String, Permission>> perm2 = p2.getUserPermissions(); Assert.assertEquals(perm1.size(), perm2.size()); {/*from w w w. j a v a 2s .c om*/ HashMap<String, Permission> perm1Map = new HashMap<String, Permission>(); for (Pair<String, Permission> p : perm1) { perm1Map.put(p.getFirst(), p.getSecond()); } for (Pair<String, Permission> p : perm2) { Assert.assertTrue(perm1Map.containsKey(p.getFirst())); Permission perm = perm1Map.get(p.getFirst()); Assert.assertEquals(perm, p.getSecond()); } } { HashMap<String, Permission> perm2Map = new HashMap<String, Permission>(); for (Pair<String, Permission> p : perm2) { perm2Map.put(p.getFirst(), p.getSecond()); } for (Pair<String, Permission> p : perm1) { Assert.assertTrue(perm2Map.containsKey(p.getFirst())); Permission perm = perm2Map.get(p.getFirst()); Assert.assertEquals(perm, p.getSecond()); } } }
From source file:azkaban.project.JdbcProjectLoaderTest.java
private void assertGroupPermissionsEqual(Project p1, Project p2) { List<Pair<String, Permission>> perm1 = p1.getGroupPermissions(); List<Pair<String, Permission>> perm2 = p2.getGroupPermissions(); Assert.assertEquals(perm1.size(), perm2.size()); {/*from www.ja v a2 s .c o m*/ HashMap<String, Permission> perm1Map = new HashMap<String, Permission>(); for (Pair<String, Permission> p : perm1) { perm1Map.put(p.getFirst(), p.getSecond()); } for (Pair<String, Permission> p : perm2) { Assert.assertTrue(perm1Map.containsKey(p.getFirst())); Permission perm = perm1Map.get(p.getFirst()); Assert.assertEquals(perm, p.getSecond()); } } { HashMap<String, Permission> perm2Map = new HashMap<String, Permission>(); for (Pair<String, Permission> p : perm2) { perm2Map.put(p.getFirst(), p.getSecond()); } for (Pair<String, Permission> p : perm1) { Assert.assertTrue(perm2Map.containsKey(p.getFirst())); Permission perm = perm2Map.get(p.getFirst()); Assert.assertEquals(perm, p.getSecond()); } } }
From source file:com.es.keyassistant.resolvers.Resolver0004.java
private void assignPropertiesTo(List<FileItem> formItems, DetectionInfo info) { HashMap<String, String> params = new HashMap<String, String>(); for (FileItem formItem : formItems) { if (formItem.isFormField()) { try { params.put(formItem.getFieldName(), formItem.getString("UTF-8")); } catch (UnsupportedEncodingException ex) { Logger.getLogger(Resolver0004.class.getName()).log(Level.SEVERE, null, ex); }/*w w w. ja v a2 s .c om*/ } } info.setDetectionOSVersion(params.get("androidVersion")); info.setDetectionPhoneId(params.get("identity")); info.setDetectionPhoneBrand(params.get("brand")); info.setDetectionPhoneModel(params.get("module")); info.setDetectionResult(ConvertUtility.parseInt(params.get("result"), -1)); info.setDetectionOS(params.containsKey("os") ? params.get("os") : "Android"); info.setDetectionDate(new Date()); }
From source file:eu.stratosphere.pact.runtime.task.DataSinkTaskTest.java
@Test public void testDataSinkTask() { int keyCnt = 100; int valCnt = 20; super.initEnvironment(MEMORY_MANAGER_SIZE, NETWORK_BUFFER_SIZE); super.addInput(new UniformRecordGenerator(keyCnt, valCnt, false), 0); DataSinkTask<Record> testTask = new DataSinkTask<Record>(); super.registerFileOutputTask(testTask, MockOutputFormat.class, new File(tempTestPath).toURI().toString()); try {//from ww w . j a va2s .com testTask.invoke(); } catch (Exception e) { LOG.debug(e); Assert.fail("Invoke method caused exception."); } File tempTestFile = new File(this.tempTestPath); Assert.assertTrue("Temp output file does not exist", tempTestFile.exists()); FileReader fr = null; BufferedReader br = null; try { fr = new FileReader(tempTestFile); br = new BufferedReader(fr); HashMap<Integer, HashSet<Integer>> keyValueCountMap = new HashMap<Integer, HashSet<Integer>>(keyCnt); while (br.ready()) { String line = br.readLine(); Integer key = Integer.parseInt(line.substring(0, line.indexOf("_"))); Integer val = Integer.parseInt(line.substring(line.indexOf("_") + 1, line.length())); if (!keyValueCountMap.containsKey(key)) { keyValueCountMap.put(key, new HashSet<Integer>()); } keyValueCountMap.get(key).add(val); } Assert.assertTrue("Invalid key count in out file. Expected: " + keyCnt + " Actual: " + keyValueCountMap.keySet().size(), keyValueCountMap.keySet().size() == keyCnt); for (Integer key : keyValueCountMap.keySet()) { Assert.assertTrue("Invalid value count for key: " + key + ". Expected: " + valCnt + " Actual: " + keyValueCountMap.get(key).size(), keyValueCountMap.get(key).size() == valCnt); } } catch (FileNotFoundException e) { Assert.fail("Out file got lost..."); } catch (IOException ioe) { Assert.fail("Caught IOE while reading out file"); } finally { if (br != null) { try { br.close(); } catch (Throwable t) { } } if (fr != null) { try { fr.close(); } catch (Throwable t) { } } } }
From source file:UserInterface.AuthorityWorkArea.DrugAnalysisJPanel.java
private void companiesPerfjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_companiesPerfjButtonActionPerformed HashMap<Integer, Integer> hashMap = new HashMap<Integer, Integer>(); int cmpId = 0; int counter = 0; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Authority authority = ecosystem.getAuthority(); for (WorkRequest wr : authority.getWorkQueue().getWorkRequestList()) { DrugApprovalRequest dar = (DrugApprovalRequest) wr; if (dar instanceof WorkRequest) { if (dar.getMessage().equals("Drug Approved")) // {/*from w w w.j ava 2s . c o m*/ if (!hashMap.containsKey(dar.getCompanyId())) { counter = 0; counter = counter + 1; } else if (hashMap.containsKey(dar.getCompanyId())) { counter = hashMap.get(dar.getCompanyId()) + 1; } hashMap.put(dar.getCompanyId(), counter); } } } Set set = hashMap.entrySet(); Iterator i = set.iterator(); // Display elements Map.Entry me = null; int compID = 0; int counterID = 0; while (i.hasNext()) { me = (Map.Entry) i.next(); compID = (int) me.getKey(); counterID = (int) me.getValue(); DrugApprovalRequest dar1; for (WorkRequest wr : authority.getWorkQueue().getWorkRequestList()) { if (wr instanceof DrugApprovalRequest) { dar1 = (DrugApprovalRequest) wr; if (dar1.getCompanyId() == compID) { String name = dar1.getCompanyName(); dataset.setValue(counterID, "Total Drugs Approved", name); } } } } JFreeChart chart = ChartFactory.createBarChart("Pharmaceutical Performance", "Company Name", "Total Drugs Approved", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.black); ChartFrame frame = new ChartFrame("Product Performance for Companies", chart); frame.setVisible(true); frame.setSize(850, 900); }
From source file:eu.stratosphere.pact.runtime.task.DataSinkTaskTest.java
@Test public void testUnionDataSinkTask() { int keyCnt = 100; int valCnt = 20; super.initEnvironment(MEMORY_MANAGER_SIZE, NETWORK_BUFFER_SIZE); super.addInput(new UniformRecordGenerator(keyCnt, valCnt, 0, 0, false), 0); super.addInput(new UniformRecordGenerator(keyCnt, valCnt, keyCnt, 0, false), 0); super.addInput(new UniformRecordGenerator(keyCnt, valCnt, keyCnt * 2, 0, false), 0); super.addInput(new UniformRecordGenerator(keyCnt, valCnt, keyCnt * 3, 0, false), 0); DataSinkTask<Record> testTask = new DataSinkTask<Record>(); super.registerFileOutputTask(testTask, MockOutputFormat.class, new File(tempTestPath).toURI().toString()); try {//from w ww .ja v a2 s.c om testTask.invoke(); } catch (Exception e) { LOG.debug(e); Assert.fail("Invoke method caused exception."); } File tempTestFile = new File(this.tempTestPath); Assert.assertTrue("Temp output file does not exist", tempTestFile.exists()); FileReader fr = null; BufferedReader br = null; try { fr = new FileReader(tempTestFile); br = new BufferedReader(fr); HashMap<Integer, HashSet<Integer>> keyValueCountMap = new HashMap<Integer, HashSet<Integer>>(keyCnt); while (br.ready()) { String line = br.readLine(); Integer key = Integer.parseInt(line.substring(0, line.indexOf("_"))); Integer val = Integer.parseInt(line.substring(line.indexOf("_") + 1, line.length())); if (!keyValueCountMap.containsKey(key)) { keyValueCountMap.put(key, new HashSet<Integer>()); } keyValueCountMap.get(key).add(val); } Assert.assertTrue("Invalid key count in out file. Expected: " + keyCnt + " Actual: " + keyValueCountMap.keySet().size(), keyValueCountMap.keySet().size() == keyCnt * 4); for (Integer key : keyValueCountMap.keySet()) { Assert.assertTrue("Invalid value count for key: " + key + ". Expected: " + valCnt + " Actual: " + keyValueCountMap.get(key).size(), keyValueCountMap.get(key).size() == valCnt); } } catch (FileNotFoundException e) { Assert.fail("Out file got lost..."); } catch (IOException ioe) { Assert.fail("Caught IOE while reading out file"); } finally { if (br != null) { try { br.close(); } catch (Throwable t) { } } if (fr != null) { try { fr.close(); } catch (Throwable t) { } } } }