Package ca.carleton.gcrc.couch.client

Examples of ca.carleton.gcrc.couch.client.CouchAuthenticationContext


      jsonDoc = new JSONObject();
      jsonDoc.put("_id", "org.nunaliit.date_clusters");
    }

    jsonDoc.put("nunaliit_date_clusters", tree.toJSON());
    CouchAuthenticationContext authContext = db.getClient().getSession().getAuthenticationContext();
    CouchNunaliitUtils.adjustDocumentForStorage(jsonDoc, authContext);
    if( exists ){
      db.updateDocument(jsonDoc);
    } else {
      db.createDocument(jsonDoc);
View Full Code Here


  }

  public void analyzeFile(AttachmentDescriptor attDescription) throws Exception {
    DocumentDescriptor docDescriptor = attDescription.getDocumentDescriptor();
    OriginalFileDescriptor originalObj = attDescription.getOriginalFileDescription();
    CouchAuthenticationContext submitter = attDescription.getSubmitter();
   
    // Figure out media file located on disk
    File originalFile = originalObj.getMediaFile();
    String mimeType = originalObj.getContentType();
View Full Code Here

// GET /_sleep        - Returns success after waiting for a given number of milliseconds (removed since 1.0.0)
// GET /_utils/file   - Return static web pages that contain the CouchDB administration interface
   
    try {
      Cookie[] cookies = req.getCookies();
      CouchAuthenticationContext authContext = getAuthenticationContextFromCookies(cookies);
     
      List<String> path = computeRequestPath(req);
     
      String dbIdentifier = null;
      if( path.size() > 0 ){
View Full Code Here

// PUT /db/_design/design-doc            - Inserts a new version of the design document
// PUT /db/_design/design-doc/attachment - Inserts an attachment to the design document
   
    try {
      Cookie[] cookies = req.getCookies();
      CouchAuthenticationContext authContext = getAuthenticationContextFromCookies(cookies);
     
      List<String> path = computeRequestPath(req);
     
      String dbIdentifier = null;
      if( path.size() > 0 ){
View Full Code Here

// DELETE /db/_design/design-doc - Deletes the design document
// DELETE /db/_design/design-doc/attachment - Deletes an attachment from the design document
   
    try {
      Cookie[] cookies = req.getCookies();
      CouchAuthenticationContext authContext = getAuthenticationContextFromCookies(cookies);
     
      List<String> path = computeRequestPath(req);
     
      String dbIdentifier = null;
      if( path.size() > 0 ){
View Full Code Here

   
    CouchFactory factory = new CouchFactory();
    CouchClient userClient = factory.getClient(contextCookie, client);
   
    CouchSession session = userClient.getSession();
    CouchAuthenticationContext authContext = session.getAuthenticationContext();
   
    return authContext;
  }
View Full Code Here

        throw new Exception("Analysis required but original object is not present");
      }
      OriginalFileDescriptor originalObj = attDescription.getOriginalFileDescription();
     
      // Verify if a submitter is specified
      CouchAuthenticationContext submitter = attDescription.getSubmitter();

      boolean pluginFound = false;
      String fileClass = attDescription.getFileClass();
      for(FileConversionPlugin fcp : this.fileConverters) {
        if( fcp.handlesFileClass(fileClass, FileConversionPlugin.WORK_ANALYZE) ) {
View Full Code Here

  }

  public void analyzeFile(AttachmentDescriptor attDescription) throws Exception {
    DocumentDescriptor docDescriptor = attDescription.getDocumentDescriptor();
    OriginalFileDescriptor originalObj = attDescription.getOriginalFileDescription();
    CouchAuthenticationContext submitter = attDescription.getSubmitter();
   
    // Figure out media file located on disk
    File originalFile = originalObj.getMediaFile();

    // Perform conversion(s)
View Full Code Here

     */
   
    try {
      // Get CouchDb instance on behalf of the user
      CouchDb userCouchDb = getUserCouchDbFromCookies(cookies);
      CouchAuthenticationContext userContext = getUserFromClient(userCouchDb.getClient());
     
      // Create an upload request
      JSONObject doc = new JSONObject();
     
      JSONObject uploadRequest = new JSONObject();
      doc.put("nunaliit_upload_request", uploadRequest);
      uploadRequest.put("docId", docId);
      uploadRequest.put("revision", revision);
      uploadRequest.put("uploadId", uploadId);

      JSONArray files = new JSONArray();
      uploadRequest.put("files", files);
     
      Set<String> fileNames = new HashSet<String>();
      for(LoadedFile uploadedFile : uploadedFiles) {
        File actualFile = uploadedFile.getFile();
        String originalName = uploadedFile.getOriginalFileName();
       
        // Compute name for attachment
        String attachmentName = null;
        {
          File tempFile = new File(originalName);
          attachmentName = tempFile.getName();
          if( fileNames.contains(attachmentName) ) {
            // Select a different file name
            String prefix = "";
            String suffix = "";
            int pos = attachmentName.indexOf('.', 1);
            if( pos < 0 ) {
              prefix = attachmentName;
            } else {
              prefix = attachmentName.substring(0, pos-1);
              suffix = attachmentName.substring(pos);
            }
            int counter = 0;
            while( fileNames.contains(attachmentName) ) {
              attachmentName = prefix + counter + suffix;
              ++counter;
            }
          }
        }
        fileNames.add(attachmentName);
       
        JSONObject file = new JSONObject();
        files.put(file);
        file.put("attachmentName", attachmentName);
        file.put("originalName", originalName);
        file.put("submitter", userContext.getName());
       
        JSONObject original = new JSONObject();
        file.put("original", original);
        original.put("mediaFile", actualFile.getName());
       
View Full Code Here

  public void setSubmitterName(String originalName) throws Exception {
    setStringAttribute(UploadConstants.SUBMITTER_KEY,originalName);
  }
 
  public CouchAuthenticationContext getSubmitter() throws Exception {
    CouchAuthenticationContext submitter = null;
   
    String submitterName = getSubmitterName();
    if( null != submitterName ) {
      try {
        submitter = getContext().getUserFromName(submitterName);
View Full Code Here

TOP

Related Classes of ca.carleton.gcrc.couch.client.CouchAuthenticationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.