Example usage for java.lang Long toString

List of usage examples for java.lang Long toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this Long 's value.

Usage

From source file:net.firejack.platform.service.registry.helper.PackageVersionHelper.java

/**
 * @param packageId/*from w w  w  . j  av  a2s .c  om*/
 * @param version
 * @return
 */
public boolean existsVersion(Long packageId, Integer version) {
    return OPFEngine.FileStoreService.getInfo(OpenFlame.FILESTORE_BASE, helper.getVersion(),
            packageId.toString(), version.toString()) != null;
}

From source file:net.firejack.platform.service.registry.helper.PackageVersionHelper.java

/**
 * @param packageId/*from   w  ww. j  ava  2s .  c  o m*/
 * @param version
 */
public void remove(Long packageId, Integer version) {
    OPFEngine.FileStoreService.deleteDirectory(OpenFlame.FILESTORE_BASE, helper.getVersion(),
            packageId.toString(), version.toString());
}

From source file:de.decidr.workflowmodeleditor.server.servicetask.WSDLUploadServletImpl.java

@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    /* Make sure that session is valid and field set (by WebPortal) */
    if (request.getSession().getAttribute("authenticatedUser") == null) {
        response.getWriter().write("Invalid authentication!");
        return;//from   w  w w. ja v  a2 s. c o  m
    } else {
        callingUser = new UserRole((Long) request.getSession().getAttribute("authenticatedUser"));
    }

    boolean isMultipart = ServletFileUpload.isMultipartContent(new ServletRequestContext(request));
    if (isMultipart) {
        FileItemStream uploadItem = getFileItem(request);
        if (uploadItem == null) {
            super.service(request, response);
            return;
        }

        response.setContentType("text/plain");
        FileFacade ff = new FileFacade(callingUser);
        InputStream data = receiveUpload(uploadItem.openStream());
        Set<Class<? extends FilePermission>> publicPermissions = new HashSet<Class<? extends FilePermission>>();
        publicPermissions.add(FileReadPermission.class);
        try {
            Long fileID = ff.createFile(data, (long) data.available(), uploadItem.getName(),
                    uploadItem.getContentType(), false, publicPermissions);
            response.getWriter().write(fileID.toString());
        } catch (TransactionException e) {
            e.printStackTrace();
            response.getWriter().write("Failed due to transaction exception!");
        }

    } else {
        super.service(request, response);
    }
}

From source file:com.aliyun.odps.ship.common.RecordConverter.java

/**
 * tunnel record to byte[] array/*from w w  w .  ja  v  a  2s. com*/
 */
public byte[][] format(Record r) throws UnsupportedEncodingException {

    int cols = schema.getColumns().size();
    byte[][] line = new byte[cols][];
    byte[] colValue = null;
    for (int i = 0; i < cols; i++) {

        OdpsType t = schema.getColumn(i).getType();
        switch (t) {
        case BIGINT: {
            Long v = r.getBigint(i);
            colValue = v == null ? null : v.toString().getBytes(defaultCharset);
            break;
        }
        case DOUBLE: {
            Double v = r.getDouble(i);
            if (v == null) {
                colValue = null;
            } else if (v.equals(Double.POSITIVE_INFINITY) || v.equals(Double.NEGATIVE_INFINITY)) {
                colValue = v.toString().getBytes(defaultCharset);
            } else {
                colValue = doubleFormat.format(v).replaceAll(",", "").getBytes(defaultCharset);
            }
            break;
        }
        case DATETIME: {
            Date v = r.getDatetime(i);
            if (v == null) {
                colValue = null;
            } else {
                colValue = dateFormatter.format(v).getBytes(defaultCharset);
            }
            break;
        }
        case BOOLEAN: {
            Boolean v = r.getBoolean(i);
            colValue = v == null ? null : v.toString().getBytes(defaultCharset);
            break;
        }
        case STRING: {
            byte[] v = r.getBytes(i);
            if (v == null) {
                colValue = null;
            } else if (Util.isIgnoreCharset(charset)) {
                colValue = v;
            } else {
                // data at ODPS side is always utf-8
                colValue = new String(v, Constants.REMOTE_CHARSET).getBytes(charset);
            }
            break;
        }
        case DECIMAL: {
            BigDecimal v = r.getDecimal(i);
            colValue = v == null ? null : v.toPlainString().getBytes(defaultCharset);
            break;
        }
        default:
            throw new RuntimeException("Unknown column type: " + t);
        }

        if (colValue == null) {
            line[i] = nullBytes;
        } else {
            line[i] = colValue;
        }
    }
    return line;
}

From source file:com.bsb.cms.moss.controller.content.ContContentController.java

/**
 * //from  w ww.  j a  v a2s.c  o m
 * 
 * @param content  
 * @param contentBody 
 * @param modelMap  
 * @return
 */
@RequestMapping(value = "create.htm", method = RequestMethod.POST)
@ResponseBody
public JSONResultDTO create(ContContent content, String contentBody, ModelMap modelMap) {
    JSONResultDTO result = new JSONResultDTO();
    ContContentBody contContentBody = null;
    try {
        if (StringUtils.isNotBlank(contentBody)) {
            String[] htmls = imgRemot2Location.transfer(contentBody, content.getKeyword());
            contContentBody = new ContContentBody(htmls[1]);
            if (StringUtils.isNotBlank(htmls[0])) {
                content.setDefaultImg(htmls[0]);
            }
        }
        try {
            ContentAndTypeUtils.setAllParentId(contTypeCacheService, content);//14?id
            content.setStatus(ContentEnum.DEPLOY.getCode());
            content.setContentUrl(PublishUtil.getCtURL(null));
            Long id = contContentService.create(content, contContentBody);
            content.setContentUrl(content.getContentUrl() + id.toString() + ".html");//TODO
            contContentPublisherService.publishContent(PublishUtil.translateContent(content, contContentBody));

            log(OperateTypeEnum.CONTENT_CREATE, "id:" + id, "");
        } catch (RenameRuntimeException e) {
            result.setMessage("???");
            result.setResult(JSONResultDTO.ERROR);
        }

    } catch (Exception e) {
        result.setMessage(".???");
        result.setResult(JSONResultDTO.ERROR);
        log.error(e.getMessage(), e.getCause());
        e.printStackTrace();
    }

    return result;
}

From source file:net.firejack.platform.service.registry.broker.package_.ActivatePackageVersionBroker.java

@Override
protected ServiceResponse<Package> perform(ServiceRequest<NamedValues> request) throws Exception {
    Long packageId = (Long) request.getData().get("packageId");
    Integer version = (Integer) request.getData().get("version");

    PackageModel packageRN = packageStore.findById(packageId);

    String packageVersionFolder = FileUtils.construct(helper.getVersion(), packageId.toString(),
            version.toString());/*from   w  w w . j a v a2  s . c o  m*/

    InputStream packageXmlFile = OPFEngine.FileStoreService.download(OpenFlame.FILESTORE_BASE,
            packageRN.getName() + PackageFileType.PACKAGE_XML.getDotExtension(), packageVersionFolder);
    InputStream resourceZipFile = OPFEngine.FileStoreService.download(OpenFlame.FILESTORE_BASE,
            packageRN.getName() + PackageFileType.RESOURCE_ZIP.getDotExtension(), packageVersionFolder);

    StatusProviderTranslationResult result = packageInstallationService.activatePackage(packageXmlFile,
            resourceZipFile);
    IOUtils.closeQuietly(packageXmlFile);
    IOUtils.closeQuietly(resourceZipFile);

    if (result.getResult()) {
        Integer oldVersion = packageRN.getVersion();
        packageRN = packageStore.updatePackageVersion(packageId, version);
        try {
            packageVersionHelper.archiveVersion(packageRN, oldVersion, result.getOldPackageXml());
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        }
    }

    Package packageVO = factory.convertTo(Package.class, packageRN);
    PackageVersion packageVersionVO = packageVersionHelper.populatePackageVersion(packageRN);
    packageVO.setPackageVersion(packageVersionVO);
    return new ServiceResponse<Package>(packageVO, "activate package version successfully", true);
}

From source file:com.ushahidi.swiftriver.core.api.service.DropIndexService.java

/**
 * Deletes the collection of {@link DropDocument} entities whose IDs are
 * in the {@link List} specified in <code>dropIds</code> from the search index
 * /*from   ww w.ja va2s.co  m*/
 * @param dropIds
 */
@Transactional(readOnly = false)
public void deleteAllFromIndex(List<Long> dropIds) {
    logger.debug("Deleting documents with IDs {} from the search index", dropIds);

    List<String> documentIds = new ArrayList<String>();
    for (Long dropId : dropIds) {
        documentIds.add(dropId.toString());
    }

    // Find all drop documents with the specified IDs
    List<DropDocument> dropDocuments = repository.findAll(documentIds);
    if (dropDocuments.isEmpty()) {
        logger.debug("No documents found in the search index");
        return;
    }

    repository.delete(dropDocuments);

    logger.debug("Successfully deleted {} documents from the search index", dropDocuments.size());
}

From source file:com.loy.MainFrame.java

void killProcess() {
    for (Long pid : pids) {
        try {/*from w w  w  .  ja  v a2s. com*/
            if (Processes.isProcessRunning(platform, pid)) {
                File pidFile = new File("./pids/" + pid.toString());
                pidFile.deleteOnExit();
                if (Platform.Windows == platform) {
                    Processes.tryKillProcess(null, platform, new NullProcessor(), pid);
                } else {
                    Processes.killProcess(null, platform, new NullProcessor(), pid);
                }
            }
        } catch (Exception ex) {
        }
    }
}

From source file:net.softforlife.klich.ws.service.impl.KlichWSLocalImpl.java

@Override
public ResultWSMessage replaceGeopoint(String s) {
    logger.info("Vamos a reemplazar un Geopoint: " + s);

    ResultWSMessage result = new ResultWSMessage();

    Geopoint geopoint = Geopoint.parse(s);

    if (geopoint.getTrackId() != null) {
        Long id = wsDataService.replaceGeopoint(geopoint);
        if (id != null) {
            result.setMessage(id.toString());
        } else {//from w  w  w.  jav a  2 s.c o  m
            result.setMessage("FAIL");
        }
    } else {
        result.setMessage("FAIL");
    }

    return result;
}