コード例 #1
0
  /** Test of find method, of class BitstreamFormat. */
  @Test
  public void testFind() throws SQLException {
    BitstreamFormat found = BitstreamFormat.find(context, 1);
    assertThat("testFind 0", found, notNullValue());
    assertThat("testFind 1", found.getShortDescription(), equalTo("Unknown"));

    found = BitstreamFormat.find(context, 2);
    assertThat("testFind 2", found, notNullValue());
    assertThat("testFind 3", found.getShortDescription(), equalTo("License"));
    assertTrue("testFind 4", found.isInternal());
  }
コード例 #2
0
ファイル: UploadStep.java プロジェクト: richardrodgers/DSpace
  /**
   * Process input from get file type page
   *
   * @param context current DSpace context
   * @param request current servlet request object
   * @param response current servlet response object
   * @param subInfo submission info object
   * @return Status or error flag which will be processed by UI-related code! (if STATUS_COMPLETE or
   *     0 is returned, no errors occurred!)
   */
  protected int processSaveFileFormat(
      Context context,
      HttpServletRequest request,
      HttpServletResponse response,
      SubmissionInfo subInfo)
      throws ServletException, IOException, SQLException, AuthorizeException {
    if (subInfo.getBitstream() != null) {
      // Did the user select a format?
      int typeID = Util.getIntParameter(request, "format");

      BitstreamFormat format = BitstreamFormat.find(context, typeID);

      if (format != null) {
        subInfo.getBitstream().setFormat(format);
      } else {
        String userDesc = request.getParameter("format_description");

        subInfo.getBitstream().setUserFormatDescription(userDesc);
      }

      // update database
      subInfo.getBitstream().update();
    } else {
      return STATUS_INTEGRITY_ERROR;
    }

    return STATUS_COMPLETE;
  }
コード例 #3
0
 /**
  * This method will be run before every test as per @Before. It will initialize resources required
  * for the tests.
  *
  * <p>Other methods can be annotated with @Before here or in subclasses but no execution order is
  * guaranteed
  */
 @Before
 @Override
 public void init() {
   super.init();
   try {
     bf = BitstreamFormat.find(context, 5);
     bunknown = BitstreamFormat.findUnknown(context);
   } catch (SQLException ex) {
     log.error("SQL Error in init", ex);
     fail("SQL Error in init: " + ex.getMessage());
   }
 }
コード例 #4
0
  public void addBody(Body body) throws WingException, SQLException, AuthorizeException {
    // Get all our parameters
    String idsString = parameters.getParameter("formatIDs", null);

    ArrayList<BitstreamFormat> formats = new ArrayList<BitstreamFormat>();
    for (String id : idsString.split(",")) {
      BitstreamFormat format = BitstreamFormat.find(context, Integer.valueOf(id));
      formats.add(format);
    }

    // DIVISION: bitstream-format-confirm-delete
    Division deleted =
        body.addInteractiveDivision(
            "bitstream-format-confirm-delete",
            contextPath + "/admin/format-registry",
            Division.METHOD_POST,
            "primary administrative format-registry");
    deleted.setHead(T_head);
    deleted.addPara(T_para1);

    Table table = deleted.addTable("format-confirm-delete", formats.size() + 1, 3);
    Row header = table.addRow(Row.ROLE_HEADER);
    header.addCell().addContent(T_column1);
    header.addCell().addContent(T_column2);
    header.addCell().addContent(T_column3);

    for (BitstreamFormat format : formats) {
      if (format == null) {
        continue;
      }

      String formatID = String.valueOf(format.getID());
      String mimetype = format.getMIMEType();
      String name = format.getShortDescription();

      Row row = table.addRow();
      row.addCell().addContent(formatID);
      row.addCell().addContent(mimetype);
      row.addCell().addContent(name);
    }
    Para buttons = deleted.addPara();
    buttons.addButton("submit_confirm").setValue(T_submit_delete);
    buttons.addButton("submit_cancel").setValue(T_submit_cancel);

    deleted.addHidden("administrative-continue").setValue(knot.getId());
  }
コード例 #5
0
  /** Test of delete method, of class BitstreamFormat. */
  @Test
  public void testDeleteAdmin() throws SQLException, AuthorizeException {

    new NonStrictExpectations() {
      AuthorizeManager authManager;
      BitstreamFormat unknown;

      {
        AuthorizeManager.isAdmin((Context) any);
        result = true;
      }
    };

    bf.delete();
    BitstreamFormat b = BitstreamFormat.find(context, 5);
    assertThat("testDeleteAdmin 0", b, nullValue());
  }
コード例 #6
0
  /** Test of update method, of class BitstreamFormat. */
  @Test
  public void testUpdateAdmin() throws SQLException, AuthorizeException {

    new NonStrictExpectations() {
      AuthorizeManager authManager;

      {
        AuthorizeManager.isAdmin((Context) any);
        result = true;
      }
    };

    String desc = "Test description";
    bf.setDescription(desc);
    bf.update();

    BitstreamFormat b = BitstreamFormat.find(context, 5);
    assertThat("testUpdateAdmin 0", b.getDescription(), equalTo(desc));
  }