@Override
	public String addDocument(Map<String, Object> document, String docClass) throws DocumentException {

		HttpAutomationClient client = null;
		Session session = null;
		String docid = null;
		String uniqueFileName = null;
		
		try {
			
			String fileName = (String) document.get(DocumentConstants.FILE_NAME);
			String mimeType = (String) document.get(DocumentConstants.FILE_TYPE);
			Object fileContent = document.get(DocumentConstants.FILE_CONTENT);
			
			if((fileName == null) || (mimeType == null) || !(fileContent instanceof String)){
				throw new DocumentException(
						DocumentConstants.ERR_CODE_ADDDOC_MISSING_REQ_PARAM,
						DocumentConstants.ERR_MSG_ADDDOC_MISSING_REQ_PARAM);
			}
			
			document.remove(DocumentConstants.FILE_NAME);
			document.remove(DocumentConstants.FILE_TYPE);
			document.remove(DocumentConstants.FILE_CONTENT);
			uniqueFileName = getUUID(fileName);
			PropertyMap props = new PropertyMap();
			
			for(Map.Entry<String, Object> property : document.entrySet()){
				props.set("dc:"+property.getKey(),String.valueOf(property.getValue()));	
			}
			
			client = new HttpAutomationClient(getURL());
			session = client.getSession(getUserName(), getPassword());
						
			OperationRequest docReq = session.newRequest("Document.Create");
			docReq.setInput(new PathRef(getWorkspace()));
			docReq.set("type", docClass);
			docReq.set("name", uniqueFileName);
			docReq.set("properties", props);
			Document doc = (Document) docReq.execute();
			docid = doc.getId();
			// Upload The file
	        File file = new File((String)fileContent);
	        FileBlob fb = new FileBlob(file);
	        fb.setMimeType(mimeType);
	        fb.setFileName(fileName);
	        OperationRequest blobReq = session.newRequest("Blob.Attach");
	        // uploading a file will return null since we used HEADER_NX_VOIDOP
	        blobReq.setHeader(Constants.HEADER_NX_VOIDOP, "true");
	        blobReq.setInput(fb);
  	        blobReq.set("document", getWorkspace()+"/"+uniqueFileName);
  	        blobReq.execute();
			
		} catch (Exception ex) {
			throw new DocumentException(ex, DocumentConstants.ERR_CODE_GENERIC,
					DocumentConstants.ERR_MSG_GENERIC);
		} finally {
			
			if (session != null) {
				session.close();
				session = null;
			}

			if (client != null) {
				client.shutdown();
				client = null;
			}
		}

		return docid;
	}