docs: @Override
      protected void doPost(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
          LOG.debug("Entering");
          final AtomHandler handler = createAtomRequestHandler(req, res);
          final String userName = handler.getAuthenticatedUsername();
          if (userName != null) {
              final AtomRequest areq = new AtomRequestImpl(req);
              try {
                  if (handler.isCollectionURI(areq)) {
  
                      if (req.getContentType().startsWith("application/atom+xml")) {
  
                          // parse incoming entry
                          final Entry entry = Atom10Parser.parseEntry(new BufferedReader(new InputStreamReader(req.getInputStream(), "UTF-8")), null, Locale.US);
  
                          // call handler to post it
                          final Entry newEntry = handler.postEntry(areq, entry);
  
                          // set Location and Content-Location headers
                          for (final Object element : newEntry.getOtherLinks()) {
                              final Link link = (Link) element;
                              if ("edit".equals(link.getRel())) {
                                  res.addHeader("Location", link.getHrefResolved());
                                  break;
                              }
                          }
                          for (final Object element : newEntry.getAlternateLinks()) {
                              final Link link = (Link) element;
                              if ("alternate".equals(link.getRel())) {
                                  res.addHeader("Content-Location", link.getHrefResolved());
                                  break;
                              }
                          }
  
                          // write entry back out to response
                          res.setStatus(HttpServletResponse.SC_CREATED);
                          res.setContentType("application/atom+xml; type=entry; charset=utf-8");
  
                          final Writer writer = res.getWriter();
                          Atom10Generator.serializeEntry(newEntry, writer);
                          writer.close();
  
                      } else if (req.getContentType() != null) {
  
                          // get incoming title and slug from HTTP header
                          final String title = areq.getHeader("Title");
  
                          // create new entry for resource, set title and type
                          final Entry resource = new Entry();
                          resource.setTitle(title);
                          final Content content = new Content();
                          content.setType(areq.getContentType());
                          resource.setContents(Collections.singletonList(content));
  
                          // hand input stream off to hander to post file
                          final Entry newEntry = handler.postMedia(areq, resource);
  
                          // set Location and Content-Location headers
                          for (final Object element : newEntry.getOtherLinks()) {
                              final Link link = (Link) element;
                              if ("edit".equals(link.getRel())) {
                                  res.addHeader("Location", link.getHrefResolved());
                                  break;
                              }
                          }
                          for (final Object element : newEntry.getAlternateLinks()) {
                              final Link link = (Link) element;
                              if ("alternate".equals(link.getRel())) {
                                  res.addHeader("Content-Location", link.getHrefResolved());
                                  break;
                              }
                          }
  
                          res.setStatus(HttpServletResponse.SC_CREATED);
                          res.setContentType("application/atom+xml; type=entry; charset=utf-8");
  
                          final Writer writer = res.getWriter();
                          Atom10Generator.serializeEntry(newEntry, writer);
                          writer.close();
  
                      } else {
                          res.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, "No content-type specified in request");
                      }
  
                  } else {
                      res.sendError(HttpServletResponse.SC_NOT_FOUND, "Invalid collection specified in request");
                  }
              } catch (final AtomException ae) {
                  res.sendError(ae.getStatus(), ae.getMessage());
                  LOG.debug("An error occured while processing POST", ae);
              } catch (final Exception e) {
                  res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
                  LOG.debug("An error occured while processing POST", e);
              }
          } else {
              res.setHeader("WWW-Authenticate", "BASIC realm=\"AtomPub\"");
              res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
          }
          LOG.debug("Exiting");
      }