當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpServletResponse.SC_CONFLICT屬性代碼示例

本文整理匯總了Java中javax.servlet.http.HttpServletResponse.SC_CONFLICT屬性的典型用法代碼示例。如果您正苦於以下問題:Java HttpServletResponse.SC_CONFLICT屬性的具體用法?Java HttpServletResponse.SC_CONFLICT怎麽用?Java HttpServletResponse.SC_CONFLICT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.servlet.http.HttpServletResponse的用法示例。


在下文中一共展示了HttpServletResponse.SC_CONFLICT屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: uploadImageFromStorage

/**
 * Requests that the NameNode download an image from this node.  Allows for
 * optional external cancelation.
 *
 * @param fsName the http address for the remote NN
 * @param conf Configuration
 * @param storage the storage directory to transfer the image from
 * @param nnf the NameNodeFile type of the image
 * @param txid the transaction ID of the image to be uploaded
 * @param canceler optional canceler to check for abort of upload
 * @throws IOException if there is an I/O error or cancellation
 */
public static void uploadImageFromStorage(URL fsName, Configuration conf,
    NNStorage storage, NameNodeFile nnf, long txid, Canceler canceler)
    throws IOException {
  URL url = new URL(fsName, ImageServlet.PATH_SPEC);
  long startTime = Time.monotonicNow();
  try {
    uploadImage(url, conf, storage, nnf, txid, canceler);
  } catch (HttpPutFailedException e) {
    if (e.getResponseCode() == HttpServletResponse.SC_CONFLICT) {
      // this is OK - this means that a previous attempt to upload
      // this checkpoint succeeded even though we thought it failed.
      LOG.info("Image upload with txid " + txid + 
          " conflicted with a previous image upload to the " +
          "same NameNode. Continuing...", e);
      return;
    } else {
      throw e;
    }
  }
  double xferSec = Math.max(
      ((float) (Time.monotonicNow() - startTime)) / 1000.0, 0.001);
  LOG.info("Uploaded image with txid " + txid + " to namenode at " + fsName
      + " in " + xferSec + " seconds");
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:36,代碼來源:TransferFsImage.java

示例2: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    Map<String, Object> model = new HashMap<String, Object>();
    
    // Current user
    String userID = AuthenticationUtil.getFullyAuthenticatedUser();
    if (userID == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_UNAUTHORIZED, "Web Script ["
                    + req.getServiceMatch().getWebScript().getDescription()
                    + "] requires user authentication.");
    }

    NodeRef nodeRefToBeRestored = parseRequestForNodeRef(req);
    if (nodeRefToBeRestored == null)
    {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "nodeRef not recognised. Could not restore.");
    }
    
    // check if the current user has the permission to restore the node
    validatePermission(nodeRefToBeRestored, userID);
    
    RestoreNodeReport report = nodeArchiveService.restoreArchivedNode(nodeRefToBeRestored);

    // Handling of some error scenarios
    if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_INVALID_ARCHIVE_NODE))
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find archive node: " + nodeRefToBeRestored);
    }
    else if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_PERMISSION))
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "Unable to restore archive node: " + nodeRefToBeRestored);
    }
    else if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_DUPLICATE_CHILD_NODE_NAME))
    {
        throw new WebScriptException(HttpServletResponse.SC_CONFLICT, "Unable to restore archive node: " + nodeRefToBeRestored +". Duplicate child node name");
    }
    else if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_INVALID_PARENT) ||
             report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_INTEGRITY) ||
             report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_OTHER))
    {
        throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to restore archive node: " + nodeRefToBeRestored);
    }
    
    model.put("restoreNodeReport", report);
    return model;
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:48,代碼來源:ArchivedNodePut.java


注:本文中的javax.servlet.http.HttpServletResponse.SC_CONFLICT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。