Java 类org.apache.commons.httpclient.util.DateUtil 实例源码

项目:Equella    文件:StagingApiTest.java   
@Test
public void restrictions() throws IOException, DateParseException
{
    String stagingUrl = staging.create();

    // put a file to the folder1 content url
    final File file = new File(getPathFromUrl(Attachments.get("avatar.png")));

    Response response = staging.putFile(stagingUrl, AVATAR_PATH, file);
    assertEquals(response.getHeader("ETag"), AVATAR_PNG_ETAG);

    RequestSpecification notModified = staging.notModified();
    notModified.header("If-None-Match", AVATAR_PNG_ETAG);
    staging.get(notModified, stagingUrl, AVATAR_PATH);
    response = staging.head(stagingUrl, AVATAR_PATH);
    Date date = DateUtil.parseDate(response.header("Last-Modified"));

    notModified = staging.notModified();
    notModified.header("If-Modified-Since", DateUtil.formatDate(date));
    staging.get(notModified, stagingUrl, AVATAR_PATH);
}
项目:linkbinder    文件:ProjectLogoManagerTest.java   
/**
 * projectId:存在するプロジェクト、ifModifiedSince:ロゴと同じ
 */
@Test
public void testIsModified6(){
    String projectId = "test-project";

    String testFile = MockSystemConfig.CONFIG_PROJECT_LOGO_DIR + "/" + projectId + ".png";
    File f = new File(testFile);
    if (!f.exists()) {
        fail("テスト用のファイル[" + testFile + "] を用意してください");
        return;
    }

    MockSystemConfig.CONFIG_PROJECT_LOGO_DEFAULT = "test-default.png";
    String testFile2 = MockSystemConfig.CONFIG_PROJECT_LOGO_DIR + "/" + MockSystemConfig.CONFIG_PROJECT_LOGO_DEFAULT;
    File f2 = new File(testFile2);
    if (!f2.exists()) {
        fail("テスト用のファイル[" + testFile2 + "] を用意してください");
        return;
    }

    String ifModifiedSince = DateUtil.formatDate(new Date(f.lastModified()));
    assertFalse(projectLogoManager.isModified(projectId, ifModifiedSince));
}
项目:linkbinder    文件:ProjectLogoManagerTest.java   
/**
 * projectId:存在するプロジェクト、ifModifiedSince:ロゴ + 1秒
 */
@Test
public void testIsModified7(){
    String projectId = "test-project";

    String testFile = MockSystemConfig.CONFIG_PROJECT_LOGO_DIR + "/" + projectId + ".png";
    File f = new File(testFile);
    if (!f.exists()) {
        fail("テスト用のファイル[" + testFile + "] を用意してください");
        return;
    }

    MockSystemConfig.CONFIG_PROJECT_LOGO_DEFAULT = "test-default.png";
    String testFile2 = MockSystemConfig.CONFIG_PROJECT_LOGO_DIR + "/" + MockSystemConfig.CONFIG_PROJECT_LOGO_DEFAULT;
    File f2 = new File(testFile2);
    if (!f2.exists()) {
        fail("テスト用のファイル[" + testFile2 + "] を用意してください");
        return;
    }

    String ifModifiedSince = DateUtil.formatDate(new Date(f.lastModified() + 1000));
    assertTrue(projectLogoManager.isModified(projectId, ifModifiedSince));
}
项目:linkbinder    文件:ProjectLogoManagerTest.java   
/**
 * projectId:存在するプロジェクト、ifModifiedSince:ロゴ - 1秒
 */
@Test
public void testIsModified8(){
    String projectId = "test-project";

    String testFile = MockSystemConfig.CONFIG_PROJECT_LOGO_DIR + "/" + projectId + ".png";
    File f = new File(testFile);
    if (!f.exists()) {
        fail("テスト用のファイル[" + testFile + "] を用意してください");
        return;
    }

    MockSystemConfig.CONFIG_PROJECT_LOGO_DEFAULT = "test-default.png";
    String testFile2 = MockSystemConfig.CONFIG_PROJECT_LOGO_DIR + "/" + MockSystemConfig.CONFIG_PROJECT_LOGO_DEFAULT;
    File f2 = new File(testFile2);
    if (!f2.exists()) {
        fail("テスト用のファイル[" + testFile2 + "] を用意してください");
        return;
    }

    String ifModifiedSince = DateUtil.formatDate(new Date(f.lastModified() - 1000));
    assertTrue(projectLogoManager.isModified(projectId, ifModifiedSince));
}
项目:webarchive-commons    文件:ARC2WCDX.java   
protected static void appendTimeField(StringBuilder builder, Object obj) {
    if(builder.length()>0) {
        // prepend with delimiter
        builder.append(' ');
    }
    if(obj==null) {
        builder.append("-");
        return;
    }
    if(obj instanceof Header) {
        String s = ((Header)obj).getValue().trim();
        try {
            Date date = DateUtil.parseDate(s);
            String d = ArchiveUtils.get14DigitDate(date);
            if(d.startsWith("209")) {
                d = "199"+d.substring(3);
            }
            obj = d;
        } catch (DateParseException e) {
            builder.append('e');
            return;
        }

    }
    builder.append(obj);
}
项目:rainbow    文件:TestAPC.java   
@Test
public void test () throws IOException, InterruptedException
{
    BufferedReader reader = new BufferedReader(new FileReader(
            "H:\\SelfLearning\\SAI\\DBIIR\\rainbows\\workload.txt"));
    String line = null;
    int i = 0, j = 0;
    Random random = new Random(System.currentTimeMillis());
    AccessPatternCache APC = new AccessPatternCache(100000, 0.1);
    System.out.println(DateUtil.formatDate(new Date()));
    while ((line = reader.readLine()) != null)
    {
        i++;
        String[] tokens = line.split("\t");
        double weight = Double.parseDouble(tokens[1]);
        AccessPattern pattern = new AccessPattern(tokens[0], weight);
        for (String column : tokens[2].split(","))
        {
            pattern.addColumn(column);
        }

        if (APC.cache(pattern))
        {
            System.out.println(DateUtil.formatDate(new Date()));
            System.out.println(i + ", trigger layout optimization.");
            j++;
            APC.saveAsWorkloadFile("H:\\SelfLearning\\SAI\\DBIIR\\rainbows\\workload_"+j+".txt");
            System.out.println(DateUtil.formatDate(new Date()));
        }
        Thread.sleep(random.nextInt(500));
    }
}
项目:Equella    文件:ItemDownloadTest.java   
@Test
public void restrictions() throws DateParseException
{
    RequestSpecification notModified = staging.notModified();
    notModified.header("If-None-Match", AVATAR_PNG_ETAG);
    staging.file(notModified, ITEM_ID, AVATAR_PATH);

    Response response = staging.headFile(ITEM_ID, AVATAR_PATH);
    Date date = DateUtil.parseDate(response.header("Last-Modified"));

    notModified = staging.notModified();
    notModified.header("If-Modified-Since", DateUtil.formatDate(date));
    staging.file(notModified, ITEM_ID, AVATAR_PATH);
}
项目:lib-commons-httpclient    文件:TestDateParser.java   
public void testTwoDigitYear() throws Exception {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(DateUtil.parseDate("Thu, 23-Dec-04 24:00:00 CET", PATTERNS));
    assertEquals(2004, calendar.get(Calendar.YEAR));

    calendar.setTime(DateUtil.parseDate("Thu, 23-Dec-94 24:00:00 CET", PATTERNS));
    assertEquals(2094, calendar.get(Calendar.YEAR));
}
项目:Spring-Boot-Server    文件:AppPayComponent.java   
public void saveKeyNode(String orderId){
    PageData pd = new PageData();
    pd.put("O_ID", orderId);
    pd.put("NM_ID", "");
    pd.put("NM_NAME", "已付款");
    pd.put("KN_TIME", DateUtil.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
    pd.put("KN_DAY", 0);
    pd.put("KN_CONTENT", "请等待服务人员联系");
    pd.put("IS_SCHEDULE", "0");
    pd.put("EDIT_STATE", "1");
    appPayMapper.insertNode(pd);
}
项目:linkbinder    文件:ProjectLogoManagerTest.java   
/**
 * projectId:存在しないプロジェクト、ifModifiedSince:ロゴと同じ
 */
@Test
public void testIsModified3(){
    String projectId = "not_exist_project";

    MockSystemConfig.CONFIG_PROJECT_LOGO_DEFAULT = "test-default.png";
    String testFile = MockSystemConfig.CONFIG_PROJECT_LOGO_DIR + "/" + MockSystemConfig.CONFIG_PROJECT_LOGO_DEFAULT;
    File f = new File(testFile);
    if (!f.exists()) {
        fail("テスト用のファイル[" + testFile + "] を用意してください");
        return;
    }
    String ifModifiedSince = DateUtil.formatDate(new Date(f.lastModified()));
    assertFalse(projectLogoManager.isModified(projectId, ifModifiedSince));
}
项目:linkbinder    文件:ProjectLogoManagerTest.java   
/**
 * projectId:存在しないプロジェクト、ifModifiedSince:ロゴ + 1秒
 */
@Test
public void testIsModified4(){
    String projectId = "not_exist_project";

    MockSystemConfig.CONFIG_PROJECT_LOGO_DEFAULT = "test-default.png";
    String testFile = MockSystemConfig.CONFIG_PROJECT_LOGO_DIR + "/" + MockSystemConfig.CONFIG_PROJECT_LOGO_DEFAULT;
    File f = new File(testFile);
    if (!f.exists()) {
        fail("テスト用のファイル[" + testFile + "] を用意してください");
        return;
    }
    String ifModifiedSince = DateUtil.formatDate(new Date(f.lastModified() + 1000));
    assertTrue(projectLogoManager.isModified(projectId, ifModifiedSince));
}
项目:linkbinder    文件:ProjectLogoManagerTest.java   
/**
 * projectId:存在しないプロジェクト、ifModifiedSince:ロゴ - 1秒
 */
@Test
public void testIsModified5(){
    String projectId = "not_exist_project";

    MockSystemConfig.CONFIG_PROJECT_LOGO_DEFAULT = "test-default.png";
    String testFile = MockSystemConfig.CONFIG_PROJECT_LOGO_DIR + "/" + MockSystemConfig.CONFIG_PROJECT_LOGO_DEFAULT;
    File f = new File(testFile);
    if (!f.exists()) {
        fail("テスト用のファイル[" + testFile + "] を用意してください");
        return;
    }
    String ifModifiedSince = DateUtil.formatDate(new Date(f.lastModified() - 1000));
    assertTrue(projectLogoManager.isModified(projectId, ifModifiedSince));
}
项目:linkbinder    文件:ProjectLogoManagerTest.java   
/**
 * デフォルトロゴが存在しない、ifModifiedSince:現在日時
 */
@Test
public void testIsModified11(){
    String projectId = "not_exist_project";
    String ifModifiedSince = DateUtil.formatDate(new Date(System.currentTimeMillis()));
    assertTrue(projectLogoManager.isModified(projectId, ifModifiedSince));
}
项目:sonar-gerrit-plugin    文件:DateTypeConverter.java   
public Date deserialize(JsonElement json, Type type, JsonDeserializationContext context) {
    String str = json.getAsString();
    try {
        return DateUtil.parseDate(str);
    } catch (DateParseException e) {
        try {
            DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssz");
            return df.parse(str);
        } catch (ParseException e1) {
            LOGGER.log(Level.WARNING, "An exception occurred on DateTypeConverter: {0}", e.getStackTrace());
            throw new JsonParseException(e);
        }
    }
}
项目:persistenturls    文件:RemoteGraphSupport.java   
@Override
public boolean reload(String origin) throws Exception {
    String url = getResource().stringValue();
    BasicHttpRequest req = new BasicHttpRequest("GET", url);
    String type = getPurlContentType();
    if (type == null) {
        req.setHeader("Accept", "application/rdf+xml");
    } else {
        req.setHeader("Accept", type);
    }
    String etag = getPurlEtag();
    if (etag != null) {
        req.setHeader("If-None-Match", etag);
    }
    XMLGregorianCalendar modified = getPurlLastModified();
    if (modified != null) {
        Date date = modified.toGregorianCalendar().getTime();
        req.setHeader("If-Modified-Since", DateUtil.formatDate(date));
    }
    HttpResponse resp = requestRDF(req, 20);
    int code = resp.getStatusLine().getStatusCode();
    if (code == 304) {
        DatatypeFactory df = DatatypeFactory.newInstance();
        GregorianCalendar gc = new GregorianCalendar();
        setPurlLastValidated(df.newXMLGregorianCalendar(gc));
        setPurlCacheControl(getHeader(resp, "Cache-Control"));
    }
    if (code == 304 || code == 404) {
        HttpEntity entity = resp.getEntity();
        if (entity != null) {
            entity.consumeContent();
        }
        return true;
    }
    return importResponse(resp, origin);
}
项目:persistenturls    文件:RemoteGraphSupport.java   
private Date getDateHeader(HttpResponse resp, String name)
        throws DateParseException {
    Header hd = resp.getFirstHeader(name);
    if (hd == null)
        return new Date();
    return DateUtil.parseDate(hd.getValue());
}
项目:Plugins    文件:HttpFileObject.java   
/**
 * Returns the last modified time of this file.
 * <p/>
 * This implementation throws an exception.
 */
@Override
protected long doGetLastModifiedTime() throws Exception
{
    final Header header = method.getResponseHeader("last-modified");
    if (header == null)
    {
        throw new FileSystemException("vfs.provider.http/last-modified.error", getName());
    }
    return DateUtil.parseDate(header.getValue()).getTime();
}
项目:wso2-commons-vfs    文件:HttpFileObject.java   
/**
 * Returns the last modified time of this file.
 * <p/>
 * This implementation throws an exception.
 */
@Override
protected long doGetLastModifiedTime() throws Exception
{
    final Header header = method.getResponseHeader("last-modified");
    if (header == null)
    {
        throw new FileSystemException("vfs.provider.http/last-modified.error", getName());
    }
    return DateUtil.parseDate(header.getValue()).getTime();
}
项目:wso2-commons-vfs    文件:WebdavFileObject.java   
/**
 * Returns the last modified time of this file.  Is only called if
 * {@link #doGetType} does not return {@link FileType#IMAGINARY}.
 */
@Override
protected long doGetLastModifiedTime() throws Exception
{
    DavProperty property = getProperty((URLFileName) getName(),
            DavConstants.PROPERTY_GETLASTMODIFIED);
    if (property != null)
    {
        String value = (String) property.getValue();
        return DateUtil.parseDate(value).getTime();
    }
    return 0;
}
项目:GeoprocessingAppstore    文件:TProxy.java   
/**
 * Finds last modified date.
 * @param headers array of headers
 * @return last modified date or <code>null</code> if date not found
 */
private static Date findLastModifiedDate(ResponseInfo responseInfo) {
  Header lastModfiedHeader = responseInfo.getResponseHeader("Last-Modified");
  if (lastModfiedHeader != null) {
    try {
      return DateUtil.parseDate(lastModfiedHeader.getValue());
    } catch (DateParseException ex) {
      return null;
    }
  }
  return null;
}
项目:GeoprocessingAppstore    文件:WafProxy.java   
/**
 * Finds last modified date.
 * @param headers array of headers
 * @return last modified date or <code>null</code> if date not found
 */
private static Date findLastModifiedDate(ResponseInfo responseInfo) {
  Header lastModfiedHeader = responseInfo.getResponseHeader("Last-Modified");
  if (lastModfiedHeader!=null) {
    try {
      return DateUtil.parseDate(lastModfiedHeader.getValue());
    } catch (DateParseException ex) {
      return null;
    }
  }
  return null;
}
项目:httpstreams    文件:HttpHeaders.java   
public Date getDate(String name) {
    String v = get(name);

    try {
        return DateUtil.parseDate(v);
    } catch (Exception e) {
        return null;
    }
}
项目:httpclient3-ntml    文件:TestDateParser.java   
public void testTwoDigitYear() throws Exception {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(DateUtil.parseDate("Thu, 23-Dec-04 24:00:00 CET", PATTERNS));
    assertEquals(2004, calendar.get(Calendar.YEAR));

    calendar.setTime(DateUtil.parseDate("Thu, 23-Dec-94 24:00:00 CET", PATTERNS));
    assertEquals(2094, calendar.get(Calendar.YEAR));
}
项目:pdi-vfs    文件:WebdavFileObject.java   
/**
 * Returns the last modified time of this file.  Is only called if
 * {@link #doGetType} does not return {@link FileType#IMAGINARY}.
 */
protected long doGetLastModifiedTime() throws Exception
{
    DavProperty property = getProperty((URLFileName) getName(),
            DavConstants.PROPERTY_GETLASTMODIFIED);
    if (property != null)
    {
        String value = (String) property.getValue();
        return DateUtil.parseDate(value).getTime();
    }
    return 0;
}
项目:bandwidth-on-demand    文件:NsiInfraDocumentsController.java   
private String handleRequest(final String document, final Date version, final HttpServletRequest request, final HttpServletResponse response) throws DateParseException {
  response.addHeader(HttpHeaders.LAST_MODIFIED, DateUtil.formatDate(version));
  if (!isModifiedSince(request.getHeaders(HttpHeaders.IF_MODIFIED_SINCE), version)) {
    response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
    return null;
  }
  return document;
}
项目:bandwidth-on-demand    文件:NsiInfraDocumentsController.java   
private boolean isModifiedSince(final Enumeration<String> ifModifiedSinceValues, final Date lastModified) throws DateParseException {
  DateTime lastModifiedDateTime = new DateTime(lastModified);
  if (ifModifiedSinceValues.hasMoreElements()) {
    DateTime ifModifiedSince = new DateTime(DateUtil.parseDate(ifModifiedSinceValues.nextElement()));
    return ifModifiedSince.isBefore(lastModifiedDateTime);
  }
  return true;
}
项目:bandwidth-on-demand    文件:OfflineNsaController.java   
private String handleRequest(final String document, final Date version, final HttpServletRequest request, final HttpServletResponse response) throws DateParseException {
  response.addHeader(HttpHeaders.LAST_MODIFIED, DateUtil.formatDate(version));
  if (!isModifiedSince(request.getHeaders(HttpHeaders.IF_MODIFIED_SINCE), version)) {
    response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
    return null;
  }
  return document;
}
项目:bandwidth-on-demand    文件:OfflineNsaController.java   
private boolean isModifiedSince (final Enumeration<String> ifModifiedSinceValues, final Date lastModified) throws DateParseException {
  DateTime lastModifiedDateTime = new DateTime(lastModified);
  if (ifModifiedSinceValues.hasMoreElements()) {
    DateTime ifModifiedSince = new DateTime(DateUtil.parseDate(ifModifiedSinceValues.nextElement()));
    return ifModifiedSince.isBefore(lastModifiedDateTime);
  }
  return true;
}
项目:caintegrator    文件:AbstractPersistedAnalysisJob.java   
/**
 * Retrieves the header for the toString() of subclasses.
 * @param type of job.
 * @return the header
 */
protected String retrieveHeader(String type) {
    String nl = "\n";
    StringBuffer sb = new StringBuffer();
    sb.append("Job Type: ").append(type).append(nl);
    sb.append("Job ID: ").append(getId()).append(nl);
    sb.append("Date: ").append(DateUtil.formatDate(new Date(), DateUtil.PATTERN_ASCTIME)).append(nl);
    if (getSubscription() != null && getSubscription().getStudy() != null) {
        sb.append("Study Name: ").append(getSubscription().getStudy().getShortTitleText()).append(nl);
    }
    return sb.toString();
}
项目:alfresco-solrclient    文件:SOLRAPIClient.java   
public GetTextContentResponse getTextContent(Long nodeId, QName propertyQName, Long modifiedSince) throws AuthenticationException, IOException
{
    StringBuilder url = new StringBuilder(128);
    url.append(GET_CONTENT);

    StringBuilder args = new StringBuilder(128);
    if(nodeId != null)
    {
        args.append("?");
        args.append("nodeId");
        args.append("=");
        args.append(nodeId);            
    }
    else
    {
        throw new NullPointerException("getTextContent(): nodeId cannot be null.");
    }
    if(propertyQName != null)
    {
        if(args.length() == 0)
        {
            args.append("?");
        }
        else
        {
            args.append("&");
        }
        args.append("propertyQName");
        args.append("=");
        args.append(URLEncoder.encode(propertyQName.toString()));
    }

    url.append(args);

    GetRequest req = new GetRequest(url.toString());

    if(modifiedSince != null)
    {
        Map<String, String> headers = new HashMap<String, String>(1, 1.0f);
        headers.put("If-Modified-Since", String.valueOf(DateUtil.formatDate(new Date(modifiedSince))));
        req.setHeaders(headers);
    }

    Response response = repositoryHttpClient.sendRequest(req);

    if(response.getStatus() != Status.STATUS_NOT_MODIFIED && response.getStatus() != Status.STATUS_NO_CONTENT && response.getStatus() != Status.STATUS_OK)
    {
        throw new AlfrescoRuntimeException("GetTextContentResponse return status is " + response.getStatus());
    }

    return new GetTextContentResponse(response);
}
项目:PackagePlugin    文件:FileUtil.java   
/**
 * 输出excel接口文档
 *
 * @param param         请求参数 如:a=1&b=&c=
 * @param url           接口地址
 * @param interfaceName 接口名称
 * @param result        请求结果
 * @throws Exception
 */
public static void writeExcel(String param, String url, String interfaceName, JsonObject result) throws Exception {
    HSSFWorkbook wb = new HSSFWorkbook();
    STYLE_MAP.clear();
    HSSFSheet sheet = wb.createSheet(interfaceName);
    int rowIndex = 0;

    setRegionBorder(sheet, rowIndex, 0, 9);//这操作会自动创建row
    HSSFRow row = sheet.getRow(rowIndex++);//如果这里再创建row原来合并的单元格式样式将被覆盖
    getCell(row, 0, HSSFColor.DARK_YELLOW.index, "业务描述");
    setRegionBorder(sheet, rowIndex, 0, 9);
    row = sheet.getRow(rowIndex++);
    getCell(row, 0, HSSFColor.LIGHT_YELLOW.index, "");

    setRegionBorder(sheet, rowIndex, 3, 7);
    row = sheet.getRow(rowIndex++);
    getCell(row, 0, -1, "创建者");
    getCell(row, 2, -1, "创建时间");
    getCell(row, 3, -1, DateUtil.formatDate(new Date(), "yyyy-MM-dd"));
    getCell(row, 8, -1, "适用");
    getCell(row, 9, -1, "教师端");

    setRegionBorder(sheet, rowIndex, 1, 7);
    row = sheet.getRow(rowIndex++);
    getCell(row, 0, -1, "接口名称");
    getCell(row, 1, -1, url.substring(url.indexOf("app")));
    getCell(row, 8, -1, "协议");
    getCell(row, 9, -1, "HTTP(POST)");

    setRegionBorder(sheet, rowIndex, 1, 9);
    row = sheet.getRow(rowIndex++);
    getCell(row, 0, -1, "接口描述");

    setRegionBorder(sheet, rowIndex, 2, 7);
    row = sheet.getRow(rowIndex++);
    getCell(row, 0, -1, "变更历史");
    getCell(row, 1, -1, "时间");
    getCell(row, 2, -1, "操作内容");
    getCell(row, 8, -1, "操作人");
    getCell(row, 9, -1, "备注");
    rowIndex = createEmptyRow(sheet, rowIndex);
    rowIndex = createEmptyRow(sheet, rowIndex);
    rowIndex = createEmptyRow(sheet, rowIndex);

    rowIndex = setTitle(sheet, rowIndex++, "参数");
    if (param != null && !param.trim().isEmpty()) {
        String[] pms = param.split("&");
        for (String pm : pms) {
            setData(sheet, rowIndex++, pm.split("=")[0], "String");
        }
    }
    rowIndex = setTitle(sheet, rowIndex++, "返回值");
    LinkedHashMap<Object, Object> map = new LinkedHashMap<>();
    analysisJson(map, result, "");
    index = rowIndex;
    analysisMap(map, sheet);
    sheet.autoSizeColumn(0, true);
    sheet.autoSizeColumn(1, true);
    sheet.autoSizeColumn(9, true);
    try (FileOutputStream fileOut = new FileOutputStream(interfaceName + ".xls")) {
        wb.write(fileOut);
    }
}
项目:oneops    文件:WorkOrderExecutor.java   
/**
 * Process work-order and return message to be put in the controller response queue.
 *
 * @param o CmsWorkOrderSimpleBase
 * @param correlationId JMS correlation Id
 * @returns response message map.
 */
@Override
public Map<String, String> process(CmsWorkOrderSimpleBase o, String correlationId) {
  CmsWorkOrderSimple wo = (CmsWorkOrderSimple) o;

  // compute::replace will do a delete and add - only for old pre-versioned compute
  String[] classParts = wo.getRfcCi().getCiClassName().split("\\.");
  if (classParts.length < 3 && isWorkOrderOfCompute(wo) && isAction(wo, REPLACE)) {
    logger.info("compute::replace - delete then add");
    wo.getRfcCi().setRfcAction(DELETE);
    process(wo, correlationId);

    if (wo.getDpmtRecordState().equals(COMPLETE)) {
      if (wo.getRfcCi().getCiAttributes().containsKey("instance_id")) {
        wo.getRfcCi().getCiAttributes().remove("instance_id");
      }
      wo.getRfcCi().setRfcAction(ADD);
    } else {
      logger.info("compute::replace - delete failed");
      return buildResponseMessage(wo, correlationId);
    }
  }

  long startTime = System.currentTimeMillis();
  if (config.isCloudStubbed(wo)) {
    String fileName = config.getDataDir() + "/" + wo.getDpmtRecordId() + ".json";
    writeChefRequest(wo, fileName);
    processStubbedCloud(wo);
    logger.warn("completing wo without doing anything because cloud is stubbed");
  } else {
    // skip fqdn workorder if dns is disabled
    if (config.isDnsDisabled() && wo.getRfcCi().getCiClassName()
        .matches(BOM_CLASS_PREFIX + "Fqdn")) {
      wo.setDpmtRecordState(COMPLETE);
      CmsCISimple resultCi = new CmsCISimple();
      mergeRfcToResult(wo.getRfcCi(), resultCi);
      wo.setResultCi(resultCi);
      logger.info("completing wo without doing anything because dns is off");
    } else {
      // creates the json chefRequest and exec's chef to run chef local or remote via ssh/mc
      runWorkOrder(wo);
    }
  }

  long endTime = System.currentTimeMillis();
  int duration = Math.round((endTime - startTime) / 1000);
  logger.info(format("%s %s %s %s took: %d sec",
      wo.getRfcCi().getRfcAction(),
      wo.getRfcCi().getImpl(),
      wo.getRfcCi().getCiClassName(),
      wo.getRfcCi().getCiName(),
      duration));

  setTotalExecutionTime(wo, endTime - startTime);
  wo.putSearchTag(RESPONSE_ENQUE_TS, DateUtil.formatDate(new Date(), SEARCH_TS_PATTERN));
  return buildResponseMessage(wo, correlationId);
}
项目:oneops    文件:AbstractOrderExecutor.java   
private long getTimeElapsed(CmsWorkOrderSimpleBase wo) throws DateParseException {
  return System.currentTimeMillis() - DateUtil
      .parseDate(getSearchTag(wo, REQUEST_DEQUE_TS), SEARCH_TS_FORMATS).getTime();
}
项目:lib-commons-httpclient    文件:TestDateParser.java   
public void testFourDigitYear() throws Exception {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(DateUtil.parseDate("Thu, 23-Dec-2004 24:00:00 CET", PATTERNS));
    assertEquals(2004, calendar.get(Calendar.YEAR));
}
项目:lib-commons-httpclient    文件:TestDateParser.java   
public void testThreeDigitYear() throws Exception {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(DateUtil.parseDate("Thu, 23-Dec-994 24:00:00 CET", PATTERNS));
    assertEquals(994, calendar.get(Calendar.YEAR));
}
项目:linkbinder    文件:ProjectLogoManager.java   
/**
 * プロジェクトロゴファイルが変更されたか否かを判断する.
 *
 * @param projectId プロジェクトID
 * @param ifModifiedSince If-Modified-Since値
 * @return true:変更された false:変更されていない
 */
public boolean isModified(String projectId, String ifModifiedSince) {
    if (log.isDebugEnabled()) {
        log.debug("projectId[" + projectId + "]");
        log.debug("ifModifiedSince[" + ifModifiedSince + "]");
    }

    if (StringUtils.isEmpty(ifModifiedSince)) {
        // If-Modified-Sinceヘッダ(値)が無いならばtrue
        return true;
    }

    long ifModifiedSinceLongValue = 0;
    try {
        Date ifModifiedSinceDateValue = DateUtil.parseDate(ifModifiedSince);
        ifModifiedSinceLongValue = ifModifiedSinceDateValue.getTime();
        if (log.isDebugEnabled()) {
            log.debug("ifModifiedSinceDateValue[" + ifModifiedSinceDateValue + "]");
            log.debug("ifModifiedSinceLongValue[" + ifModifiedSinceLongValue + "]");
        }
    } catch (DateParseException e) {
        // 日付解析失敗なので変更されたと見なす
        log.warn("If-Modified-Since parse error[" + ifModifiedSince + "]", e);
        return true;
    }

    String logoFile = detectLogoFile(projectId);
    File f = new File(logoFile);
    if (log.isDebugEnabled()) {
        log.debug("f.exists[" + f.exists() + "]");
        log.debug("f.lastModified[" + f.lastModified() + "]");
    }

    // ミリ秒の値を秒単位で比較するため1/1000する(12:34:56.789と12:34:56.000は同じと見なす)
    //CHECKSTYLE:OFF
    if (!f.exists()
          || f.lastModified() / 1000 != ifModifiedSinceLongValue / 1000) {
        return true;
    }
    //CHECKSTYLE:ON

    if (log.isDebugEnabled()) {
        log.debug("return false");
    }
    return false;
}
项目:sonar-gerrit-plugin    文件:DateTypeConverter.java   
public JsonElement serialize(Date src, Type srcType, JsonSerializationContext context) {
    return new JsonPrimitive(DateUtil.formatDate(src));
}
项目:community-edition-old    文件:SOLRAPIClient.java   
public GetTextContentResponse getTextContent(Long nodeId, QName propertyQName, Long modifiedSince) throws AuthenticationException, IOException
{
    StringBuilder url = new StringBuilder(128);
    url.append(GET_CONTENT);

    StringBuilder args = new StringBuilder(128);
    if(nodeId != null)
    {
        args.append("?");
        args.append("nodeId");
        args.append("=");
        args.append(nodeId);            
    }
    else
    {
        throw new NullPointerException("getTextContent(): nodeId cannot be null.");
    }
    if(propertyQName != null)
    {
        if(args.length() == 0)
        {
            args.append("?");
        }
        else
        {
            args.append("&");
        }
        args.append("propertyQName");
        args.append("=");
        args.append(URLEncoder.encode(propertyQName.toString()));
    }

    url.append(args);

    GetRequest req = new GetRequest(url.toString());

    if(modifiedSince != null)
    {
        Map<String, String> headers = new HashMap<String, String>(1, 1.0f);
        headers.put("If-Modified-Since", String.valueOf(DateUtil.formatDate(new Date(modifiedSince))));
        req.setHeaders(headers);
    }

    Response response = repositoryHttpClient.sendRequest(req);

    if(response.getStatus() != Status.STATUS_NOT_MODIFIED && response.getStatus() != Status.STATUS_NO_CONTENT && response.getStatus() != Status.STATUS_OK)
    {
        throw new AlfrescoRuntimeException("GetTextContentResponse return status is " + response.getStatus());
    }

    return new GetTextContentResponse(response);
}
项目:httpclient3-ntml    文件:TestDateParser.java   
public void testFourDigitYear() throws Exception {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(DateUtil.parseDate("Thu, 23-Dec-2004 24:00:00 CET", PATTERNS));
    assertEquals(2004, calendar.get(Calendar.YEAR));
}
项目:httpclient3-ntml    文件:TestDateParser.java   
public void testThreeDigitYear() throws Exception {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(DateUtil.parseDate("Thu, 23-Dec-994 24:00:00 CET", PATTERNS));
    assertEquals(994, calendar.get(Calendar.YEAR));
}