List of usage examples for java.lang Integer longValue
public long longValue()
From source file:com.redhat.rhn.frontend.xmlrpc.system.SystemHandler.java
private ScriptRunAction lookupScriptRunAction(Integer actionId, User loggedInUser) { ScriptRunAction action = null;/*from w w w. jav a 2s . c o m*/ try { action = (ScriptRunAction) ActionManager.lookupAction(loggedInUser, new Long(actionId.longValue())); } catch (LookupException e) { throw new NoSuchActionException(actionId.toString(), e); } catch (ClassCastException e) { throw new InvalidActionTypeException(e); } return action; }
From source file:com.redhat.rhn.frontend.xmlrpc.system.SystemHandler.java
/** * Sets a list of kickstart variables for the specified server * * @param loggedInUser The current user//from www. java 2s .c om * @param serverId identifies the server * @param netboot netboot enabled * @param variables list of system kickstart variables to set * @return int - 1 on success, exception thrown otherwise * * @xmlrpc.doc Sets a list of kickstart variables in the cobbler system record * for the specified server. * Note: This call assumes that a system record exists in cobbler for the * given system and will raise an XMLRPC fault if that is not the case. * To create a system record over xmlrpc use system.createSystemRecord * * To create a system record in the Web UI please go to * System -> <Specified System> -> Provisioning -> * Select a Kickstart profile -> Create Cobbler System Record. * * * @xmlrpc.param #param("string", "sessionKey") * @xmlrpc.param #param("int", "serverId") * @xmlrpc.param #param("boolean","netboot") * @xmlrpc.param * #array() * #struct("kickstart variable") * #prop("string", "key") * #prop("string or int", "value") * #struct_end() * #array_end() * @xmlrpc.returntype #return_int_success() */ public int setVariables(User loggedInUser, Integer serverId, Boolean netboot, Map<String, Object> variables) { Server server = null; try { server = SystemManager.lookupByIdAndUser(serverId.longValue(), loggedInUser); } catch (LookupException e) { throw new NoSuchSystemException(); } if (!(server.hasEntitlement(EntitlementManager.PROVISIONING))) { throw new FaultException(-2, "provisionError", "System does not have provisioning entitlement"); } SystemRecord rec = SystemRecord.lookupById(CobblerXMLRPCHelper.getConnection(loggedInUser), server.getCobblerId()); if (rec == null) { throw new NoSuchCobblerSystemRecordException(); } rec.enableNetboot(netboot); rec.setKsMeta(variables); rec.save(); return 1; }
From source file:com.redhat.rhn.frontend.xmlrpc.system.SystemHandler.java
/** * Compares the packages installed on two systems. * * @param loggedInUser The current user/*from w w w. ja v a 2 s . co m*/ * @param sid1 This system's ID * @param sid2 Other system's ID * @return Array of PackageMetadata * * @xmlrpc.doc Compares the packages installed on two systems. * @xmlrpc.param #param("string", "sessionKey") * @xmlrpc.param #param("int", "thisServerId") * @xmlrpc.param #param("int", "otherServerId") * @xmlrpc.returntype * #array() * $PackageMetadataSerializer * #array_end() * */ public Object[] comparePackages(User loggedInUser, Integer sid1, Integer sid2) { Server target = null; Server source = null; try { target = SystemManager.lookupByIdAndUser(new Long(sid1.longValue()), loggedInUser); source = SystemManager.lookupByIdAndUser(new Long(sid2.longValue()), loggedInUser); } catch (LookupException e) { throw new NoSuchSystemException(); } // Check that the two systems are compatible for comparison: if (!isCompatible(loggedInUser, target, source)) { throw new InvalidSystemException(); } DataResult result = null; try { result = ProfileManager.compareServerToServer(new Long(sid1.longValue()), new Long(sid2.longValue()), loggedInUser.getOrg().getId(), null); } catch (MissingEntitlementException e) { throw new com.redhat.rhn.frontend.xmlrpc.MissingEntitlementException(); } return result.toArray(); }
From source file:edu.ku.brc.specify.tasks.WorkbenchTask.java
/** * Finds the Rollover command that represents the item that has the passed in Record id and * it is checking the CommandAction's attr by name for the RecordSet * @param workbench// w w w. j a v a2 s . c o m * @return */ protected int getCountOfPanesForTemplate(final Integer templateId) { int count = 0; for (SubPaneIFace sbi : SubPaneMgr.getInstance().getSubPanes()) { if (sbi.getTask() == this && sbi instanceof WorkbenchPaneSS) { WorkbenchPaneSS wbp = (WorkbenchPaneSS) sbi; // XXX Ran into a Bug I can't duplicate so this // should help me track it down the follow should never be NULL // but one of them was null if (templateId == null) { log.error("templateId is null"); return count; } if (wbp.getWorkbench() == null) { log.error("wbp.getWorkbench() is null"); return count; } if (wbp.getWorkbench().getWorkbenchTemplate() == null) { log.error("wbp.getWorkbench().getWorkbenchTemplate() is null"); return count; } if (wbp.getWorkbench().getWorkbenchTemplate().getWorkbenchTemplateId() == null) { log.error("wbp.getWorkbench().getWorkbenchTemplate().getWorkbenchTemplateId() is null"); return count; } // END DEBUG if (wbp.getWorkbench().getWorkbenchTemplate().getWorkbenchTemplateId().longValue() == templateId .longValue()) { count++; } } } return count; }
From source file:com.redhat.rhn.frontend.xmlrpc.system.SystemHandler.java
/** * Schedule a script to run./*from w ww . j a va2s .c om*/ * * @param loggedInUser The current user * @param systemIds IDs of the servers to run the script on. * @param username User to run script as. * @param groupname Group to run script as. * @param timeout Seconds to allow the script to run before timing out. * @param script Contents of the script to run. * @param earliest Earliest the script can run. * @return ID of the new script action. * * @xmlrpc.doc Schedule a script to run. * @xmlrpc.param #param("string", "sessionKey") * @xmlrpc.param #array_single("int", "System IDs of the servers to run the script on.") * @xmlrpc.param #param_desc("string", "username", "User to run script as.") * @xmlrpc.param #param_desc("string", "groupname", "Group to run script as.") * @xmlrpc.param #param_desc("int", "timeout", "Seconds to allow the script to run * before timing out.") * @xmlrpc.param #param_desc("string", "script", "Contents of the script to run.") * @xmlrpc.param #param_desc("dateTime.iso8601", "earliestOccurrence", * "Earliest the script can run.") * @xmlrpc.returntype int - ID of the script run action created. Can be used to fetch * results with system.getScriptResults. */ public Integer scheduleScriptRun(User loggedInUser, List<Integer> systemIds, String username, String groupname, Integer timeout, String script, Date earliest) { ScriptActionDetails scriptDetails = ActionManager.createScript(username, groupname, new Long(timeout.longValue()), script); ScriptAction action = null; List<Long> servers = new ArrayList<Long>(); for (Iterator<Integer> sysIter = systemIds.iterator(); sysIter.hasNext();) { Integer sidAsInt = sysIter.next(); Long sid = new Long(sidAsInt.longValue()); Server server = null; try { server = SystemManager.lookupByIdAndUser(new Long(sid.longValue()), loggedInUser); servers.add(sid); } catch (LookupException e) { throw new NoSuchSystemException(); } } try { action = ActionManager.scheduleScriptRun(loggedInUser, servers, null, scriptDetails, earliest); } catch (MissingCapabilityException e) { throw new com.redhat.rhn.frontend.xmlrpc.MissingCapabilityException(); } catch (MissingEntitlementException e) { throw new com.redhat.rhn.frontend.xmlrpc.MissingEntitlementException(); } return new Integer(action.getId().intValue()); }
From source file:com.redhat.rhn.frontend.xmlrpc.system.SystemHandler.java
/** * Remove addon entitlements from a server. * * @param loggedInUser The current user/*from w w w . j a v a2 s. c o m*/ * @param serverId ID of server. * @param entitlements List of addon entitlement labels to remove. * @return 1 on success, exception thrown otherwise. * * @xmlrpc.doc Remove addon entitlements from a server. Entitlements a server does * not have are quietly ignored. * @xmlrpc.param #param("string", "sessionKey") * @xmlrpc.param #param("int", "serverId") * @xmlrpc.param #array_single("string", "entitlement_label") * @xmlrpc.returntype #return_int_success() */ public int removeEntitlements(User loggedInUser, Integer serverId, List<String> entitlements) { boolean needsSnapshot = false; Server server = null; try { server = SystemManager.lookupByIdAndUser(new Long(serverId.longValue()), loggedInUser); } catch (LookupException e) { throw new NoSuchSystemException(); } validateEntitlements(entitlements); List<Entitlement> baseEnts = new LinkedList<Entitlement>(); for (Iterator<String> it = entitlements.iterator(); it.hasNext();) { Entitlement ent = EntitlementManager.getByName(it.next()); if (ent.isBase()) { baseEnts.add(ent); continue; } SystemManager.removeServerEntitlement(server.getId(), ent); needsSnapshot = true; } // process base entitlements at the end if (!baseEnts.isEmpty()) { // means unentile the whole system SystemManager.removeAllServerEntitlements(server.getId()); needsSnapshot = true; } if (needsSnapshot) { SystemManager.snapshotServer(server, LocalizationService.getInstance().getMessage("snapshots.entitlements")); } return 1; }
From source file:com.redhat.rhn.frontend.xmlrpc.system.SystemHandler.java
/** * Add addon entitlements to a server. Entitlements a server already has are simply * ignored.// w w w . j a v a 2 s. co m * * @param loggedInUser The current user * @param serverId ID of server. * @param entitlements List of addon entitlement labels to add. * @return 1 on success, exception thrown otherwise. * * @xmlrpc.doc Add entitlements to a server. Entitlements a server already has * are quietly ignored. * @xmlrpc.param #param("string", "sessionKey") * @xmlrpc.param #param("int", "serverId") * @xmlrpc.param #array_single("string", "entitlementLabel - one of following: * provisioning_entitled, virtualization_host, * virtualization_host_platform, enterprise_entitled") * @xmlrpc.returntype #return_int_success() */ public int addEntitlements(User loggedInUser, Integer serverId, List<String> entitlements) { boolean needsSnapshot = false; Server server = null; try { server = SystemManager.lookupByIdAndUser(new Long(serverId.longValue()), loggedInUser); } catch (LookupException e) { throw new NoSuchSystemException(); } validateEntitlements(entitlements); // Check that we're not adding virt or virt platform to a system that already has // the other: if (server.hasEntitlement(EntitlementManager.VIRTUALIZATION) && entitlements.contains(EntitlementManager.VIRTUALIZATION_PLATFORM_ENTITLED)) { throw new InvalidEntitlementException(); } if (server.hasEntitlement(EntitlementManager.VIRTUALIZATION_PLATFORM) && entitlements.contains(EntitlementManager.VIRTUALIZATION_ENTITLED)) { throw new InvalidEntitlementException(); } List<String> addOnEnts = new LinkedList<String>(entitlements); // first process base entitlements for (Entitlement en : EntitlementManager.getBaseEntitlements()) { if (addOnEnts.contains(en.getLabel())) { addOnEnts.remove(en.getLabel()); server.setBaseEntitlement(en); } } // put a more intelligible exception if ((server.getBaseEntitlement() == null) && (!addOnEnts.isEmpty())) { throw new InvalidEntitlementException("Base entitlement missing"); } for (Iterator<String> it = addOnEnts.iterator(); it.hasNext();) { Entitlement ent = EntitlementManager.getByName(it.next()); // Ignore if the system already has this entitlement: if (server.hasEntitlement(ent)) { log.debug("System " + server.getName() + " already has entitlement: " + ent.getLabel()); continue; } if (SystemManager.canEntitleServer(server, ent)) { ValidatorResult vr = SystemManager.entitleServer(server, ent); needsSnapshot = true; if (vr.getErrors().size() > 0) { throw new InvalidEntitlementException(); } } else { throw new InvalidEntitlementException(); } } if (needsSnapshot) { SystemManager.snapshotServer(server, LocalizationService.getInstance().getMessage("snapshots.entitlements")); } return 1; }
From source file:com.redhat.rhn.frontend.xmlrpc.system.SystemHandler.java
/** * Sets the base channel for the given server to the given channel * @param loggedInUser The current user/*from w w w.j av a2 s .c o m*/ * @param sid The id for the server * @param cid The id for the channel * @return Returns 1 if successful, exception otherwise * @throws FaultException A FaultException is thrown if: * - the server corresponding to sid cannot be found. * - the channel corresponding to cid is not a base channel. * - the user doesn't have subscribe access to either the current or * the new base channel. * @deprecated being replaced by system.setBaseChannel(string sessionKey, * int serverId, string channelLabel) * * @xmlrpc.doc Assigns the server to a new baseChannel. * @xmlrpc.param #param("string", "sessionKey") * @xmlrpc.param #param("int", "serverId") * @xmlrpc.param #param("int", "channelId") * @xmlrpc.returntype #return_int_success() */ @Deprecated public int setBaseChannel(User loggedInUser, Integer sid, Integer cid) throws FaultException { //Get the logged in user and server Server server = lookupServer(loggedInUser, sid); UpdateBaseChannelCommand cmd = new UpdateBaseChannelCommand(loggedInUser, server, new Long(cid.longValue())); ValidatorError ve = cmd.store(); if (ve != null) { throw new InvalidChannelException( LocalizationService.getInstance().getMessage(ve.getKey(), ve.getValues())); } return 1; }
From source file:com.redhat.rhn.frontend.xmlrpc.system.SystemHandler.java
/** * Sync packages from a source system to a target. * * @param loggedInUser The current user/*from w ww . j ava 2 s . co m*/ * @param targetServerId Target system to apply package changes to. * @param sourceServerId Source system to retrieve package state from. * @param packageIds List of package IDs to be synced. * @param earliest Earliest occurrence of action. * @return action id, exception thrown otherwise * @since 13.0 * * @xmlrpc.doc Sync packages from a source system to a target. * @xmlrpc.param #param("string", "sessionKey") * @xmlrpc.param #param_desc("int", "targetServerId", "Target system to apply package * changes to.") * @xmlrpc.param #param_desc("int", "sourceServerId", "Source system to retrieve * package state from.") * @xmlrpc.param #array_single("int", "packageId - Package IDs to be synced.") * @xmlrpc.param #param_desc("dateTime.iso8601", "date", "Date to schedule action for") * @xmlrpc.returntype int actionId - The action id of the scheduled action */ public Long scheduleSyncPackagesWithSystem(User loggedInUser, Integer targetServerId, Integer sourceServerId, List<Integer> packageIds, Date earliest) { Server target = null; Server source = null; try { target = SystemManager.lookupByIdAndUser(new Long(targetServerId.longValue()), loggedInUser); source = SystemManager.lookupByIdAndUser(new Long(sourceServerId.longValue()), loggedInUser); } catch (LookupException e) { throw new NoSuchSystemException(); } if (!isCompatible(loggedInUser, target, source)) { throw new InvalidSystemException(); } // For each of the package ids provided, retrieve the pkg id combo // which includes name_id|evr_id|arch_id Set<String> pkgIdCombos = new HashSet<String>(); for (Iterator<Integer> it = packageIds.iterator(); it.hasNext();) { Integer i = it.next(); Package pkg = PackageManager.lookupByIdAndUser(i.longValue(), loggedInUser); if (pkg != null) { StringBuilder idCombo = new StringBuilder(); idCombo.append(pkg.getPackageName().getId()).append("|"); if (pkg.getPackageEvr() != null) { idCombo.append(pkg.getPackageEvr().getId()).append("|"); } if (pkg.getPackageArch() != null) { idCombo.append(pkg.getPackageArch().getId()); } pkgIdCombos.add(idCombo.toString()); } } Action action = null; try { action = ProfileManager.syncToSystem(loggedInUser, new Long(targetServerId.longValue()), new Long(sourceServerId.longValue()), pkgIdCombos, null, earliest); } catch (MissingEntitlementException e) { throw new com.redhat.rhn.frontend.xmlrpc.MissingEntitlementException(); } if (action == null) { throw new InvalidParameterException("No packages to sync"); } return action.getId(); }
From source file:org.egov.services.payment.PaymentService.java
@Transactional public List<InstrumentHeader> reassignInstrument(final List<ChequeAssignment> chequeAssignmentList, final String paymentMode, final Integer bankaccount, final Map<String, String[]> parameters, final Department dept) throws ApplicationRuntimeException, Exception { if (LOGGER.isDebugEnabled()) LOGGER.debug("Starting reassignInstrument..."); List<InstrumentHeader> instHeaderList = new ArrayList<InstrumentHeader>(); final List<Long> selectedPaymentVHList = new ArrayList<Long>(); final Map<String, BigDecimal> payeeMap = new HashMap<String, BigDecimal>(); BigDecimal totalPaidAmt = BigDecimal.ZERO; for (final ChequeAssignment assignment : chequeAssignmentList) if (assignment.getIsSelected()) { selectedPaymentVHList.add(assignment.getVoucherid()); if (payeeMap.containsKey(assignment.getPaidTo() + DELIMETER + assignment.getDetailtypeid() + DELIMETER + assignment.getDetailkeyid())) // concatenate the // amount, if the // party's are same payeeMap.put(//from w w w . ja va 2 s . c o m assignment.getPaidTo() + DELIMETER + assignment.getDetailtypeid() + DELIMETER + assignment.getDetailkeyid(), payeeMap.get(assignment.getPaidTo() + DELIMETER + assignment.getDetailtypeid() + DELIMETER + assignment.getDetailkeyid()).add(assignment.getPaidAmount())); else payeeMap.put(assignment.getPaidTo() + DELIMETER + assignment.getDetailtypeid() + DELIMETER + assignment.getDetailkeyid(), assignment.getPaidAmount()); totalPaidAmt = totalPaidAmt.add(assignment.getPaidAmount()); } if (LOGGER.isDebugEnabled()) LOGGER.debug("selectedPaymentList===" + selectedPaymentVHList); final Bankaccount account = (Bankaccount) persistenceService.find(" from Bankaccount where id=?", bankaccount.longValue()); // get voucherList final List<CVoucherHeader> voucherList = persistenceService.findAllByNamedQuery("getVoucherList", selectedPaymentVHList); new ArrayList<Map<String, Object>>(); final List<Map<String, Object>> instrumentVoucherList = new ArrayList<Map<String, Object>>(); if (paymentMode.equals(FinancialConstants.MODEOFPAYMENT_CHEQUE)) { final Map<Long, CVoucherHeader> paymentVoucherMap = new HashMap<Long, CVoucherHeader>(); for (final CVoucherHeader voucherHeader : voucherList) paymentVoucherMap.put(voucherHeader.getId(), voucherHeader); String text = ""; final Map<String, BigDecimal> partyChequeNoMap = new HashMap<String, BigDecimal>(); for (final ChequeAssignment assignment : chequeAssignmentList) if (assignment.getIsSelected()) { text = assignment.getPaidTo() + DELIMETER + assignment.getDetailtypeid() + DELIMETER + assignment.getDetailkeyid() + DELIMETER + assignment.getChequeNumber() + DELIMETER + formatter.format(assignment.getChequeDate()) + DELIMETER + assignment.getSerialNo(); if (partyChequeNoMap.containsKey(text)) partyChequeNoMap.put(text, partyChequeNoMap.get(text).add(assignment.getPaidAmount())); else partyChequeNoMap.put(text, assignment.getPaidAmount()); } instHeaderList = new ArrayList<InstrumentHeader>(); final Iterator iterator = partyChequeNoMap.keySet().iterator(); String key; while (iterator.hasNext()) // create instrument header { key = iterator.next().toString(); instHeaderList.add(reassignInstrumentHeader(account, key.split(DELIMETER)[3], FinancialConstants.MODEOFPAYMENT_CHEQUE.toLowerCase(), key.split(DELIMETER)[0], partyChequeNoMap.get(key), formatter.parse(key.split(DELIMETER)[4]), key, key.split(DELIMETER)[5])); } // instHeaderList = // instrumentService.addToInstrument(instrumentHeaderList); // create instrument voucher for (final ChequeAssignment assignment : chequeAssignmentList) if (assignment.getIsSelected()) instrumentVoucherList.add(reassignInstrumentVoucher( paymentVoucherMap.get(assignment.getVoucherid()), account, assignment.getChequeNumber(), assignment.getPaidTo(), assignment.getSerialNo())); instVoucherList = instrumentService.updateInstrumentVoucherReference(instrumentVoucherList); // end of manual cheque number } else // if it's cash or RTGS { instHeaderList.add(reassignInstrumentHeader(account, parameters.get("chequeNo")[0], FinancialConstants.MODEOFPAYMENT_CHEQUE.toLowerCase(), parameters.get("inFavourOf")[0], totalPaidAmt, formatter.parse(parameters.get("chequeDt")[0]), "", parameters.get("serialNo")[0])); reassignInstrumentVoucher(null, account, parameters.get("chequeNo")[0], parameters.get("inFavourOf")[0], parameters.get("serialNo")[0]); // instHeaderList = // instrumentService.addToInstrument(instrumentHeaderList); final List<Paymentheader> paymentList = persistenceService.findAllByNamedQuery("getPaymentList", selectedPaymentVHList); Map<String, Object> instrumentVoucherMap = null; for (final Paymentheader paymentheader : paymentList) { instrumentVoucherMap = new HashMap<String, Object>(); instrumentVoucherMap.put(VoucherConstant.VOUCHER_HEADER, paymentheader.getVoucherheader()); instrumentVoucherMap.put(VoucherConstant.INSTRUMENT_HEADER, instHeaderList.get(0)); instrumentVoucherList.add(instrumentVoucherMap); } instVoucherList = instrumentService.updateInstrumentVoucherReference(instrumentVoucherList); } if (LOGGER.isDebugEnabled()) LOGGER.debug("Completed reassignInstrument."); return instHeaderList; }