List of usage examples for java.lang Long decode
public static Long decode(String nm) throws NumberFormatException
From source file:org.jboss.dashboard.ui.config.treeNodes.SkinsNode.java
public boolean onEdit() { resourcesPropertiesHandler.setResourceType("skin"); resourcesPropertiesHandler.setResourceId(null); resourcesPropertiesHandler.setFile(null); resourcesPropertiesHandler.getFieddErrors().clear(); resourcesPropertiesHandler.setInserted(false); resourcesPropertiesHandler.setPreview(false); if (this.getParent().getParent() instanceof RootNode) { resourcesPropertiesHandler.setWorkspaceId(null); resourcesPropertiesHandler.setPanelId(null); resourcesPropertiesHandler.setSectionId(null); } else if (this.getParent().getParent() instanceof WorkspaceNode) { WorkspaceNode workspaceNode = (WorkspaceNode) this.getParent().getParent(); resourcesPropertiesHandler.setWorkspaceId(workspaceNode.getId()); resourcesPropertiesHandler.setPanelId(null); resourcesPropertiesHandler.setSectionId(null); } else if (this.getParent().getParent() instanceof SectionNode) { AbstractNode parent = (AbstractNode) this.getParent(); while (!(parent instanceof WorkspaceNode)) parent = (AbstractNode) parent.getParent(); WorkspaceNode workspaceNode = (WorkspaceNode) parent; SectionNode sectionNode = (SectionNode) this.getParent().getParent(); resourcesPropertiesHandler.setWorkspaceId(workspaceNode.getId()); resourcesPropertiesHandler.setSectionId(Long.decode(sectionNode.getId())); resourcesPropertiesHandler.setPanelId(null); } else if (this.getParent().getParent() instanceof PanelNode) { AbstractNode parent = (AbstractNode) this.getParent(); while (!(parent instanceof WorkspaceNode)) parent = (AbstractNode) parent.getParent(); WorkspaceNode workspaceNode = (WorkspaceNode) parent; PanelNode panelNode = (PanelNode) this.getParent().getParent(); resourcesPropertiesHandler.setWorkspaceId(workspaceNode.getId()); resourcesPropertiesHandler.setSectionId(null); resourcesPropertiesHandler.setPanelId(panelNode.getPanelId()); } else {/*w ww .ja v a2 s .com*/ //Unsuported Node throw new UnsupportedOperationException(); } return super.onEdit(); }
From source file:org.jboss.dashboard.ui.config.treeNodes.LayoutsNode.java
public boolean onEdit() { resourcesPropertiesHandler.setResourceType("layout"); resourcesPropertiesHandler.setInserted(false); resourcesPropertiesHandler.setPreview(false); resourcesPropertiesHandler.setResourceId(null); resourcesPropertiesHandler.setFile(null); resourcesPropertiesHandler.getFieddErrors().clear(); if (this.getParent().getParent() instanceof RootNode) { resourcesPropertiesHandler.setWorkspaceId(null); resourcesPropertiesHandler.setPanelId(null); resourcesPropertiesHandler.setSectionId(null); } else if (this.getParent().getParent() instanceof WorkspaceNode) { WorkspaceNode workspaceNode = (WorkspaceNode) this.getParent().getParent(); resourcesPropertiesHandler.setWorkspaceId(workspaceNode.getId()); resourcesPropertiesHandler.setPanelId(null); resourcesPropertiesHandler.setSectionId(null); } else if (this.getParent().getParent() instanceof SectionNode) { AbstractNode parent = (AbstractNode) this.getParent(); while (!(parent instanceof WorkspaceNode)) parent = (AbstractNode) parent.getParent(); WorkspaceNode workspaceNode = (WorkspaceNode) parent; SectionNode sectionNode = (SectionNode) this.getParent().getParent(); resourcesPropertiesHandler.setWorkspaceId(workspaceNode.getId()); resourcesPropertiesHandler.setSectionId(Long.decode(sectionNode.getId())); resourcesPropertiesHandler.setPanelId(null); } else if (this.getParent().getParent() instanceof PanelNode) { AbstractNode parent = (AbstractNode) this.getParent(); while (!(parent instanceof WorkspaceNode)) parent = (AbstractNode) parent.getParent(); WorkspaceNode workspaceNode = (WorkspaceNode) parent; PanelNode panelNode = (PanelNode) this.getParent().getParent(); resourcesPropertiesHandler.setWorkspaceId(workspaceNode.getId()); resourcesPropertiesHandler.setSectionId(null); resourcesPropertiesHandler.setPanelId(panelNode.getPanelId()); } else {//w w w . j a va 2 s . c om //Unsuported Node throw new UnsupportedOperationException(); } return super.onEdit(); }
From source file:org.jboss.dashboard.ui.config.treeNodes.EnvelopesNode.java
public boolean onEdit() { resourcesPropertiesHandler.setResourceType("envelope"); resourcesPropertiesHandler.setInserted(false); resourcesPropertiesHandler.setPreview(false); resourcesPropertiesHandler.setResourceId(null); resourcesPropertiesHandler.setFile(null); resourcesPropertiesHandler.getFieddErrors().clear(); if (this.getParent().getParent() instanceof RootNode) { resourcesPropertiesHandler.setWorkspaceId(null); resourcesPropertiesHandler.setPanelId(null); resourcesPropertiesHandler.setSectionId(null); } else if (this.getParent().getParent() instanceof WorkspaceNode) { WorkspaceNode workspaceNode = (WorkspaceNode) this.getParent().getParent(); resourcesPropertiesHandler.setWorkspaceId(workspaceNode.getId()); resourcesPropertiesHandler.setPanelId(null); resourcesPropertiesHandler.setSectionId(null); } else if (this.getParent().getParent() instanceof SectionNode) { AbstractNode parent = (AbstractNode) this.getParent(); while (!(parent instanceof WorkspaceNode)) parent = (AbstractNode) parent.getParent(); WorkspaceNode workspaceNode = (WorkspaceNode) parent; SectionNode sectionNode = (SectionNode) this.getParent().getParent(); resourcesPropertiesHandler.setWorkspaceId(workspaceNode.getId()); resourcesPropertiesHandler.setSectionId(Long.decode(sectionNode.getId())); resourcesPropertiesHandler.setPanelId(null); } else if (this.getParent().getParent() instanceof PanelNode) { AbstractNode parent = (AbstractNode) this.getParent(); while (!(parent instanceof WorkspaceNode)) parent = (AbstractNode) parent.getParent(); WorkspaceNode workspaceNode = (WorkspaceNode) parent; PanelNode panelNode = (PanelNode) this.getParent().getParent(); resourcesPropertiesHandler.setWorkspaceId(workspaceNode.getId()); resourcesPropertiesHandler.setSectionId(null); resourcesPropertiesHandler.setPanelId(panelNode.getPanelId()); } else {//from w w w . j av a2s. com //Unsuported Node throw new UnsupportedOperationException(); } return super.onEdit(); }
From source file:org.jboss.dashboard.ui.config.components.homePages.HomePagesHandler.java
public void actionSaveHomePages(final CommandRequest request) throws Exception { new HibernateTxFragment() { protected void txFragment(Session session) throws Exception { Map rolesPages = new HashMap(); Set<Role> allRoles = SecurityServices.lookup().getRolesManager().getAllRoles(); for (Role role : allRoles) { String param = request.getParameter("defaultPageFor_" + role.getName()); if (!StringUtils.isBlank(param)) rolesPages.put(role.getName(), Long.decode(param)); else rolesPages.put(role.getName(), null); }/*from ww w. j a va 2 s .co m*/ Workspace workspace = getWorkspace(); Set<WorkspaceHome> homePages = workspace.getWorkspaceHomes(); for (WorkspaceHome page : homePages) { Long sectionId = (Long) rolesPages.get(page.getRoleId()); page.setSectionId(sectionId); rolesPages.remove(page.getRoleId()); } Iterator it = rolesPages.keySet().iterator(); while (it.hasNext()) { String roleName = (String) it.next(); Long sectionId = (Long) rolesPages.get(roleName); WorkspaceHome newPage = new WorkspaceHome(); newPage.setWorkspace(workspace); newPage.setRoleId(roleName); newPage.setSectionId(sectionId); workspace.getWorkspaceHomes().add(newPage); } // Save the changes made to the workspace. UIServices.lookup().getWorkspacesManager().store(workspace); } }.execute(); }
From source file:com.amazonaws.mobileconnectors.pinpoint.internal.core.configuration.AndroidPreferencesConfiguration.java
public Long getLong(final String propertyName) { Long value = null;//from w ww . j a v a2 s. com String valueString = properties.get(propertyName); if (valueString != null) { try { value = Long.decode(valueString); } catch (Exception ex) { // Do not log property due to potential sensitive information. log.error("Could not get Long for property."); } } return value; }
From source file:org.jboss.dashboard.ui.config.treeNodes.ResourceGalleryNode.java
public boolean onEdit() { resourcesPropertiesHandler.setResourceType("resourceGallery"); resourcesPropertiesHandler.setInserted(false); resourcesPropertiesHandler.setPreview(false); resourcesPropertiesHandler.setResourceId(null); resourcesPropertiesHandler.setFile(null); resourcesPropertiesHandler.getFieddErrors().clear(); if (this.getParent().getParent() instanceof RootNode) { resourcesPropertiesHandler.setWorkspaceId(null); resourcesPropertiesHandler.setPanelId(null); resourcesPropertiesHandler.setSectionId(null); } else if (this.getParent().getParent() instanceof WorkspaceNode) { WorkspaceNode workspaceNode = (WorkspaceNode) this.getParent().getParent(); resourcesPropertiesHandler.setWorkspaceId(workspaceNode.getId()); resourcesPropertiesHandler.setPanelId(null); resourcesPropertiesHandler.setSectionId(null); } else if (this.getParent().getParent() instanceof SectionNode) { AbstractNode parent = (AbstractNode) this.getParent(); while (!(parent instanceof WorkspaceNode)) parent = (AbstractNode) parent.getParent(); WorkspaceNode workspaceNode = (WorkspaceNode) parent; SectionNode sectionNode = (SectionNode) this.getParent().getParent(); resourcesPropertiesHandler.setWorkspaceId(workspaceNode.getId()); resourcesPropertiesHandler.setSectionId(Long.decode(sectionNode.getId())); resourcesPropertiesHandler.setPanelId(null); } else if (this.getParent().getParent() instanceof PanelNode) { AbstractNode parent = (AbstractNode) this.getParent(); while (!(parent instanceof WorkspaceNode)) parent = (AbstractNode) parent.getParent(); WorkspaceNode workspaceNode = (WorkspaceNode) parent; parent = (AbstractNode) this.getParent(); while (!(parent instanceof SectionNode)) parent = (AbstractNode) parent.getParent(); SectionNode sectionNode = (SectionNode) parent; PanelNode panelNode = (PanelNode) this.getParent().getParent(); resourcesPropertiesHandler.setWorkspaceId(workspaceNode.getId()); resourcesPropertiesHandler.setSectionId(Long.decode(sectionNode.getId())); resourcesPropertiesHandler.setPanelId(panelNode.getPanelId()); } else {//from w w w .j a v a2 s .c o m //Unsuported Node throw new UnsupportedOperationException(); } return super.onEdit(); }
From source file:org.energy_home.jemma.javagal.rest.resources.PermitJoinAllResource.java
@Post public void processPost(String body) { // Uri parameters check String timeoutString = null;// www. jav a2 s. c o m String urilistener = null; Long timeout = -1l; Parameter timeoutParam = getRequest().getResourceRef().getQueryAsForm() .getFirst(Resources.URI_PARAM_TIMEOUT); if (timeoutParam == null) { Info info = new Info(); Status _st = new Status(); _st.setCode((short) GatewayConstants.GENERAL_ERROR); _st.setMessage("Error: mandatory '" + Resources.URI_PARAM_TIMEOUT + "' parameter missing."); info.setStatus(_st); Info.Detail detail = new Info.Detail(); info.setDetail(detail); getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML); return; } else { timeoutString = timeoutParam.getValue().trim(); try { timeout = Long.decode("0x" + timeoutString); } catch (NumberFormatException nfe) { } // if (timeout < 0 || timeout > 0xffffffff) { if (!Util.isUnsigned32(timeout)) { Info info = new Info(); Status _st = new Status(); _st.setCode((short) GatewayConstants.GENERAL_ERROR); _st.setMessage("Error: mandatory '" + Resources.URI_PARAM_TIMEOUT + "' parameter's value invalid. You provided: " + timeoutString); info.setStatus(_st); Info.Detail detail = new Info.Detail(); info.setDetail(detail); getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML); return; } } Parameter urilistenerParam = getRequest().getResourceRef().getQueryAsForm() .getFirst(Resources.URI_PARAM_URILISTENER); JoiningInfo joiningInfo; try { joiningInfo = Util.unmarshal(body, JoiningInfo.class); // Gal Manager check if (urilistenerParam == null) { proxyGalInterface = getRestManager().getClientObjectKey(-1, getClientInfo().getAddress()) .getGatewayInterface(); proxyGalInterface.permitJoinAll(timeout, joiningInfo.getPermitDuration()); Info info = new Info(); Status _st = new Status(); _st.setCode((short) GatewayConstants.SUCCESS); info.setStatus(_st); Info.Detail detail = new Info.Detail(); info.setDetail(detail); getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML); return; } else { // Async call. We know here that urilistenerParam is not null... urilistener = urilistenerParam.getValue(); // Process async. If urilistener equals "", don't send the // result but wait that the IPHA polls for it using the request // identifier. ClientResources rcmal = getRestManager() .getClientObjectKey(Util.getPortFromUriListener(urilistener), getClientInfo().getAddress()); proxyGalInterface = rcmal.getGatewayInterface(); rcmal.getClientEventListener().setPermitJoinDestination(urilistener); proxyGalInterface.permitJoinAll(timeout, joiningInfo.getPermitDuration()); Info.Detail detail = new Info.Detail(); Info infoToReturn = new Info(); Status status = new Status(); status.setCode((short) GatewayConstants.SUCCESS); infoToReturn.setStatus(status); infoToReturn.setRequestIdentifier(Util.getRequestIdentifier()); infoToReturn.setDetail(detail); getResponse().setEntity(Util.marshal(infoToReturn), MediaType.TEXT_XML); return; } } catch (Exception e1) { Info info = new Info(); Status _st = new Status(); _st.setCode((short) GatewayConstants.GENERAL_ERROR); _st.setMessage(e1.getMessage()); info.setStatus(_st); Info.Detail detail = new Info.Detail(); info.setDetail(detail); getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML); return; } }
From source file:com.emergya.persistenceGeo.web.RestZoneController.java
/** * Get all zones in a zone/* ww w .j ava2s .co m*/ * * @param idZone id zone to obtain children or null if you want all zones * * @return all zones if idZone is null or child zones of idZone otherwise */ @RequestMapping(value = "/persistenceGeo/getAllZones", method = RequestMethod.GET) public @ResponseBody Map<String, Object> getAllZones( @RequestParam(value = "idZone", required = false) String idZone) { Map<String, Object> result = new HashMap<String, Object>(); List<ZoneDto> zones = null; try { if (idZone == null) { zones = (List<ZoneDto>) zoneAdminService.findAllEnabled(); } else { zones = (List<ZoneDto>) zoneAdminService.findByParent(Long.decode(idZone), Boolean.TRUE); } result.put(SUCCESS, true); } catch (Exception e) { result.put(SUCCESS, false); } result.put(RESULTS, zones != null ? zones.size() : 0); result.put(ROOT, zones != null ? zones : ListUtils.EMPTY_LIST); return result; }
From source file:org.jboss.dashboard.ui.config.treeNodes.SectionNode.java
protected TreeNode listChildrenById(String id) { try {/*from w ww .ja va 2 s. c o m*/ Section s = ((WorkspaceImpl) getWorkspace()).getSection(Long.decode(id)); if (getSectionId().equals(s.getParentSectionId())) { return getNewSectionNode(s); } } catch (Exception e) { log.error("Error: ", e); } return null; }
From source file:org.jbpm.formModeler.core.processing.fieldHandlers.NumericFieldHandler.java
public Object getTheValue(Field field, String[] paramValue, String desiredClassName) throws Exception { if (paramValue == null || paramValue.length == 0) return null; if (desiredClassName.equals("byte")) { if (StringUtils.isEmpty(paramValue[0])) return new Byte((byte) 0); else//from w ww . j a v a 2 s . c om return Byte.decode(paramValue[0]); } else if (desiredClassName.equals("short")) { if (StringUtils.isEmpty(paramValue[0])) return new Short((short) 0); else return Short.decode(paramValue[0]); } else if (desiredClassName.equals("int")) { if (StringUtils.isEmpty(paramValue[0])) return new Integer(0); else return Integer.decode(paramValue[0]); } else if (desiredClassName.equals("long")) { if (StringUtils.isEmpty(paramValue[0])) return new Long(0L); else return Long.decode(paramValue[0]); } else if (desiredClassName.equals(Byte.class.getName())) { if (StringUtils.isEmpty(paramValue[0])) throw new EmptyNumberException(); return Byte.decode(paramValue[0]); } else if (desiredClassName.equals(Short.class.getName())) { if (StringUtils.isEmpty(paramValue[0])) throw new EmptyNumberException(); return Short.decode(paramValue[0]); } else if (desiredClassName.equals(Integer.class.getName())) { if (StringUtils.isEmpty(paramValue[0])) throw new EmptyNumberException(); return Integer.decode(paramValue[0]); } else if (desiredClassName.equals(Long.class.getName())) { if (StringUtils.isEmpty(paramValue[0])) throw new EmptyNumberException(); return Long.decode(paramValue[0]); } else if (desiredClassName.equals(Double.class.getName()) || desiredClassName.equals("double") || desiredClassName.equals(Float.class.getName()) || desiredClassName.equals("float") || desiredClassName.equals(BigDecimal.class.getName())) { if (StringUtils.isEmpty(paramValue[0])) throw new EmptyNumberException(); DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance(new Locale(LocaleManager.currentLang())); if (desiredClassName.equals(BigDecimal.class.getName())) df.setParseBigDecimal(true); String pattern = getFieldPattern(field); if (pattern != null && !"".equals(pattern)) { df.applyPattern(pattern); } else { df.applyPattern("###.##"); } ParsePosition pp = new ParsePosition(0); Number num = df.parse(paramValue[0], pp); if (paramValue[0].length() != pp.getIndex() || num == null) { log.debug("Error on parsing value"); throw new ParseException("Error parsing value", pp.getIndex()); } if (desiredClassName.equals(BigDecimal.class.getName())) { return num; } else if (desiredClassName.equals(Float.class.getName()) || desiredClassName.equals("float")) { return new Float(num.floatValue()); } else if (desiredClassName.equals(Double.class.getName()) || desiredClassName.equals("double")) { return new Double(num.doubleValue()); } } else if (desiredClassName.equals(BigInteger.class.getName())) { if (StringUtils.isEmpty(paramValue[0])) throw new EmptyNumberException(); return new BigInteger(paramValue[0]); } throw new IllegalArgumentException("Invalid class for NumericFieldHandler: " + desiredClassName); }