CenterForDigitalHumanities / TPEN28

Split front/back ends from each other
3 stars 2 forks source link

Some issues with private upload projects... #388

Open cubap opened 7 years ago

cubap commented 7 years ago

Here's what I did. Upload a zip with one image and try to open the project. The upload process went smoothly and the messages were positive. The project management showed me the page and information stored correctly. When I went to transcribe, I got a crazy trexhead (below) with no errors across it (there is usually a red band with the error). All the pieces, however, seem to be in the right place.

I get a real JSON when I http://165.134.105.25/TPEN28/getProjectTPENServlet?projectID=5449

and I get my image when I http://165.134.105.25/TPEN28/imageResize?folioNum=13219325&height=2000&user=cubap@slu.edu

So I'm looking into where the actual error is cropping up.

image

cubap commented 7 years ago

This is appearing because permissionForImage is false. The #requestAccess is 0 height for some reason and no matter how I play with z-index (trex has a 3), I can't get it into the right stack.

More importantly, this is a newly created private upload, so it shouldn't be a restricted manuscript. If it is, I should be allowed by default, as the creator.

thehabes commented 7 years ago

Fixed the CSS issues

thehabes commented 7 years ago

The other problems are much deeper. Manuscript.getControllingUser() is always returning null, which is screwing up permission checks in getProjectTPENServlet

thehabes commented 7 years ago

I have narrowed it down to an unexpected null (which is now handled) and this

if(user.getUname().equals(controllerName) ||  forThisFolio.isRestricted()){ 
              //This user is the controlling user or this folio is not restricted
              folio_obj.element("ipr", true); //should be true in this case because the check needs to pass
 }

And the fact that auth attached to the user ends up false when it shouldn't, which I am on now

thehabes commented 7 years ago

FileUpload.java says

Manuscript ms = new Manuscript(repository, archive, collection, city, -999);

Public Manuscript(all, "private", these, five, things) says

if (!"private".equals(arch)) {            
            try (PreparedStatement lookup = conn.prepareStatement("SELECT * FROM manuscript WHERE repository=? AND msIdentifier=? AND archive=?")) {
               lookup.setString(1, repo);
               lookup.setString(2, coll);
               lookup.setString(3, arch);
               ResultSet rs = lookup.executeQuery();
               if (rs.next()) {
                  id = rs.getInt("id");
                  return;
               }
            }
         }
         try (PreparedStatement insertion = conn.prepareStatement("INSERT INTO `manuscript` (`repository`, `archive`, `msIdentifier`, `city`, `restricted`) "
              + "VALUES (?,?,?,?,?)", PreparedStatement.RETURN_GENERATED_KEYS)) {
            insertion.setString(1, repo);
            insertion.setString(2, arch);
            insertion.setString(3, coll);
            insertion.setString(4, c);
            insertion.setInt(5, restricted);
            insertion.executeUpdate();
            ResultSet rs = insertion.getGeneratedKeys();
            if (rs.next()) {
               id = rs.getInt(1);
            }
         }

and Manuscript.isRestricted says

String query = "select restricted from manuscript where id=?";
      Connection j = null;
      PreparedStatement ps = null;
      try {
         j = DatabaseWrapper.getConnection();
         ps = j.prepareStatement(query);
         ps.setInt(1, id);
         ResultSet rs = ps.executeQuery();
         if (rs.next()) {
            if (rs.getInt(1) != 0) {
               return true;
            }
         }
      }

So somehwere something needs to change.

thehabes commented 7 years ago

I went into the logs and they told me Is -999 equal to 0 No, return true (meaning this is restricted) the user is not authorized for this manuscript

Since it was restricted and the user is not authorized, it tried to throw the error "Patrick, you are not a part of this project" which was the trex head you saw without the message, I got the message on mine.

Now, everytime I reload, it just tells me it can't get the image instead of throwing the trex head properly.

I believe if (rs.getInt(1) !=0) needs to be if(rs.getInt(1)!=0 && rs.getInt(1)!=-999)

thehabes commented 7 years ago

Fixed, but now I can't get any images on .25

thehabes commented 7 years ago

missing a / in SERVERURL, this is done.