- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
有什么方法可以查看 http 调用的响应 header 吗?我会更具体。我需要查看资源(由 Web 上的 URL 指向)何时被修改。知道最后修改的日期我决定是否下载它。我认为这样做的一种方法是观察 http 调用的 header 。有什么建议 ?
最佳答案
这将很容易使用用户定义的 Java 类完成。这是一个 Class 示例,期望来自上一步的名为 picture(图片的 url)的输入行。现在使用此代码添加您的用户定义的 java 类:
import java.util.*;
import java.lang.System.*;
import java.net.*;
import java.io.*;
import java.text.*;
import java.util.Date;
import java.util.Calendar;
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException, Exception
{
//First, get a row from the default input hop
Object[] r = getRow();
//If the row object is null, we are done processing.
if (r == null) {
setOutputDone();
return false;
}
String filesSavePath = getParameter("filesSavePath")+"/tmp/pictures";
//remove "file://" from filesSavePath, otherwise gives a file io exception, file not found
filesSavePath = filesSavePath.replace("file://","");
String picture = get(Fields.In, "picture").getString(r);
//get the last chunk of picture as filename to save in disk
String filePictureName = picture.substring(picture.lastIndexOf('/') + 1);
String fileFullPath = filesSavePath+ "/"+ filePictureName;
//lets get the headers from picture
try {
boolean fileExists = new File(fileFullPath).isFile();
//if picture do not exists save it
if(fileExists != true){
saveImage(picture, fileFullPath);
System.out.println("new picture saved = " + filePictureName);
System.out.println("*******************************");
}
//if file exists compare date last modified file from header, younger than yesterday.
//if true save it.
else{
//get the last-modified header
URL url = new URL(picture);
URLConnection conn = url.openConnection();
long lastModified = conn.getLastModified();
//get last-modified date
Date lastModifiedDate = new Date(lastModified);
//get yesterday date
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
Date yesterdayDate = cal.getTime();
//today just for testing
//Date today = new Date();
//boolean dateCompare = today.after(yesterdayDate);
boolean dateCompare = lastModifiedDate.after(yesterdayDate);
//if true save it!
if(dateCompare == true){
saveImage(picture, fileFullPath);
System.out.println("new picture saved(last modified after yesterday) = " + filePictureName);
}
System.out.println("picture = " + picture);
System.out.println("last modified after yesterday = " + dateCompare);
System.out.println("last modified = " + lastModifiedDate);
//System.out.println("today = " + today);
System.out.println("yesterday date = " + yesterdayDate);
System.out.println("*******************************");
}
}
catch (Exception e) {
System.out.println("error: " + e);
String fullStackTrace = org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e);
System.out.println("fullStackTrace: " + fullStackTrace);
}
return true;
}
private static void saveImage(String imageUrl, String destinationFile) throws IOException {
URL url = new URL(imageUrl);
InputStream is = url.openStream();
OutputStream os = new FileOutputStream(destinationFile);
byte[] b = new byte[2048];
int length;
while ((length = is.read(b)) != -1) {
os.write(b, 0, length);
}
is.close();
os.close();
}
关于http - 如何使用 pentaho kettle 查看 http header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18186649/
我想将浏览文件页面设置为 Pentaho BI 服务器的主页。默认情况下,我们需要单击浏览文件按钮才能查看我们的文件。我想在我的主页上看到我的文件 有人可以帮帮我吗? 最佳答案 1.) 在文本编辑器中
我是 Pentaho 数据集成的新手;我需要将一个数据库作为 ETL 作业集成到另一个位置。我想计算 ETL 作业期间插入/更新的次数,并将该计数插入到另一个表中。谁能帮我解决这个问题吗? 最佳答案
我正在以非常基本的方式使用水壶。我想要做的是从 csv 文件中读取,在用户定义的 Java 类步骤中进行某种转换并将输出写入文本文件。 a picture http://imageshack.com/
我有一个案例,我将 X 行数据库名称作为我需要连接的参数。我已经成功地完成了工作和转换,为作为参数给出的每个数据库名称重复表输入步骤。因此,当这些 dbnames 恰好有效时,这一切都很好地工作。但是
这可能是一个基本问题,但我想知道 Pentaho 数据集成中保存的转换在哪里。目前,我正在连接到一个存储库,我的所有工作和转换都保存在那里。我希望能够通过电子邮件将特定转换发送给另一个人。我在服务器上
当我们通过 shell 脚本直接调用 .ktr 文件来运行 Pentaho 转换(.ktr 文件)时,有没有办法指定日志记录级别(基本/最小)等?默认值是多少? 最佳答案 来自 Pan 文档: "设置
我想使用 Pentaho 报表设计器使用 命令行 自动化整个报表生成过程。有没有可能在Pentaho中实现? 输入 = 存储在数据库中的结果数据Output = 使用 Report designer
需要将多个事实表关联到一个蒙德里安立方体。模式工作台不允许这样做。我们怎样才能做到这一点? 最佳答案 您不能在多维数据集中添加多个事实表。 Schema Workbench 希望您有一个星型模式,其中
pentaho 文档 ( http://wiki.pentaho.com/display/EAI/Job+checkpoints+and+restartability ) 指定,从版本 5.0 开始,
我正在尝试在 pentaho cde 中制作数据表。在pentaho中组件的名称是Table Component。 问题是我尝试执行没有特定列数的动态查询,并出现以下错误: DataTables wa
任何人都可以提供在pentaho数据集成中获取变量和从结果步骤获取行的示例吗? 我的工作需要进行两次转变。 第一个转换采用样本输入并生成样本输出,最后我将行复制到结果步骤。 我的第二个转换从结果步骤中
我正在研究 PDI 水壶。我们可以定义一个变量并在数据库连接名称中使用它吗?因此,如果将来我需要更改多个转换中的连接,我会只更改 kettle 属性文件中的变量值吗? 最佳答案 只需在数据库连接中使用
我正在使用水壶勺进行改造。 如何从“获取系统信息”给出固定输入日期?我看到选择昨天、一个月前等选项。但我想手动选择固定日期,例如:'2012-12-14' 我从转换中得到了一个 csv,“文本文件输出
我需要参数化我的水壶作业和转换中的所有变量(作业将在 AWS 中运行,所有参数都作为环境变量传入)。 我在作业中的连接、路径和各种其他参数及其伴随的转换使用 ${SOURCE_DB_PASSWORD}
我知道我可以通过在vi模式下打开spoon.sh来检查Pentaho版本,但是安装在生产环境中的Pentaho没有该信息。可能在我之前的某个员工已经编辑过它。那么有没有其他方法可以让我知道服务器上正在
我是 Pentaho 新手,需要将表格从行转置为列,但第一列不包含标题。 它看起来像这样: Jan/15 Feb/15 Mar/15 Apr/15 1.1 3.4 1.7
我必须处理一个包含多个聚合级别的电子表格。大多数情况下,这很好,但在一种情况下,我需要将最高聚合级别的信息与下一个聚合级别的信息结合使用。这是一个例子: Title, Platform
我在这个报告中创建了一个 CDE 参数报告我想通过 url 传递参数我的 CDE 报告链接如下 http://localhost:8080/pentaho/content/pentaho-cdf-dd
我昨天在 Redhat 机器上运行 Pentaho 5.3 Biserver 出现电源故障,当电源恢复时我试图启动它提供的 biserver HTTP Status 404 - type Status
我正在通过模式工作台或 Ivy 模式编辑器创建多维数据集(xml 模式)。 当我发布它时,我想知道模式(mondrian.xml 文件)实际保存在哪里,这些文件的位置是什么? 谢谢, 最佳答案 您使用
我是一名优秀的程序员,十分优秀!