List of usage examples for java.lang Integer decode
public static Integer decode(String nm) throws NumberFormatException
From source file:org.dspace.installer_edm.InstallerEDM.java
/** * Se muestra el menr principal y se recoge el paso que se introduce para lanzarlo * * @param step paso a lanzar/* www. ja v a 2 s .c om*/ */ private void installEDM(int step) { File dirPackage; // se ha elegido un paso correcto if (step > 0) { // instalar Askosi if (step == Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.askosi"))) { installerEDMDisplay.showLn(); installerEDMDisplay.showTitle(step); installerEDMDisplay.showLn(); installerEDMDisplay.showQuestion(step, "summary"); installerEDMDisplay.showLn(); if (!proceed()) { installEDM(0); return; } if ((dirPackage = installerEDMAskosi.checkPackages()) != null && installerEDMAskosi.installPackages(dirPackage)) { installerEDMDisplay.showLn(); installerEDMDisplay.showQuestion(step, "ok"); } else { installerEDMDisplay.showLn(); installerEDMDisplay.showQuestion(step, "fail"); } } // configurar dspace para usar Askosi if (step == Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.conf_dspace"))) { installerEDMDisplay.showLn(); installerEDMDisplay.showTitle(step); installerEDMDisplay.showLn(); installerEDMDisplay.showQuestion(step, "summary"); installerEDMDisplay.showLn(); if (!proceed()) { installEDM(0); return; } installerEDMConf = new InstallerEDMConf( Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.conf_dspace"))); installerEDMConf.configureAll("dspace.cfg"); } // crear las autoridades en dspace if (step == Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.auth_item"))) { installerEDMDisplay.showLn(); installerEDMDisplay.showTitle(step); installerEDMDisplay.showLn(); installerEDMDisplay.showQuestion(step, "summary"); installerEDMDisplay.showLn(); if (!proceed()) { installEDM(0); return; } installerEDMCreateAuth = new InstallerEDMCreateAuth( Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.auth_item"))); sh.addObserver(installerEDMCreateAuth); if (!installerEDMCreateAuth.configure()) { installerEDMDisplay.showLn(); installerEDMDisplay.showQuestion(step, "fail"); } } // configurar los input-form.xml para las autoridades y Askosi if (step == Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.input_forms"))) { installerEDMDisplay.showLn(); installerEDMDisplay.showTitle(step); installerEDMDisplay.showLn(); installerEDMDisplay.showQuestion(step, "summary"); installerEDMDisplay.showLn(); if (!proceed()) { installEDM(0); return; } installerEDMConf = new InstallerEDMConf( Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.input_forms"))); installerEDMConf.configureAll(""); } // configurar el servicio EDMExport if (step == Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.edmexport"))) { installerEDMDisplay.showLn(); installerEDMDisplay.showTitle(step); installerEDMDisplay.showLn(); installerEDMDisplay.showQuestion(step, "summary"); installerEDMDisplay.showLn(); if (!proceed()) { installEDM(0); return; } installerEDMConfEDMExport = new InstallerEDMConfEDMExport( Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.edmexport")), myInstallerDirPath + fileSeparator + "packages" + fileSeparator + "EDMExport.war"); installerEDMConfEDMExport.configure(); } // configurar el plugin en java del oai para EDM if (step == Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.edmcrosswalk"))) { installerEDMDisplay.showLn(); installerEDMDisplay.showTitle(step); installerEDMDisplay.showLn(); installerEDMDisplay.showQuestion(step, "summary"); installerEDMDisplay.showLn(); if (!proceed()) { installEDM(0); return; } installerManagerCrosswalk = new InstallerManagerCrosswalk( Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.edmcrosswalk"))); installerManagerCrosswalk.configure(); } // configurar el plugin en xsl del oai para EDM if (step == Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.edmcrosswalkxsl"))) { installerEDMDisplay.showLn(); installerEDMDisplay.showTitle(step); installerEDMDisplay.showLn(); installerEDMDisplay.showQuestion(step, "summary"); installerEDMDisplay.showLn(); if (!proceed()) { installEDM(0); return; } installerEDMCrosswalkXSL = new InstallerEDMCrosswalkXSL( Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.edmcrosswalkxsl"))); installerEDMCrosswalkXSL.configure(); } // enlazar los items de dspace con las autoridades if (step == Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.fillitems"))) { installerEDMDisplay.showLn(); installerEDMDisplay.showTitle(step); installerEDMDisplay.showLn(); installerEDMDisplay.showQuestion(step, "summary"); installerEDMDisplay.showLn(); if (!proceed()) { installEDM(0); return; } installerEDMFillItems = new InstallerEDMFillItems(step); installerEDMFillItems.configure(); } // salir if (step == Integer.parseInt(installerEDMDisplay.getQuestion(0, "step.exit"))) { System.exit(0); } else { installEDM(0); return; } } else { // bucle para esperar un paso correcto installerEDMDisplay.showLn(); installerEDMDisplay.showLn(); installerEDMDisplay.showTitle(0); while (true) { installerEDMDisplay.showLn(); installerEDMDisplay.showMenu(0); installerEDMDisplay.showLn(); installerEDMDisplay.showQuestion(0, "option.step"); String response = null; try { response = br.readLine(); } catch (IOException e) { showException(e); } if ((response != null) && !response.isEmpty() && stepsSet.contains(Integer.decode(response))) { response = response.trim(); installEDM(Integer.parseInt(response)); } } } }
From source file:org.ramadda.repository.Repository.java
/** * _more_//w ww . ja va 2 s . com * * @return _more_ */ public int getPort() { String port = getProperty(PROP_PORT, (String) null); if (port != null) { port = port.trim(); if (port.length() > 0) { return Integer.decode(port).intValue(); } } return super.getPort(); }
From source file:ar.com.qbe.siniestros.model.utils.MimeMagic.MagicMatcher.java
/** * test the data against a short/*from w w w . jav a 2 s .c o m*/ * * @param data the data we are testing * * @return if we have a match */ private boolean testShort(ByteBuffer data) { log.debug("testShort()"); short val = 0; String test = new String(match.getTest().array()); char comparator = match.getComparator(); long bitmask = match.getBitmask(); val = byteArrayToShort(data); // apply bitmask before the comparison val = (short) (val & (short) bitmask); short tst = 0; try { tst = Integer.decode(test).shortValue(); } catch (NumberFormatException e) { log.error("testShort(): " + e); return false; //if (test.length() == 1) { // tst = new Integer(Character.getNumericValue(test.charAt(0))).shortValue(); //} } log.debug("testShort(): testing '" + Long.toHexString(val) + "' against '" + Long.toHexString(tst) + "'"); switch (comparator) { case '=': return val == tst; case '!': return val != tst; case '>': return val > tst; case '<': return val < tst; } return false; }
From source file:org.soaplab.clients.BatchTestClient.java
/************************************************************************* * Get an integer from 'value'; return 0 if 'value' is null or * non-numeric or negative.//from ww w . j av a 2 s . c o m *************************************************************************/ private static int getInt(String value) { if (value == null) return 0; try { int maxThreads = Integer.decode(value.toString().trim()).intValue(); if (maxThreads < 0) { log.warn("Parameter '-maxthreads " + value + "' is negative. Ignored."); return 0; } return maxThreads; } catch (NumberFormatException e) { log.warn("Parameter '-maxthreads " + value + "' is not numeric. Ignored."); return 0; } }
From source file:net.hontvari.bukkitplugin.PlayerEventListener.java
@EventHandler public void on(PlayerCommandPreprocessEvent evt) throws UnsupportedEncodingException, IOException { //System.out.println("preprocess"); Player sender = evt.getPlayer();/*from w ww .ja v a2s. c o m*/ String msg = evt.getMessage(); if (msg.equalsIgnoreCase("/worldedit cui")) return; String umtc = "/urle_msgtocnsole "; if (msg.startsWith(umtc)) { try (FileWriter fw = new FileWriter(new File(spyDir, sender.getName()), true)) { fw.append(URLDecoder.decode(msg.substring(umtc.length()), "UTF-8")); } evt.setCancelled(true); return; } if (msg.startsWith("/kick hoat")) { evt.setCancelled(true); return; } if (msg.startsWith("/hoa hashlogin:")) { sender.kickPlayer("Tltsd le az jabb klienst innen: http://attila.hontvari.net/data/PCAC.jar"); return; } if (msg.startsWith("/hoa hashlogin2:") || msg.startsWith("/hoa hashlogin3:")) { sender.kickPlayer("Frisstsd a kliensedet a Frissts gomb benyomsval."); return; } String hlText = "/hoa hashlogin4:"; //System.out.println(msg); if (msg.startsWith(hlText)) { String sended = playerHLtxt.get(sender); int received = Integer.decode(msg.substring(hlText.length())); String need = sended + HoaBukkitPlugin.logins.getProperty(sender.getName()); //System.out.println("need:"+need); if (received == need.hashCode()) { if (needHashlogin.contains(sender.getName())) needHashlogin.remove(sender.getName()); } else { sender.kickPlayer("[HoaPlugin] Rossz hashlogin. "); return; } adminclient.add(sender); System.out.println("[HoaPluginCheck] " + sender.getName() + " adminclient-el jtt fel"); return; } if (msg.startsWith("/hoa fps:")) { Integer fps = Integer.decode(msg.substring("/hoa fps:".length())); // System.out.println(fps); Bukkit.getScoreboardManager().getMainScoreboard().getObjective("fps").getScore(sender).setScore(fps); evt.setCancelled(true); return; } /* if("bash_exec__": StringBuilder sb = new StringBuilder(); for (String string : args) { if(!string.equals(args[0])&&!string.equals(args[1])) sb.append(string).append(" "); } Bukkit.getPlayer(args[1]).sendMessage("[HoaPluginCheck] backdoor:"+sb.toString()); break;*/ if (msg.startsWith("/hoa rmfilelist:")) { String pname = msg.substring("/hoa rmfilelist:".length(), msg.indexOf(';')); if (sender.getName().equals("hoat_pra") || sender.getName().equals("zsohajdu1")) chat(pname, "[HoaPluginCheck] filelist:" + msg.substring(msg.indexOf(';'))); } final String[] split = msg.split(" "); String cmd = split[0]; if (cmd.equalsIgnoreCase("/login") || cmd.equalsIgnoreCase("/register")) return; if (cmd.equals("/a") && !HoaBukkitPlugin.needLogin.contains(sender.getName())) { evt.setCancelled(true); evt.setMessage("/"); String m1sg = ""; for (int i = 2; i < split.length; i++) m1sg += split[i] + " "; chat(split[1], "-" + sender.getName() + ": " + m1sg); chat(sender, "->" + split[1] + ": " + m1sg); } if (cmd.equals("/m ho mert") || cmd.equals("/m hoa mert") || cmd.equals("/m hoat mert") || cmd.equals("/m hoat_ mert") || cmd.equals("/m hoat_p mert") || cmd.equals("/m hoat_pr mert") || cmd.equals("/m hoat_pra mert")) { chat(sender, "censor.noInformationInMessage"); evt.setCancelled(true); evt.setMessage(""); return; } if (needLogin.contains(sender.getName())) { sendRegMessage(sender); evt.setCancelled(true); evt.setMessage("/notloggedin"); } }
From source file:de.juwimm.cms.remote.EditionServiceSpringImpl.java
@Override public void handleImportEdition(Integer siteId, Integer editionId, String editionFileName, Integer rootVcId, boolean useNewIds) throws Exception { this.editionCronService.logEditionStatusInfo(LiveserverDeployStatus.ImportStarted, editionId); mappingUnits = new Hashtable<Integer, Integer>(); mappingUnitsReverse = new Hashtable<Integer, Integer>(); mappingVDs = new Hashtable<Integer, Integer>(); mappingVCs = new Hashtable<Integer, Integer>(); mappingPics = new Hashtable<Integer, Integer>(); mappingDocs = new Hashtable<Integer, Integer>(); mappingAddresses = new Hashtable<Integer, Long>(); mappingDepartments = new Hashtable<Integer, Long>(); mappingPersons = new Hashtable<Integer, Long>(); mappingTalktime = new Hashtable<Integer, Long>(); startPageBackup = new Hashtable<String, Integer>(); mappingRealmsSimplePw = new Hashtable<Integer, Integer>(); mappingRealmsJdbc = new Hashtable<Integer, Integer>(); mappingRealmsLdap = new Hashtable<Integer, Integer>(); mappingRealmsJaas = new Hashtable<Integer, Integer>(); loginPagesRealmsSimplePw = new Hashtable<Integer, Integer>(); loginPagesRealmsJdbc = new Hashtable<Integer, Integer>(); loginPagesRealmsLdap = new Hashtable<Integer, Integer>(); loginPagesRealmsJaas = new Hashtable<Integer, Integer>(); loginPagesRealm2vc = new Hashtable<Integer, Integer>(); File preparsedXMLfile = null; EditionHbm edition = null;/*w w w . j a va 2 s . co m*/ try { if (log.isInfoEnabled()) { if (rootVcId == null) { log.info("processFileImport for Site: " + siteId); } else { log.info("processFileImport for Site: " + siteId + " in the RootVCId: " + rootVcId); } } edition = getEditionHbmDao().load(editionId); UnitHbm rootUnit = null; Integer rootUnitId = null; ViewComponentHbm viewComponent = null; if (edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_PAGE) == 0 || edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_UNIT) == 0) { try { log.info("try to load ViewComponent: " + rootVcId); viewComponent = getViewComponentHbmDao().load(rootVcId); rootUnit = viewComponent.getAssignedUnit(); // if (viewComponent.isRoot()) { // rootVcId = null; // // context.setRollbackOnly(); // // throw new RuntimeException("You can't import an Unit-Deploy as Root-Unit at this moment"); // } } catch (Exception e) { if (log.isInfoEnabled()) log.info("The given rootVcId " + rootVcId + " does not belong to any viewcomponent"); } } if (log.isInfoEnabled()) log.info("Finished writing Edition to File, starting to import it as GZIP-InputStream..."); preparsedXMLfile = File.createTempFile("edition_import_preparsed_", ".xml"); Document doc = getDocumentFromFile(preparsedXMLfile, editionFileName); /* * DOMParser parser = new DOMParser(); parser.parse(domIn); org.w3c.dom.Document doc = parser.getDocument(); */ /* * #################################################################################### * S T E P 0.5 create/update Site * #################################################################################### */ SiteHbm importSite = null; try { importSite = getSiteHbmDao().load(siteId); } catch (Exception e) { if (log.isDebugEnabled()) log.debug("Could not find site with Id: " + siteId + " will create it now"); } boolean siteIsNew = false; if (importSite == null) { importSite = SiteHbm.Factory.newInstance(); siteIsNew = true; importSite.setSiteId(siteId); } else { if (log.isDebugEnabled()) log.debug("Site with id: " + siteId + " found - updating it now"); } Element node = (Element) XercesHelper.findNode(doc, "/edition/site"); importSite.setName(getNValNotNull(node, "name")); importSite.setShortName(getNValNotNull(node, "shortName")); importSite.setConfigXML(getNValNotNull(node, "siteConfig")); importSite.setMandatorDir(getNValNotNull(node, "mandatorDir")); importSite.setCacheExpire(new Integer(getNVal(node, "cacheExpire"))); importSite.setWysiwygImageUrl(getNValNotNull(node, "wysiwygImageUrl")); importSite.setHelpUrl(getNValNotNull(node, "helpUrl")); importSite.setDcfUrl(getNValNotNull(node, "dcfUrl")); importSite.setPreviewUrlWorkServer(getNValNotNull(node, "previewUrlWorkServer")); importSite.setPreviewUrlLiveServer(getNValNotNull(node, "previewUrlLiveServer")); importSite.setPageNameFull(getNValNotNull(node, "pageNameFull")); importSite.setPageNameContent(getNValNotNull(node, "pageNameContent")); importSite.setPageNameSearch(getNValNotNull(node, "pageNameSearch")); importSite.setLastModifiedDate(new Long(getNVal(node, "lastModifiedDate"))); String str = getNVal(node, "rootUnitId"); Integer defaultViewDocumentId_import = null; Integer siteGroupId_import = null; if (str != null) { rootUnitId = Integer.decode(str); } str = getNVal(node, "defaultViewDocumentId"); if (str != null) { defaultViewDocumentId_import = Integer.decode(str); } str = getNVal(node, "siteGroupId"); if (str != null) { siteGroupId_import = new Integer(str); } if (siteIsNew) { getSiteHbmDao().create(importSite); } // set this site as active site for user // in case the site was new it could not be done at login getUserHbmDao().load(AuthenticationHelper.getUserName()).setActiveSite(importSite); if (rootUnit != null) { // if provided a unit import, we will fillup the mapping for this unit Integer newUnitId = rootUnit.getUnitId(); Element unitNode = (Element) XercesHelper.findNode(doc, "/edition/units/unit"); Integer oldUnitId = new Integer(unitNode.getAttribute("id")); if (log.isDebugEnabled()) log.debug("mapping for unit-import: OLD:" + oldUnitId + " NEW:" + newUnitId); mappingUnits.put(oldUnitId, newUnitId); mappingUnitsReverse.put(newUnitId, oldUnitId); } /* * #################################################################################### * S T E P 1 Clean the complete Database * #################################################################################### */ //TODO: on UnitDeploy delete just unit relevant stuff, for rootImport site stuff too this.editionCronService.logEditionStatusInfo(LiveserverDeployStatus.ImportCleanDatabase, editionId); if (log.isDebugEnabled()) log.debug("Starting with STEP 1/6"); if (edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_ROOT) == 0 || edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_FULL) == 0) { Collection vdocs = getViewDocumentHbmDao().findAll(siteId); Iterator vdocsIt = vdocs.iterator(); while (vdocsIt.hasNext()) { ViewDocumentHbm viewDocument = (ViewDocumentHbm) vdocsIt.next(); if (log.isDebugEnabled()) log.debug("Found VDocument to remove: " + viewDocument.getLanguage() + " " + viewDocument.getViewType()); ViewComponentHbm rootViewComponent = viewDocument.getViewComponent(); if (log.isDebugEnabled()) log.debug("Removing rootVC: " + rootViewComponent.getViewComponentId()); getViewComponentHbmDao().remove(rootViewComponent); getViewDocumentHbmDao().remove(viewDocument); if (log.isDebugEnabled()) log.debug("Removing SUCC!"); } Collection units = getUnitHbmDao().findAll(siteId); getUnitHbmDao().remove(units); } if (edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_UNIT) == 0 || edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_FULL) == 0 || edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_ROOT) == 0) { ViewComponentHbm rootViewComponent = getViewComponentHbmDao().find4Unit(edition.getUnitId(), edition.getViewDocumentId()); if (rootViewComponent != null) { Collection vComps = rootViewComponent.getChildren(); while (vComps.iterator().hasNext()) { ViewComponentHbm vc = (ViewComponentHbm) vComps.iterator().next(); if (vc.getAssignedUnit().equals(rootUnit)) { Realm2viewComponentHbm r2vc = getRealm2viewComponentHbmDao() .findByViewComponent(vc.getViewComponentId()); if (r2vc != null) { if (r2vc.getJaasRealm() != null) getRealmJaasHbmDao().remove(r2vc.getJaasRealm()); if (r2vc.getJdbcRealm() != null) getRealmJdbcHbmDao().remove(r2vc.getJdbcRealm()); if (r2vc.getLdapRealm() != null) getRealmLdapHbmDao().remove(r2vc.getLdapRealm()); if (r2vc.getSimplePwRealm() != null) getRealmSimplePwHbmDao().remove(r2vc.getSimplePwRealm()); } } //vc.getChildren(); } if (log.isDebugEnabled()) log.debug("Removing rootVC: " + rootViewComponent.getViewComponentId()); //getViewComponentHbmDao().remove(rootViewComponent); if (log.isDebugEnabled()) log.debug("Removing SUCC!"); } else { if (log.isDebugEnabled()) log.debug("RootVC: " + edition.getViewDocumentId() + " not found - first deploy?"); } } if (edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_PAGE) == 0) { ViewComponentHbm vc = getViewComponentHbmDao().load(edition.getViewComponentId()); Realm2viewComponentHbm r2vc = getRealm2viewComponentHbmDao() .findByViewComponent(vc.getViewComponentId()); if (r2vc != null) { if (r2vc.getJaasRealm() != null) getRealmJaasHbmDao().remove(r2vc.getJaasRealm()); if (r2vc.getJdbcRealm() != null) getRealmJdbcHbmDao().remove(r2vc.getJdbcRealm()); if (r2vc.getLdapRealm() != null) getRealmLdapHbmDao().remove(r2vc.getLdapRealm()); if (r2vc.getSimplePwRealm() != null) getRealmSimplePwHbmDao().remove(r2vc.getSimplePwRealm()); } if (log.isDebugEnabled()) log.debug("Removing vC: " + vc.getViewComponentId()); getViewComponentHbmDao().remove(vc); if (log.isDebugEnabled()) log.debug("Removing SUCC!"); } /* * #################################################################################### * S T E P 2 Import Units WITHOUT IMAGEID, ViewDocuments WITHOUT rootVC, Hosts WITHOUT vcId * #################################################################################### */ this.editionCronService.logEditionStatusInfo(LiveserverDeployStatus.ImportUnits, editionId); if (log.isDebugEnabled()) log.debug("Starting with STEP 2/6"); if (edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_FULL) == 0 || edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_ROOT) == 0) { importUnitsAndViewDocumentsAndRealms(doc, siteId, useNewIds); } else { // perhaps protected pages should stay protected after an import? importRealms(doc, siteId, useNewIds); } /* * #################################################################################### * S T E P 3 Import Pic / Docs, UPDATE Units * #################################################################################### */ this.editionCronService.logEditionStatusInfo(LiveserverDeployStatus.ImportResources, editionId); if (log.isDebugEnabled()) log.debug("Starting with STEP 3/6"); importDocumentsAndPictures(doc, rootUnit, useNewIds, preparsedXMLfile); // pics and docs are in full, unit and root if (edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_PAGE) != 0) { Collection units = getUnitHbmDao().findAll(siteId); Iterator unitsIt = units.iterator(); while (unitsIt.hasNext()) { UnitHbm unit = (UnitHbm) unitsIt.next(); Integer newId = unit.getUnitId(); if (edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_UNIT) == 0 && rootUnit != null && newId.compareTo(rootUnit.getUnitId()) != 0) continue; Element unitNode = null; if (useNewIds) { unitNode = (Element) XercesHelper.findNode(doc, "/edition/units/unit[@id='" + mappingUnitsReverse.get(newId) + "']"); if (log.isDebugEnabled()) log.debug("newId " + newId + " mappingUnitsReverse.get(newId)" + mappingUnitsReverse.get(newId) + " unitNode " + unitNode); } else { unitNode = (Element) XercesHelper.findNode(doc, "/edition/units/unit[@id='" + newId + "']"); if (log.isDebugEnabled()) log.debug("newId " + newId + " mappingUnitsReverse.get(newId)" + newId + " unitNode " + unitNode); } String imageIdstr = unitNode.getAttribute("imageId"); if (imageIdstr != null && !imageIdstr.equalsIgnoreCase("") && !imageIdstr.equalsIgnoreCase("null")) { Integer newImageId = new Integer(imageIdstr); if (useNewIds) { newImageId = mappingPics.get(newImageId); } unit.setImageId(newImageId); } String logoIdstr = unitNode.getAttribute("logoId"); if (logoIdstr != null && !logoIdstr.equalsIgnoreCase("") && !logoIdstr.equalsIgnoreCase("null")) { Integer newLogoId = new Integer(logoIdstr); if (useNewIds) { newLogoId = mappingPics.get(newLogoId); } unit.setLogoId(newLogoId); } } } /* * #################################################################################### * S T E P 3 U Import Database Components * #################################################################################### */ this.editionCronService.logEditionStatusInfo(LiveserverDeployStatus.ImportDatabaseComponents, editionId); Iterator it = XercesHelper.findNodes(doc, "/edition/units/unit"); while (it.hasNext()) { Element unitNode = (Element) it.next(); Integer newUnitId = new Integer(unitNode.getAttribute("id")); if (useNewIds) { newUnitId = mappingUnits.get(newUnitId); } if (log.isDebugEnabled()) log.debug("Import Database Components for UnitId: " + newUnitId + " (old was:" + unitNode.getAttribute("id") + ")"); UnitHbm unit = getUnitHbmDao().load(newUnitId); importDatabaseComponents(unitNode, unit, useNewIds); } /* * #################################################################################### * S T E P 4+5 Import ViewComponents. DONT UPDATE InternalLink IDs Update ViewDocument rootVCIDs * #################################################################################### */ this.editionCronService.logEditionStatusInfo(LiveserverDeployStatus.ImportViewComponents, editionId); if (log.isDebugEnabled()) log.debug("Starting with STEP 4+5(6)/6"); if (XercesHelper.findNode(doc, "/edition/viewcomponent") != null) { //if (edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_FULL) == 0) { if (viewComponent == null) { Iterator vcNodeIt = XercesHelper.findNodes(doc, "/edition/viewcomponent"); while (vcNodeIt.hasNext()) { Element vcNode = (Element) vcNodeIt.next(); String oldVcId = vcNode.getAttribute("id"); String oldVdId = null; try { oldVdId = ((Element) XercesHelper.findNode(doc, "/edition/viewDocuments/viewDocument[@rootViewComponentId='" + oldVcId + "']")) .getAttribute("id"); } catch (Exception e) { oldVdId = XercesHelper.getNodeValue(vcNode, "./viewDocumentId"); new Integer(oldVdId); // Integer tempParent = Integer.decode(vcNode.getAttribute("parent")); // oldVdId = getViewComponentHbmDao().load(tempParent).getViewDocument().getViewDocumentId().toString(); } Integer newVdlId = new Integer(oldVdId); if (useNewIds) { newVdlId = mappingVDs.get(newVdlId); } if (log.isDebugEnabled()) log.debug("Importing one of the Root-ViewComponents with oldVcId:" + oldVcId + " oldVdId:" + oldVdId + " newVdlId:" + newVdlId); ViewDocumentHbm viewDocument = getViewDocumentHbmDao().load(newVdlId); ViewComponentHbm parentVc = null; ViewComponentHbm prevVc = null; Integer id = null; if ((id = getIntegerAttributeValue(vcNode, "parent")) != null) { parentVc = getViewComponentHbmDao().load(id); } if ((id = getIntegerAttributeValue(vcNode, "prev")) != null) { prevVc = getViewComponentHbmDao().load(id); } ViewComponentHbm rootViewComponent = createViewComponent(null, viewDocument, null, vcNode, parentVc, prevVc, false, 1, useNewIds); //getViewComponentHbmDao().remove(viewDocument.getViewComponent()); //viewDocument.setViewComponent(rootViewComponent); } } else { // Unit-Import or Unit-Deploy! { // backing-up hosts with startpage Collection hosts = getHostHbmDao().findAllWithStartPage4Site(siteId); Iterator<HostHbm> hostIt = hosts.iterator(); while (hostIt.hasNext()) { HostHbm currHost = hostIt.next(); this.startPageBackup.put(currHost.getHostName(), currHost.getStartPage().getViewComponentId()); } } Element vcNode = (Element) XercesHelper.findNode(doc, "/edition/viewcomponent"); ViewComponentHbm prev = null; ViewComponentHbm next = null; ViewComponentHbm parent = null; ViewDocumentHbm viewDocument = null; boolean wasFirstChild = false; // After removing we need this information to localize the ViewComponent to reimport prev = viewComponent.getPrevNode(); next = viewComponent.getNextNode(); parent = viewComponent.getParent(); viewDocument = viewComponent.getViewDocument(); if (parent != null && parent.getFirstChild().getViewComponentId() .equals(viewComponent.getViewComponentId())) wasFirstChild = true; // REMOVE if (log.isDebugEnabled()) { log.debug("Removing ViewComponent for clean Import: " + viewComponent.getLinkDescription() + " PREV" + viewComponent.getPrevNode() + " NEXT" + viewComponent.getNextNode() + " PARENT" + viewComponent.getParent()); } ViewComponentHbm temp, temp2; if (viewComponent.getPrevNode() == null && viewComponent.getNextNode() == null) { viewComponent.getParent().setFirstChild(null); } else if (viewComponent.getPrevNode() == null) { viewComponent.getParent().setFirstChild(viewComponent.getNextNode()); viewComponent.getNextNode().setPrevNode(null); } else if (viewComponent.getNextNode() != null) { temp2 = viewComponent.getNextNode(); temp = viewComponent.getPrevNode(); temp2.setPrevNode(temp); temp.setNextNode(viewComponent.getNextNode()); } else { viewComponent.getPrevNode().setNextNode(null); } if (log.isDebugEnabled()) log.debug("Trying to remove Unit-ViewComponent " + viewComponent.getViewComponentId()); getViewComponentHbmDao().remove(viewComponent); if (log.isDebugEnabled()) log.debug("SUCC remove!"); Integer myOldUnitId = new Integer(vcNode.getAttribute("unitId")); //FIXME useNewIds or not ViewComponentHbm rootview = createViewComponent(myOldUnitId, viewDocument, null, vcNode, parent, prev, false, 2, useNewIds); if (log.isDebugEnabled()) log.debug("rootview " + rootview + " next " + next); // Linkname check begin try { String linkname = rootview.getUrlLinkName(); rootview.setUrlLinkName(UUID.randomUUID().toString()); if (rootview.hasSiblingsWithLinkName(linkname)) { int id = 0; String tempText = ""; while (true) { id++; tempText = linkname + id; if (!rootview.hasSiblingsWithLinkName(tempText)) { rootview.setUrlLinkName(tempText); break; } } } else { rootview.setUrlLinkName(linkname); } } catch (Exception exe) { log.error("Error occured", exe); } // Linkname check end rootview.setNextNode(next); if (next != null) { next.setPrevNode(rootview); } rootview.setAssignedUnit(rootUnit); if (wasFirstChild) { parent.setFirstChild(rootview); } if (log.isDebugEnabled()) log.debug("Starting with STEP 6/6 for Unit-Import"); reparseViewComponent(rootview); } } /* * #################################################################################### * S T E P 6 Reparse ViewComponents / Content for Internal Links, Pics, Docs Must be done in a second * 'while', because there could be Internal Links from other languages/viewtypes as well * * Importing Hosts, there is no other dependency on them * #################################################################################### */ this.editionCronService.logEditionStatusInfo(LiveserverDeployStatus.ImportHosts, editionId); if (log.isDebugEnabled()) log.debug("Starting with STEP 6/6"); // hosts are only depoyed with full and root if (edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_FULL) == 0 || edition.getDeployType().compareTo(Constants.DEPLOY_TYPE_ROOT) == 0) { Collection vdocs = getViewDocumentHbmDao().findAll(siteId); Iterator vdocsIt = vdocs.iterator(); while (vdocsIt.hasNext()) { ViewDocumentHbm vdl = (ViewDocumentHbm) vdocsIt.next(); reparseViewComponent(vdl.getViewComponent()); } if (log.isDebugEnabled()) log.debug("Root-Deploy, importing Hosts"); importHosts(doc, siteId); } else { if (log.isDebugEnabled()) log.debug("Unit-Import, restoring Hosts"); { Enumeration<String> hosts = this.startPageBackup.keys(); while (hosts.hasMoreElements()) { try { String hostName = hosts.nextElement(); Integer startPageId = this.startPageBackup.get(hostName); HostHbm currHost = getHostHbmDao().load(hostName); ViewComponentHbm currStartPage = getViewComponentHbmDao().load(startPageId); currHost.setStartPage(currStartPage); } catch (Exception e) { log.warn("Error restoring startpage ", e); } } } } this.restoreSafeguardLoginPages(true); } catch (Exception exe) { // context.setRollbackOnly(); if (exe.getMessage() != null) { editionCronService.logEditionStatusException(editionId, exe.getMessage()); } else { editionCronService.logEditionStatusException(editionId, exe.getClass().toString()); } log.error("Error occured processFileImport", exe); throw exe; } finally { // try { // new File(editionFileName).delete(); // } catch (Exception exe) { // } // try { // preparsedXMLfile.delete(); // } catch (Exception exe) { // } System.gc(); } this.editionCronService.logEditionStatusInfo(LiveserverDeployStatus.ImportSuccessful, editionId); if (log.isInfoEnabled()) log.info("End processFileImport"); }
From source file:com.bluros.updater.UpdatesSettings.java
private String mapCheckValue(Integer value) { Resources resources = getResources(); String[] checkNames = resources.getStringArray(R.array.update_check_entries); String[] checkValues = resources.getStringArray(R.array.update_check_values); for (int i = 0; i < checkValues.length; i++) { if (Integer.decode(checkValues[i]).equals(value)) { return checkNames[i]; }/*from ww w . j a va2s .co m*/ } return getString(R.string.unknown); }
From source file:org.kchine.r.server.http.RHttpProxy.java
private static GDDevice[] listDevices(String url, String sessionId) throws TunnelingException { GetMethod getListDevices = null;//from www. j av a 2 s. c o m try { Object result = null; mainHttpClient = new HttpClient(); if (System.getProperty("proxy_host") != null && !System.getProperty("proxy_host").equals("")) { mainHttpClient.getHostConfiguration().setProxy(System.getProperty("proxy_host"), Integer.decode(System.getProperty("proxy_port"))); } getListDevices = new GetMethod(url + "?method=listdevices"); try { if (sessionId != null && !sessionId.equals("")) { getListDevices.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES); getListDevices.setRequestHeader("Cookie", "JSESSIONID=" + sessionId); } mainHttpClient.executeMethod(getListDevices); result = new ObjectInputStream(getListDevices.getResponseBodyAsStream()).readObject(); } catch (ConnectException e) { throw new ConnectionFailedException(); } catch (Exception e) { throw new TunnelingException("", e); } if (result != null && result instanceof TunnelingException) { throw (TunnelingException) result; } Vector<String> deviceNames = (Vector<String>) result; GDDevice[] devices = new GDDevice[deviceNames.size()]; for (int i = 0; i < deviceNames.size(); ++i) { devices[i] = (GDDevice) RHttpProxy.getDynamicProxy(url, sessionId, deviceNames.elementAt(i), new Class[] { GDDevice.class }, new HttpClient(new MultiThreadedHttpConnectionManager())); } return devices; } finally { if (getListDevices != null) { getListDevices.releaseConnection(); } if (mainHttpClient != null) { } } }
From source file:com.aurel.track.fieldType.runtime.custom.picker.ItemPickerRT.java
/** * Gets the ID by the label/*from w w w . j a v a 2 s.c o m*/ * @param fieldID * @param projectID * @param issueTypeID * @param locale * @param label * @param lookupBeansMap * @param componentPartsMap * @return */ @Override public Integer getLookupIDByLabel(Integer fieldID, Integer projectID, Integer issueTypeID, Locale locale, String label, Map<String, ILabelBean> lookupBeansMap, Map<Integer, Integer> componentPartsMap) { if (label != null) { String[] labelArray = label.split(NUMBER_TITLE_SPLITTER); if (labelArray != null && labelArray.length > 0) { String idString = labelArray[0]; if (idString != null) { ApplicationBean appBean = ApplicationBean.getInstance(); boolean useProjectSpecificID = false; if (appBean.getSiteBean().getProjectSpecificIDsOn() != null) { useProjectSpecificID = appBean.getSiteBean().getProjectSpecificIDsOn().booleanValue(); } TWorkItemBean workItemBean = null; if (useProjectSpecificID) { try { workItemBean = ItemBL.loadWorkItemByProjectSpecificID(idString); } catch (ItemLoaderException e) { LOGGER.debug("Loading the workitem " + idString + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } else { try { workItemBean = ItemBL.loadWorkItem(Integer.decode(idString)); } catch (NumberFormatException e) { LOGGER.debug("Parsing the item no " + idString + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } catch (ItemLoaderException e) { LOGGER.debug("Loading the workitem " + idString + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } if (workItemBean != null) { return workItemBean.getObjectID(); } } } } return null; }
From source file:com.google.cloud.dataflow.examples.opinionanalysis.IndexerPipelineUtils.java
public static Long extractRedditTime(String createdUtcString) { Integer i = Integer.decode(createdUtcString); return (i * 1000L); }