Java 类com.liferay.portal.kernel.util.FileUtil 实例源码

项目:ch-inofix-timetracker    文件:TaskRecordLocalServiceImpl.java   
@Override
public void importTaskRecords(ExportImportConfiguration exportImportConfiguration, InputStream inputStream)
        throws PortalException {

    File file = null;

    try {
        file = FileUtil.createTempFile("lar");

        FileUtil.write(file, inputStream);

        importTaskRecords(exportImportConfiguration, file);

    } catch (IOException ioe) {
        throw new SystemException(ioe);
    } finally {
        FileUtil.delete(file);
    }
}
项目:ch-inofix-contact-manager    文件:ContactLocalServiceImpl.java   
@Override
public void importContacts(ExportImportConfiguration exportImportConfiguration, InputStream inputStream)
        throws PortalException {

    File file = null;

    try {
        file = FileUtil.createTempFile("lar");

        FileUtil.write(file, inputStream);

        importContacts(exportImportConfiguration, file);

    } catch (IOException ioe) {
        throw new SystemException(ioe);
    } finally {
        FileUtil.delete(file);
    }
}
项目:ch-inofix-contact-manager    文件:ContactLocalServiceImpl.java   
@Override
public long importContactsInBackground(long userId, ExportImportConfiguration exportImportConfiguration,
        InputStream inputStream, String extension) throws PortalException {

    File file = null;

    try {

        file = FileUtil.createTempFile(extension);

        FileUtil.write(file, inputStream);

        return importContactsInBackground(userId, exportImportConfiguration, file);

    } catch (IOException ioe) {
        throw new SystemException(ioe);
    } finally {
        FileUtil.delete(file);
    }
}
项目:opencps-v2    文件:UserActions.java   
@Override
public File uploadPhoto(long userId, long companyId, long groupId, long id, InputStream inputStream,
        String fileName, String fileType, long fileSize, String destination, String desc,
        ServiceContext serviceContext) throws Exception {
    File file = null;

    FileEntry fileEntry = FileUploadUtils.uploadFile(userId, companyId, groupId, inputStream, fileName, fileType,
            fileSize, destination, desc, serviceContext);

    User user = UserLocalServiceUtil.fetchUser(id);

    file = DLFileEntryLocalServiceUtil.getFile(fileEntry.getFileEntryId(), fileEntry.getVersion(), false);

    UserLocalServiceUtil.updatePortrait(user.getUserId(), FileUtil.getBytes(file));

    return file;
}
项目:ch-inofix-data-manager    文件:MeasurementLocalServiceImpl.java   
@Override
public void importMeasurements(
        ExportImportConfiguration exportImportConfiguration,
        InputStream inputStream) throws PortalException {

    _log.info("importMeasurements()");

    File file = null;

    try {

        // TODO: use extension from upload
        file = FileUtil.createTempFile("lar");

        FileUtil.write(file, inputStream);

        importMeasurements(exportImportConfiguration, file);

    } catch (IOException ioe) {
        throw new SystemException(ioe);
    } finally {
        FileUtil.delete(file);
    }
}
项目:ch-inofix-data-manager    文件:MeasurementLocalServiceImpl.java   
@Override
public long importMeasurementsInBackground(long userId,
        ExportImportConfiguration exportImportConfiguration,
        InputStream inputStream, String extension) throws PortalException {

    _log.info("importMeasurementsInBackground()");

    File file = null;

    try {

        file = FileUtil.createTempFile(extension);

        FileUtil.write(file, inputStream);

        return importMeasurementsInBackground(userId,
                exportImportConfiguration, file);

    } catch (IOException ioe) {
        throw new SystemException(ioe);
    } finally {
        FileUtil.delete(file);
    }
}
项目:govapps    文件:MultiMediaLocalServiceImpl.java   
public MultiMedia addMultiMedia(MultiMedia multiMedia, File imageFile) throws SystemException, PortalException {
        long multiMediaId = CounterLocalServiceUtil.increment(MultiMedia.class.getName());
        MultiMedia model =  multiMediaPersistence.create(multiMediaId);
        model.setUserId(multiMedia.getUserId());
        model.setCompanyId(multiMedia.getCompanyId());
        model.setCreateDate(new Date());
        model.setModifiedDate(new Date());
        model.setApplicationId(multiMedia.getApplicationId());
        model.setName(multiMedia.getName());
        model.setType(multiMedia.getType());
        try {

//          DLAppLocalServiceUtil.addFileEntry(userId, repositoryId, folderId, sourceFileName, mimeType, title, description, changeLog, imageFile, serviceContext);
//          DLAppLocalServiceUtil.addFileEntry(userId, repositoryId, folderId, imageFile.getName(), mimeType, title, description, changeLog, imageFile, serviceContext);
            byte[] imageBytes = null;
            imageBytes = FileUtil.getBytes(imageFile);
            model.setImageId(counterLocalService.increment());
            _log.debug("addLink::imageBytes.length: "  + imageBytes.length);
            saveImages(model.getImageId(), imageFile, imageBytes);
        } catch (Exception e) {
            _log.info(e.toString());
        }
        return multiMediaPersistence.update(model, true);
    }
项目:govapps    文件:MultiMediaLocalServiceImpl.java   
public MultiMedia updateMultiMedia(MultiMedia multiMedia, File imageFile) throws SystemException {
    MultiMedia model =  multiMediaPersistence.fetchByPrimaryKey(multiMedia.getMultiMediaId());
    model.setUserId(multiMedia.getUserId());
    model.setCompanyId(multiMedia.getCompanyId());
    model.setApplicationId(multiMedia.getApplicationId());
    model.setType(multiMedia.getType());
    model.setModifiedDate(new Date());
    try {
        byte[] imageBytes = null;
        imageBytes = FileUtil.getBytes(imageFile);
        model.setImageId(counterLocalService.increment());
        _log.debug("addLink::imageBytes.length: "  + imageBytes.length);
        _log.debug("imageFile.getName(): "  + imageFile.getName());
        model.setName(imageFile.getName());

        saveImages(model.getImageId(), imageFile, imageBytes);
    } catch (Exception e) {
        _log.info(e.toString());
    }
    return multiMediaPersistence.update(model, true);       
}
项目:liferaylms-portlet    文件:CourseLocalServiceImpl.java   
private void importLayouts(long userId,Group grupo,LayoutSetPrototype lsProto) throws PortalException, SystemException
{
        LayoutSet ls = lsProto.getLayoutSet();  

        Map<String, String[]> parameterMap =getLayoutSetPrototypeParameters();


    File fileIni= layoutLocalService.exportLayoutsAsFile(ls.getGroupId(), true,
            null,parameterMap, null, null);

    try
    {
    layoutLocalService.importLayouts(userId, grupo.getPublicLayoutSet().getGroupId(), 
        grupo.getPublicLayoutSet().isPrivateLayout(),
        parameterMap, fileIni);
    }
    catch(Exception e)
    {
    }
    FileUtil.delete(fileIni);

}
项目:liferaylms-portlet    文件:CourseAdmin.java   
public void deleteExportedCourse(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long groupId  = ParamUtil.getLong(actionRequest, "groupId", 0);
    String fileName = ParamUtil.getString(actionRequest, "fileName", StringPool.BLANK);
    String redirect = ParamUtil.getString(actionRequest, "redirect", StringPool.BLANK);
    File f = new File(PropsUtil.get("liferay.home")+"/data/lms_exports/courses/"+themeDisplay.getCompanyId()+"/"+groupId+"/"+fileName);
    if (themeDisplay.getPermissionChecker().hasPermission(groupId, Course.class.getName(), groupId, ActionKeys.DELETE) && f != null && f.isFile()) {
        FileUtil.delete(f);
        SessionMessages.add(actionRequest, "courseadmin.delete.exported.confirmation.success");
    } else {
        SessionMessages.add(actionRequest, "courseadmin.delete.exported.confirmation.error");
    }
    if (Validator.isNotNull(redirect)) {
        actionResponse.sendRedirect(redirect);
    }
}
项目:edemocracia    文件:UpgradeImageGallery.java   
protected void migrateFile(
        long repositoryId, long companyId, String name, Image image)
    throws Exception {

    InputStream is = _sourceHook.getImageAsStream(image);

    byte[] bytes = FileUtil.getBytes(is);

    if (name == null) {
        name = image.getImageId() + StringPool.PERIOD + image.getType();
    }

    if (DLStoreUtil.hasFile(companyId, repositoryId, name)) {
        DLStoreUtil.deleteFile(companyId, repositoryId, name);
    }

    DLStoreUtil.addFile(companyId, repositoryId, name, false, bytes);
}
项目:edemocracia    文件:BaseDB.java   
public void buildSQLFile(String sqlDir, String fileName)
    throws IOException {

    String template = buildTemplate(sqlDir, fileName);

    if (Validator.isNull(template)) {
        return;
    }

    template = buildSQL(template);

    FileUtil.write(
        sqlDir + "/" + fileName + "/" + fileName + "-" + getServerName() +
            ".sql",
        template);
}
项目:liferay-evernote    文件:ResourceImporter.java   
protected void addDDMStructures(
        String parentStructureId, String structuresDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(structuresDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMStructures(
            parentStructureId, name, urlConnection.getInputStream());
    }
}
项目:liferay-evernote    文件:ResourceImporter.java   
protected void addDDMTemplates(
        String ddmStructureKey, String templatesDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(templatesDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMTemplates(
            ddmStructureKey, name, urlConnection.getInputStream());
    }
}
项目:liferay-evernote    文件:ResourceImporter.java   
protected void addDLFileEntry(String resourcePath) throws Exception {
    Long parentFolderId = _folderIds.get(
        FileUtil.getPath(resourcePath) + StringPool.SLASH);

    if (parentFolderId == null) {
        parentFolderId = 0L;
    }

    URL url = servletContext.getResource(resourcePath);

    URLConnection urlConnection = url.openConnection();

    addDLFileEntry(
        parentFolderId, FileUtil.getShortFileName(resourcePath),
        urlConnection.getInputStream(), urlConnection.getContentLength());
}
项目:liferay-elasticsearch-integration    文件:ResourceImporter.java   
protected void addDDMStructures(
        String parentStructureId, String structuresDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(structuresDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMStructures(
            parentStructureId, name, urlConnection.getInputStream());
    }
}
项目:liferay-elasticsearch-integration    文件:ResourceImporter.java   
protected void addDDMTemplates(
        String ddmStructureKey, String templatesDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(templatesDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMTemplates(
            ddmStructureKey, name, urlConnection.getInputStream());
    }
}
项目:liferay-elasticsearch-integration    文件:ResourceImporter.java   
protected void addDLFileEntry(String resourcePath) throws Exception {
    Long parentFolderId = _folderIds.get(
        FileUtil.getPath(resourcePath) + StringPool.SLASH);

    if (parentFolderId == null) {
        parentFolderId = 0L;
    }

    URL url = servletContext.getResource(resourcePath);

    URLConnection urlConnection = url.openConnection();

    addDLFileEntry(
        parentFolderId, FileUtil.getShortFileName(resourcePath),
        urlConnection.getInputStream(), urlConnection.getContentLength());
}
项目:liferay-microsite-manager    文件:ResourceImporter.java   
protected void addDDMStructures(
        String parentStructureId, String structuresDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(structuresDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMStructures(
            parentStructureId, name, urlConnection.getInputStream());
    }
}
项目:liferay-microsite-manager    文件:ResourceImporter.java   
protected void addDDMTemplates(
        String ddmStructureKey, String templatesDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(templatesDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMTemplates(
            ddmStructureKey, name, urlConnection.getInputStream());
    }
}
项目:liferay-microsite-manager    文件:ResourceImporter.java   
protected void addDLFileEntry(String resourcePath) throws Exception {
    Long parentFolderId = _folderIds.get(
        FileUtil.getPath(resourcePath) + StringPool.SLASH);

    if (parentFolderId == null) {
        parentFolderId = 0L;
    }

    URL url = servletContext.getResource(resourcePath);

    URLConnection urlConnection = url.openConnection();

    addDLFileEntry(
        parentFolderId, FileUtil.getShortFileName(resourcePath),
        urlConnection.getInputStream(), urlConnection.getContentLength());
}
项目:liferay-document-and-media-treeview    文件:ResourceImporter.java   
protected void addDDMStructures(
        String parentStructureId, String structuresDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(structuresDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMStructures(
            parentStructureId, name, urlConnection.getInputStream());
    }
}
项目:liferay-document-and-media-treeview    文件:ResourceImporter.java   
protected void addDDMTemplates(
        String ddmStructureKey, String templatesDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(templatesDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMTemplates(
            ddmStructureKey, name, urlConnection.getInputStream());
    }
}
项目:liferay-document-and-media-treeview    文件:ResourceImporter.java   
protected void addDLFileEntry(String resourcePath) throws Exception {
    Long parentFolderId = _folderIds.get(
        FileUtil.getPath(resourcePath) + StringPool.SLASH);

    if (parentFolderId == null) {
        parentFolderId = 0L;
    }

    URL url = servletContext.getResource(resourcePath);

    URLConnection urlConnection = url.openConnection();

    addDLFileEntry(
        parentFolderId, FileUtil.getShortFileName(resourcePath),
        urlConnection.getInputStream(), urlConnection.getContentLength());
}
项目:hr-portal    文件:ResourceImporter.java   
protected void addDDMStructures(
        String parentStructureId, String structuresDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(structuresDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMStructures(
            parentStructureId, name, urlConnection.getInputStream());
    }
}
项目:hr-portal    文件:ResourceImporter.java   
protected void addDDMTemplates(
        String ddmStructureKey, String templatesDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(templatesDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMTemplates(
            ddmStructureKey, name, urlConnection.getInputStream());
    }
}
项目:hr-portal    文件:ResourceImporter.java   
protected void addDLFileEntry(String resourcePath) throws Exception {
    Long parentFolderId = _folderIds.get(
        FileUtil.getPath(resourcePath) + StringPool.SLASH);

    if (parentFolderId == null) {
        parentFolderId = 0L;
    }

    URL url = servletContext.getResource(resourcePath);

    URLConnection urlConnection = url.openConnection();

    addDLFileEntry(
        parentFolderId, FileUtil.getShortFileName(resourcePath),
        urlConnection.getInputStream(), urlConnection.getContentLength());
}
项目:liferay-voice-command    文件:ResourceImporter.java   
protected void addDDLStructures(String dirName) throws Exception {
    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(dirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        File file = new File(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMStructures(
            FileUtil.stripExtension(file.getName()),
            urlConnection.getInputStream());
    }
}
项目:liferay-voice-command    文件:ResourceImporter.java   
protected void addDDMStructures(String parentStructureId, String dirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(dirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMStructures(
            parentStructureId, name, urlConnection.getInputStream());
    }
}
项目:liferay-voice-command    文件:ResourceImporter.java   
protected void addDDMTemplates(String ddmStructureKey, String dirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(dirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMTemplates(
            ddmStructureKey, name, urlConnection.getInputStream());
    }
}
项目:liferay-voice-command    文件:ResourceImporter.java   
protected void addDLFileEntry(String resourcePath) throws Exception {
    Long parentFolderId = _folderIds.get(
        FileUtil.getPath(resourcePath) + StringPool.SLASH);

    if (parentFolderId == null) {
        parentFolderId = 0L;
    }

    URL url = servletContext.getResource(resourcePath);

    URLConnection urlConnection = url.openConnection();

    addDLFileEntry(
        parentFolderId, FileUtil.getShortFileName(resourcePath),
        urlConnection.getInputStream(), urlConnection.getContentLength());
}
项目:liferay-voice-command    文件:ResourceImporter.java   
protected void addLayoutTemplate(String dirName) throws Exception {
    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(dirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        String extension = FileUtil.getExtension(resourcePath);

        if (!extension.equals("json")) {
            return;
        }

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addLayoutTemplate(urlConnection.getInputStream());
    }
}
项目:jukebox    文件:ResourceImporter.java   
protected void addDDMStructures(
        String parentStructureId, String structuresDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(structuresDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMStructures(
            parentStructureId, name, urlConnection.getInputStream());
    }
}
项目:jukebox    文件:ResourceImporter.java   
protected void addDDMTemplates(
        String ddmStructureKey, String templatesDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(templatesDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMTemplates(
            ddmStructureKey, name, urlConnection.getInputStream());
    }
}
项目:jukebox    文件:ResourceImporter.java   
protected void addDLFileEntry(String resourcePath) throws Exception {
    Long parentFolderId = _folderIds.get(
        FileUtil.getPath(resourcePath) + StringPool.SLASH);

    if (parentFolderId == null) {
        parentFolderId = 0L;
    }

    URL url = servletContext.getResource(resourcePath);

    URLConnection urlConnection = url.openConnection();

    addDLFileEntry(
        parentFolderId, FileUtil.getShortFileName(resourcePath),
        urlConnection.getInputStream(), urlConnection.getContentLength());
}
项目:hr-portal    文件:ResourceImporter.java   
protected void addDDMStructures(
        String parentStructureId, String structuresDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(structuresDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMStructures(
            parentStructureId, name, urlConnection.getInputStream());
    }
}
项目:hr-portal    文件:ResourceImporter.java   
protected void addDDMTemplates(
        String ddmStructureKey, String templatesDirName)
    throws Exception {

    Set<String> resourcePaths = servletContext.getResourcePaths(
        resourcesDir.concat(templatesDirName));

    if (resourcePaths == null) {
        return;
    }

    for (String resourcePath : resourcePaths) {
        if (resourcePath.endsWith(StringPool.SLASH)) {
            continue;
        }

        String name = FileUtil.getShortFileName(resourcePath);

        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        addDDMTemplates(
            ddmStructureKey, name, urlConnection.getInputStream());
    }
}
项目:hr-portal    文件:ResourceImporter.java   
protected void addDLFileEntry(String resourcePath) throws Exception {
    Long parentFolderId = _folderIds.get(
        FileUtil.getPath(resourcePath) + StringPool.SLASH);

    if (parentFolderId == null) {
        parentFolderId = 0L;
    }

    URL url = servletContext.getResource(resourcePath);

    URLConnection urlConnection = url.openConnection();

    addDLFileEntry(
        parentFolderId, FileUtil.getShortFileName(resourcePath),
        urlConnection.getInputStream(), urlConnection.getContentLength());
}
项目:ch-inofix-timetracker    文件:TaskRecordImportBackgroundTaskExecutor.java   
@Override
public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws Exception {

    ExportImportConfiguration exportImportConfiguration = getExportImportConfiguration(backgroundTask);

    List<FileEntry> attachmentsFileEntries = backgroundTask.getAttachmentsFileEntries();

    File file = null;

    for (FileEntry attachmentsFileEntry : attachmentsFileEntries) {
        try {
            file = FileUtil.createTempFile("lar");

            FileUtil.write(file, attachmentsFileEntry.getContentStream());

            _log.info(file.getAbsoluteFile());

            TransactionInvokerUtil.invoke(transactionConfig,
                    new TaskRecordImportCallable(exportImportConfiguration, file));

        } catch (Throwable t) {
            if (_log.isDebugEnabled()) {
                _log.debug(t, t);
            } else if (_log.isWarnEnabled()) {
                _log.warn("Unable to import taskRecords: " + t.getMessage());
            }

            throw new SystemException(t);
        } finally {
            FileUtil.delete(file);
        }
    }

    return BackgroundTaskResult.SUCCESS;
}
项目:ch-inofix-contact-manager    文件:ContactImportBackgroundTaskExecutor.java   
@Override
public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws Exception {

    ExportImportConfiguration exportImportConfiguration = getExportImportConfiguration(backgroundTask);

    List<FileEntry> attachmentsFileEntries = backgroundTask.getAttachmentsFileEntries();

    File file = null;

    for (FileEntry attachmentsFileEntry : attachmentsFileEntries) {
        try {
            file = FileUtil.createTempFile("lar");

            FileUtil.write(file, attachmentsFileEntry.getContentStream());

            _log.info(file.getAbsoluteFile());

            TransactionInvokerUtil.invoke(transactionConfig,
                    new ContactImportCallable(exportImportConfiguration, file));

        } catch (Throwable t) {
            if (_log.isDebugEnabled()) {
                _log.debug(t, t);
            } else if (_log.isWarnEnabled()) {
                _log.warn("Unable to import contacts: " + t.getMessage());
            }

            throw new SystemException(t);
        } finally {
            FileUtil.delete(file);
        }
    }

    return BackgroundTaskResult.SUCCESS;
}