@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		UserService userService = UserServiceFactory.getUserService();
		RequestDispatcher disp = null;
		if (userService.isUserLoggedIn()) {
			User user = userService.getCurrentUser();
			PersistenceManager pm = PMF.get();
			DocumentsToken token = null;
			try {
				token = pm.getObjectById(DocumentsToken.class, user.getEmail());
				String taskName = req.getParameter("taskName");
				if (taskName != null) {
					CompositeTask task = TaskDAO.getTask(taskName);
					if (task != null) {
						GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
						oauthParameters.setOAuthConsumerKey("anonymous");
						oauthParameters.setOAuthConsumerSecret("anonymous");
						oauthParameters.setOAuthToken(token.getToken());
						oauthParameters.setOAuthTokenSecret(token
								.getTokenSecret());
						OAuthSigner signer = new OAuthHmacSha1Signer();

						SpreadsheetService service = new SpreadsheetService(
								"SpreadsheetService");
						List<SpreadsheetEntry> listOfEntries = null;
						try {
							service.setOAuthCredentials(oauthParameters, signer);
							SpreadsheetFeed feed = service
									.getFeed(
											new URL(
													"https://spreadsheets.google.com/feeds/spreadsheets/private/full"),
											SpreadsheetFeed.class);
							listOfEntries = feed.getEntries();
							List<DocumentEntity> listOfDocumentEntities = new ArrayList<DocumentEntity>();
							;
							req.setAttribute("taskName", taskName);
							if (listOfEntries.size() != 0) {
								DocumentEntity entity = null;
								for (SpreadsheetEntry entry : listOfEntries) {
									entity = new DocumentEntity();
									entity.setDocName(entry.getTitle()
											.getPlainText());
									entity.setHref(entry.getHtmlLink()
											.getHref());
									listOfDocumentEntities.add(entity);

								}
							}
							req.setAttribute("listOfEntities",
									listOfDocumentEntities);
							disp = req.getRequestDispatcher("AddDocs.jsp");
							disp.forward(req, resp);
						} catch (Exception e) {
							e.printStackTrace();
						}

					} else {
						String errText = "Task with task name " + taskName
								+ "doesnt exist.";
						req.setAttribute("err", errText);
						disp = req.getRequestDispatcher("err.jsp");
						disp.forward(req, resp);
					}
				} else {
					String errText = "parametru taskName is null";
					req.setAttribute("err", errText);
					disp = req.getRequestDispatcher("err.jsp");
					disp.forward(req, resp);
				}
			} catch (JDOObjectNotFoundException e) {
				String consumerKey = "anonymous";
				String consumerSecret = "anonymous";
				String scope = "https://spreadsheets.google.com/feeds https://docs.google.com/feeds";
				String callback = "http://vrchlpet-pc.appspot.com/documentscallbackservlet";

				GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
				oauthParameters.setOAuthConsumerKey(consumerKey);
				oauthParameters.setOAuthConsumerSecret(consumerSecret);
				oauthParameters.setScope(scope);
				oauthParameters.setOAuthCallback(callback);

				OAuthSigner signer = new OAuthHmacSha1Signer();
				GoogleOAuthHelper oauthHelper = new GoogleOAuthHelper(signer);
				try {
					oauthHelper.getUnauthorizedRequestToken(oauthParameters);
					String approvalPageUrl = oauthHelper
							.createUserAuthorizationUrl(oauthParameters);
					req.getSession().setAttribute("tokenSecret",
							oauthParameters.getOAuthTokenSecret());
					resp.sendRedirect(approvalPageUrl);
					return;
				} catch (OAuthException ee) {
					ee.printStackTrace();
				}
			}
		} else {
			disp = req.getRequestDispatcher("/projectcontrol");
			disp.forward(req, resp);
		}

	}