예제 #1
0
  void doUpdateRecords(HttpServletRequest request, HttpServletResponse response, int serviceCall)
      throws ServletException, IOException, RecordServicesException {

    MetadataSchemaTypes schemaTypes = getSchemaTypes(COLLECTION);
    MetadataSchema schema = schemaTypes.getSchema("folder_default");
    int sizeInOctets = getRequiredIntegerParameter(request, SIZE_IN_OCTETS_PARAMETER);
    int qty = getRequiredIntegerParameter(request, QUANTITY_PARAMETER);
    RecordsFlushing recordsFlushing = getRecordsFlushing(request);

    List<Record> records = getRandomFolders(qty, serviceCall);
    for (int i = 0; i < records.size(); i++) {
      Record record = records.get(i);
      setRecordMetadatas(record, schema, Octets.octets(sizeInOctets), serviceCall + i);
    }
    Transaction transaction = new Transaction(records);
    transaction.setRecordFlushing(recordsFlushing);
    transaction.setOptimisticLockingResolution(OptimisticLockingResolution.EXCEPTION);
    getRecordServices().execute(transaction);
  }
예제 #2
0
  void doAddFolder(HttpServletRequest request, HttpServletResponse response, int serviceCall)
      throws ServletException, IOException, RecordServicesException {
    int addedFolder = addedFolderCounter.incrementAndGet();
    int qty = getRequiredIntegerParameter(request, QUANTITY_PARAMETER);
    int sizeInOctets = getRequiredIntegerParameter(request, SIZE_IN_OCTETS_PARAMETER);

    MetadataSchemaTypes schemaTypes = getSchemaTypes(COLLECTION);
    MetadataSchema folderSchema = schemaTypes.getSchema("folder_default");
    RecordsFlushing recordsFlushing = getRecordsFlushing(request);

    List<Record> records = new ArrayList<>();
    for (int i = 0; i < qty; i++) {
      int counter = addedFolder + i;

      String categoryId = level1And2CategoryIds.get(counter % level1And2CategoryIds.size());
      AdministrativeUnit administrativeUnit =
          new AdministrativeUnit(
              administrativeUnits.get(counter % administrativeUnits.size()), schemaTypes);

      Record newFolderRecord = getRecordServices().newRecordWithSchema(folderSchema);
      Folder newFolder = new Folder(newFolderRecord, schemaTypes);
      newFolder.setCategoryEntered(categoryId);
      newFolder.setRetentionRuleEntered(TEST_RULE_ID);
      newFolder.setCopyStatusEntered(CopyType.PRINCIPAL);
      newFolder.setOpenDate(new LocalDate(2010, 1, 1));
      newFolder.setFilingSpaceEntered(administrativeUnit.getFilingSpaces().get(0));
      newFolder.setAdministrativeUnitEntered(administrativeUnit);

      setRecordMetadatas(
          newFolderRecord, folderSchema, Octets.octets(sizeInOctets), addedFolder + i);
      records.add(newFolderRecord);
    }
    Transaction transaction = new Transaction(records);
    transaction.setRecordFlushing(recordsFlushing);
    getRecordServices().execute(transaction);
  }