Example usage for java.lang Long Long

List of usage examples for java.lang Long Long

Introduction

In this page you can find the example usage for java.lang Long Long.

Prototype

@Deprecated(since = "9")
public Long(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Long object that represents the long value indicated by the String parameter.

Usage

From source file:com.redhat.rhn.domain.config.ConfigurationFactory.java

/**
 * Create a new ConfigRevision object.//  w  w w .ja va2s .  com
 * @return new ConfigRevision object
 */
public static ConfigRevision newConfigRevision() {
    ConfigRevision cr = new ConfigRevision();
    Date now = new Date();
    cr.setRevision(new Long(1));
    cr.setCreated(now);
    cr.setModified(now);
    return cr;
}

From source file:net.sf.sail.webapp.dao.sds.impl.SdsWorkgroupGetCommandHttpRestImpl.java

/**
 * @see net.sf.sail.webapp.dao.sds.SdsCommand#execute()
 *//*from w  w w. j  a v a2s . c o  m*/
@SuppressWarnings("unchecked")
public SdsWorkgroup execute(HttpGetRequest httpRequest) {
    //TODO LAW check on thread safety of these methods
    final SdsWorkgroup sdsWorkgroup = this.getSdsWorkgroup();
    SDS_WORKGROUP.set(null);
    Document doc = convertXmlInputStreamToXmlDocument(this.transport.get(httpRequest));
    if (doc == null) {
        return sdsWorkgroup;
    }

    Element sdsWorkgroupElement = doc.getRootElement();
    sdsWorkgroup.setName(sdsWorkgroupElement.getChild("name").getValue());
    sdsWorkgroup.setSdsObjectId(new Long(sdsWorkgroupElement.getChild("id").getValue()));

    SdsOffering sdsOffering = new SdsOffering();
    sdsOffering.setSdsObjectId(new Long(sdsWorkgroupElement.getChild("offering-id").getValue()));
    sdsWorkgroup.setSdsOffering(sdsOffering);

    HttpGetRequest sessionBundleRequest = this.generateSessionBundleRequest(sdsWorkgroup.getSdsObjectId(),
            sdsOffering.getSdsObjectId());
    sdsWorkgroup.setSdsSessionBundle(this.getSdsSessionBundle(sessionBundleRequest));
    return sdsWorkgroup;
}

From source file:test.gov.nih.nci.cacoresdk.domain.operations.SiteResourceTest.java

/**
 * Uses Nested Search Criteria for search
 * Verifies that the results are returned 
 * Verifies size of the result set//from w ww.  j  a  v a  2 s  .  c o  m
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

        Site searchObject = new Site();
        Collection results = getApplicationService().search("gov.nih.nci.cacoresdk.domain.operations.Site",
                searchObject);
        String id = "";

        if (results != null && results.size() > 0) {
            Site obj = (Site) ((List) results).get(0);

            Long idVal = obj.getId();

            id = new Long(idVal).toString();

        } else
            return;

        if (id.equals(""))
            return;

        String url = baseURL + "/rest/Site/" + id;

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("Site" + "XML.xml");

        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }

}

From source file:com.birt.airvantage.HistoricalDataConnector.java

public void loadHistoricalData(AVSystem d, AVRequest request, String dataId) {
    String historicalData = request.getMultiAgregatedDatapoints(dataId, d.uid);
    if (Parameters.DEBUG)
        System.out.println("historical:\n" + historicalData);
    JSONObject result;/*from   ww  w  .j av a2  s.c  o m*/
    try {
        result = new JSONObject(historicalData);
        JSONArray datapoints = result.getJSONObject(d.uid).getJSONArray(dataId);

        history = new ArrayList<AVTimestampedData>();
        for (int i = 0; i < datapoints.length(); i++) {
            Long value = null;
            if (!datapoints.getJSONObject(i).isNull("v"))
                value = new Long(datapoints.getJSONObject(i).getLong("v"));
            long timestamp = datapoints.getJSONObject(i).getLong("ts");
            AVTimestampedData data = new AVTimestampedData(d, value, new Date(timestamp));
            history.add(data);
        }
        //d.setHistoricalBlackInkLevel(dataHistory);

    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:info.magnolia.cms.util.NodeDataUtil.java

/**
 * Returns the value as an Object./*w w w.j a  v  a  2  s  .  c  om*/
 * @return Object
 */
public static Object getValue(NodeData nd) {
    try {
        switch (nd.getType()) {
        case (PropertyType.STRING):
            return nd.getString();
        case (PropertyType.DOUBLE):
            return new Double(nd.getDouble());
        case (PropertyType.LONG):
            return new Long(nd.getLong());
        case (PropertyType.BOOLEAN):
            return new Boolean(nd.getBoolean());
        case (PropertyType.DATE):
            return nd.getDate().getTime();
        case (PropertyType.BINARY):
            return null;
        default:
            return null;
        }
    } catch (Exception e) {
        if (log.isDebugEnabled())
            log.debug("Exception caught: " + e.getMessage(), e); //$NON-NLS-1$
    }
    return null;
}

From source file:com.redhat.rhn.manager.kickstart.KickstartSessionCreateCommand.java

/**
 * Constructor/*w w w  . j  a v  a2 s . c om*/
 * @param owner who creates the session
 * @param ksdata KickstartData profile used for this session
 * @param clientIp Client IP of the kickstarting system.
 */
public KickstartSessionCreateCommand(Org owner, KickstartData ksdata, String clientIp) {
    this.ksession = new KickstartSession();
    this.ksession.setKickstartMode(KickstartSession.MODE_DEFAULT_SESSION);
    this.ksession.setOrg(owner);
    this.ksession.setDeployConfigs(Boolean.FALSE);
    this.ksession.setPackageFetchCount(new Long(0));
    this.ksession.setKsdata(ksdata);
    this.ksession.setVirtualizationType(ksdata.getKickstartDefaults().getVirtualizationType());
    this.ksession.setKstree(ksdata.getTree());
    this.ksession.setLastAction(new Date());
    this.ksession.setState(KickstartFactory.SESSION_STATE_CREATED);
    this.ksession.setClientIp(clientIp);
    log.debug("serverProfile on ksdata: " + ksdata.getKickstartDefaults().getProfile());
    if (ksdata.getKickstartDefaults().getProfile() != null) {
        Profile p = ProfileManager.lookupByIdAndOrg(ksdata.getKickstartDefaults().getProfile().getId(), owner);
        log.debug("setting serverProfile on session: " + p.getId());
        this.ksession.setServerProfile(p);
    }

    log.debug("Saving new KickstartSession: " + this.ksession.getId());
    KickstartFactory.saveKickstartSession(this.ksession);
    log.debug("Saved new KickstartSession: " + this.ksession.getId());

    // Now create one time ActivationKey
    User user = UserFactory.findRandomOrgAdmin(owner);
    log.debug("Got random orgadmin: " + user.getLogin());
    String note = LocalizationService.getInstance().getMessage("kickstart.session.newtokennote", " ");

    Channel toolsChannel = KickstartScheduleCommand.getToolsChannel(ksdata, user, null);
    log.debug("creating one-time-activation key: " + user.getLogin());
    ActivationKey key = KickstartScheduleCommand.createKickstartActivationKey(user, ksdata, null, this.ksession,
            toolsChannel, BooleanUtils.toBoolean(ksdata.getKickstartDefaults().getCfgManagementFlag()), null,
            note);
    log.debug("added key: " + key.getKey());

    // Need to add child channels to the key so when kickstarting the
    // system from bare metal we will have the proper child channel subscriptions.
    if (ksdata.getKickstartDefaults().getProfile() != null) {
        log.debug("Checking child channels for packages in profile.");
        addChildChannelsForProfile(ksdata.getKickstartDefaults().getProfile(), ksdata.getChannel(), key);
    }
}

From source file:org.opentides.dao.impl.AuditLogDaoImpl.java

@Override
public void logEvent(String message, BaseEntity entity, boolean separateEm) {
    if (separateEm) {
        logEvent(message, entity);/*from  www . ja  v a 2  s.c  o m*/
    } else {
        Long userId = entity.getAuditUserId();
        String username = entity.getAuditUsername();

        if (ApplicationStartupListener.isApplicationStarted()) {
            if (userId == null) {
                _log.error("No userId specified for audit logging on object [" + entity.getClass().getName()
                        + "] for message [" + message + "]. Retrieving user from interceptor.");
                SessionUser user = SecurityUtil.getSessionUser();
                userId = user.getId();
                username = user.getUsername();
            }
        } else {
            userId = new Long(0);
            username = "System Evolve";
        }

        AuditLog record = new AuditLog(message, entity.getId(), entity.getClass(), entity.getReference(),
                userId, username);
        saveEntityModel(record);
    }
}

From source file:com.funtl.framework.smoke.core.modules.act.utils.DateConverter.java

/**
 * Convert String to Date//www.ja  v  a 2  s .  c o  m
 *
 * @param value
 * @return
 * @throws ParseException
 */
private Date doConvertToDate(Object value) throws ParseException {
    Date result = null;

    if (value instanceof String) {
        result = DateUtils.parseDate((String) value,
                new String[] { DATE_PATTERN, DATETIME_PATTERN, DATETIME_PATTERN_NO_SECOND, MONTH_PATTERN });

        // all patterns failed, try a milliseconds constructor
        if (result == null && StringUtils.isNotEmpty((String) value)) {

            try {
                result = new Date(new Long((String) value).longValue());
            } catch (Exception e) {
                logger.error("Converting from milliseconds to Date fails!");
                e.printStackTrace();
            }

        }

    } else if (value instanceof Object[]) {
        // let's try to convert the first element only
        Object[] array = (Object[]) value;

        if (array.length >= 1) {
            value = array[0];
            result = doConvertToDate(value);
        }

    } else if (Date.class.isAssignableFrom(value.getClass())) {
        result = (Date) value;
    }
    return result;
}

From source file:net.jradius.packet.attribute.AttributeFactory.java

private static RadiusAttribute attr(long type) throws InstantiationException, IllegalAccessException {
    RadiusAttribute attr = null;/*w  w  w  . j  a va  2  s .  c o m*/
    Class<?> c = attributeMap.get(new Long(type));

    if (c != null) {
        attr = (RadiusAttribute) c.newInstance();
    } else {
        RadiusLog.warn("Unknown Attribute: " + type);
        attr = new Attr_UnknownAttribute(type);
    }

    return attr;
}

From source file:hoot.services.models.osm.ElementFactory.java

/**
 * Creates an element/*from ww  w.  j a  v  a  2  s.  c  om*/
 *
 * @param elementType the type of element to create
 * @param conn JDBC Connection
 * @return an element
 * @throws ClassNotFoundException
 * @throws IllegalAccessException
 * @throws InstantiationException
 * @throws InvocationTargetException
 * @throws NoSuchMethodException
 */
public Element create(final long mapId, final ElementType elementType, Connection conn)
        throws InstantiationException, IllegalAccessException, ClassNotFoundException, NoSuchMethodException,
        InvocationTargetException {
    Long oMapId = new Long(mapId);
    return (Element) ConstructorUtils.invokeConstructor(
            Class.forName(ClassUtils.getPackageName(ElementFactory.class) + "." + elementType.toString()),
            new Object[] { oMapId, conn }, new Class<?>[] { Long.class, Connection.class });
}