Example usage for org.springframework.transaction.support DefaultTransactionDefinition DefaultTransactionDefinition

List of usage examples for org.springframework.transaction.support DefaultTransactionDefinition DefaultTransactionDefinition

Introduction

In this page you can find the example usage for org.springframework.transaction.support DefaultTransactionDefinition DefaultTransactionDefinition.

Prototype

public DefaultTransactionDefinition(int propagationBehavior) 

Source Link

Document

Create a new DefaultTransactionDefinition with the given propagation behavior.

Usage

From source file:edu.ur.hibernate.ir.file.db.FileVersionDAOTest.java

/**
 * Test add a file to an Version/* w w w  .jav  a2 s . c  om*/
 * @throws LocationAlreadyExistsException 
 */
@Test
public void versionAddFileDAOTest() throws IllegalFileSystemNameException, LocationAlreadyExistsException {

    // Start the transaction 
    TransactionDefinition td = new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus ts = tm.getTransaction(td);

    RepositoryBasedTestHelper repoHelper = new RepositoryBasedTestHelper(ctx);
    Repository repo = repoHelper.createRepository("localFileServer", "displayName", "file_database",
            "my_repository", properties.getProperty("a_repo_path"), "default_folder");

    // save the repository commit transaction
    tm.commit(ts);

    // Start the transaction 
    ts = tm.getTransaction(td);

    // create the first file to store in the temporary folder
    String tempDirectory = properties.getProperty("ir_hibernate_temp_directory");
    File directory = new File(tempDirectory);

    // helper to create the file
    FileUtil testUtil = new FileUtil();
    testUtil.createDirectory(directory);

    File f = testUtil.creatFile(directory, "testFile",
            "Hello  - irFile This is text in a file - VersionedFileDAO test");

    // create the file in the file system.
    FileInfo fileInfo1 = repo.getFileDatabase().addFile(f, "newFile1");
    fileInfo1.setDisplayName("displayName1");
    tm.commit(ts);

    // Start the transaction - create a versioned file with a new version
    ts = tm.getTransaction(td);

    UserEmail userEmail = new UserEmail("email");

    IrUser user = new IrUser("aUser", "password");
    user.setPasswordEncoding("encoding");
    user.addUserEmail(userEmail, true);
    userDAO.makePersistent(user);
    VersionedFile vif = new VersionedFile(user, fileInfo1, "new file test");
    FileVersion version = vif.getCurrentVersion();
    versionedFileDAO.makePersistent(vif);
    tm.commit(ts);

    Long irFileId = version.getIrFile().getId();

    // Start the transaction 
    ts = tm.getTransaction(td);
    FileVersion other = versionDAO.getById(version.getId(), false);

    assert other != null : "Other should not be null";
    assert other.getVersionNumber() == version.getVersionNumber() : " Version numbers should be equal";

    versionedFileDAO.makeTransient(versionedFileDAO.getById(vif.getId(), false));
    irFileDAO.makeTransient(irFileDAO.getById(irFileId, false));
    userDAO.makeTransient(userDAO.getById(user.getId(), false));
    tm.commit(ts);

    // Start the transaction  - clean up the data
    ts = tm.getTransaction(td);
    repoHelper.cleanUpRepository();
    tm.commit(ts);
}

From source file:net.longfalcon.newsj.FetchBinaries.java

@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
public long scan(NewsClient nntpClient, Group group, long firstArticle, long lastArticle, String type,
        boolean compressedHeaders) throws IOException {
    // this is a hack - tx is not working ATM
    TransactionStatus transaction = transactionManager
            .getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));

    long startHeadersTime = System.currentTimeMillis();

    long maxNum = 0;
    Map<String, Message> messages = new LinkedHashMap<>(MESSAGE_BUFFER + 1);

    Iterable<NewsArticle> articlesIterable = null;
    try {/*from   w ww  .ja  v  a  2 s .c  o m*/
        if (compressedHeaders) {
            _log.warn("Compressed Headers setting not currently functional");
            articlesIterable = nntpClient.iterateArticleInfo(firstArticle, lastArticle);
        } else {
            articlesIterable = nntpClient.iterateArticleInfo(firstArticle, lastArticle);
        }
    } catch (IOException e) {
        _log.error(e.toString());
        if (nntpClient.getReplyCode() == 400) {
            _log.info("NNTP connection timed out. Reconnecting...");
            nntpClient = nntpConnectionFactory.getNntpClient();
            nntpClient.selectNewsgroup(group.getName());
            articlesIterable = nntpClient.iterateArticleInfo(firstArticle, lastArticle);
        }
    }

    Period headersTime = new Period(startHeadersTime, System.currentTimeMillis());

    Set<Long> rangeRequested = ArrayUtil.rangeSet(firstArticle, lastArticle);
    Set<Long> messagesReceived = new HashSet<>();
    Set<Long> messagesBlacklisted = new HashSet<>();
    Set<Long> messagesIgnored = new HashSet<>();
    Set<Long> messagesInserted = new HashSet<>();
    Set<Long> messagesNotInserted = new HashSet<>();

    // check error codes?

    long startUpdateTime = System.currentTimeMillis();

    if (articlesIterable != null) {
        for (NewsArticle article : articlesIterable) {
            long articleNumber = article.getArticleNumberLong();

            if (articleNumber == 0) {
                continue;
            }

            messagesReceived.add(articleNumber);

            Pattern pattern = Defaults.PARTS_SUBJECT_REGEX;
            String subject = article.getSubject();
            Matcher matcher = pattern.matcher(subject);
            if (ValidatorUtil.isNull(subject) || !matcher.find()) {
                // not a binary post most likely.. continue
                messagesIgnored.add(articleNumber);
                if (_log.isDebugEnabled()) {
                    _log.debug(String.format("Skipping message no# %s : %s", articleNumber, subject));
                }
                continue;
            }

            //Filter binaries based on black/white list
            if (isBlacklisted(article, group)) {
                messagesBlacklisted.add(articleNumber);
                continue;
            }
            String group1 = matcher.group(1);
            String group2 = matcher.group(2);
            if (ValidatorUtil.isNumeric(group1) && ValidatorUtil.isNumeric(group2)) {
                int currentPart = Integer.parseInt(group1);
                int maxParts = Integer.parseInt(group2);
                subject = (matcher.replaceAll("")).trim();

                if (!messages.containsKey(subject)) {
                    messages.put(subject, new Message(article, currentPart, maxParts));
                } else if (currentPart > 0) {
                    Message message = messages.get(subject);
                    String articleId = article.getArticleId();
                    String messageId = articleId.substring(1, articleId.length() - 1);
                    int size = article.getSize();
                    message.addPart(currentPart, messageId, articleNumber, size);
                    messages.put(subject, message);
                }
            }
        }

        long count = 0;
        long updateCount = 0;
        long partCount = 0;
        maxNum = lastArticle;

        // add all the requested then remove the ones we did receive.
        Set<Long> rangeNotRecieved = new HashSet<>();
        rangeNotRecieved.addAll(rangeRequested);
        rangeNotRecieved.removeAll(messagesReceived);

        if (!type.equals("partrepair")) {
            _log.info(String.format("Received %d articles of %d requested, %d blacklisted, %d not binaries",
                    messagesReceived.size(), lastArticle - firstArticle + 1, messagesBlacklisted.size(),
                    messagesIgnored.size()));
        }

        if (rangeNotRecieved.size() > 0) {
            switch (type) {
            case "backfill":
                // don't add missing articles
                break;
            case "partrepair":
            case "update":
            default:
                addMissingParts(rangeNotRecieved, group);
                break;
            }
            _log.info("Server did not return article numbers " + ArrayUtil.stringify(rangeNotRecieved));
        }

        if (!messages.isEmpty()) {

            long dbUpdateTime = 0;
            maxNum = firstArticle;
            //insert binaries and parts into database. when binary already exists; only insert new parts
            for (Map.Entry<String, Message> entry : messages.entrySet()) {
                String subject = entry.getKey();
                Message message = entry.getValue();

                Map<Integer, MessagePart> partsMap = message.getPartsMap();
                if (!ValidatorUtil.isNull(subject) && !partsMap.isEmpty()) {
                    String binaryHash = EncodingUtil
                            .md5Hash(subject + message.getFrom() + String.valueOf(group.getId()));
                    Binary binary = binaryDAO.findByBinaryHash(binaryHash);
                    if (binary == null) {
                        long startDbUpdateTime = System.currentTimeMillis();
                        binary = new Binary();
                        binary.setName(subject);
                        binary.setFromName(message.getFrom());
                        binary.setDate(message.getDate().toDate());
                        binary.setXref(message.getxRef());
                        binary.setTotalParts(message.getMaxParts());
                        binary.setGroupId(group.getId());
                        binary.setBinaryHash(binaryHash);
                        binary.setDateAdded(new Date());
                        binaryDAO.updateBinary(binary);
                        dbUpdateTime += (System.currentTimeMillis() - startDbUpdateTime);
                        count++;
                        if (count % 500 == 0) {
                            _log.info(String.format("%s bin adds...", count));
                        }
                    } else {
                        updateCount++;
                        if (updateCount % 500 == 0) {
                            _log.info(String.format("%s bin updates...", updateCount));
                        }
                    }

                    long binaryId = binary.getId();
                    if (binaryId == 0) {
                        throw new RuntimeException("ID for binary wasnt set.");
                    }

                    for (MessagePart messagePart : message.getPartsMap().values()) {
                        long articleNumber = messagePart.getArticleNumber();
                        maxNum = (articleNumber > maxNum) ? articleNumber : maxNum;
                        partCount++;
                        // create part - its possible some bugs are happening here.
                        Part part = new Part();
                        part.setBinaryId(binaryId);
                        part.setMessageId(messagePart.getMessageId());
                        part.setNumber(messagePart.getArticleNumber());
                        part.setPartNumber(messagePart.getPartNumber());
                        part.setSize(messagePart.getSize());
                        part.setDateAdded(new Date());
                        try {
                            long startDbUpdateTime = System.currentTimeMillis();
                            partDAO.updatePart(part);
                            dbUpdateTime += (System.currentTimeMillis() - startDbUpdateTime);
                            messagesInserted.add(messagePart.getArticleNumber());
                        } catch (Exception e) {
                            _log.error(e.toString());
                            messagesNotInserted.add(messagePart.getArticleNumber());
                        }

                    }
                }
            }
            //TODO: determine whether to add to missing articles if insert failed
            if (messagesNotInserted.size() > 0) {
                _log.warn("WARNING: Parts failed to insert");
                addMissingParts(messagesNotInserted, group);
            }
            Period dbUpdatePeriod = new Period(dbUpdateTime);
            _log.info("Spent " + _periodFormatter.print(dbUpdatePeriod) + " updating the db");
        }
        Period updateTime = new Period(startUpdateTime, System.currentTimeMillis());

        if (!type.equals("partrepair")) {
            _log.info(count + " new, " + updateCount + " updated, " + partCount + " parts.");
            _log.info(" " + _periodFormatter.print(headersTime) + " headers, "
                    + _periodFormatter.print(updateTime) + " update.");
        }
        transactionManager.commit(transaction);
        return maxNum;
    } else {
        _log.error("Error: Can't get parts from server (msgs not array)\n Skipping group");
        return 0;
    }

}

From source file:edu.ur.file.db.service.DefaultFileServerServiceTest.java

/**
 * Test File Database persistence/* w ww.  jav a  2 s . c  o  m*/
 * 
 * - Make sure a file database can be created.
 * - Makes sure a file database can be found.
 * @throws LocationAlreadyExistsException 
 * 
 */
@Test
public void createFileDatabaseTest() throws LocationAlreadyExistsException {

    // Start the transaction this is for lazy loading
    TransactionDefinition td = new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus ts = tm.getTransaction(td);

    DefaultFileServer fs = dfss.createFileServer("service_file_server");

    DefaultFileDatabase fileDatabase = fs.createFileDatabase("nates file server", "file_server_1",
            properties.getProperty("defaultFileServerService.server_path"), "description");

    dfss.saveFileServer(fs);

    //commit the transaction this will assing an id to the 
    //file database
    tm.commit(ts);

    //begin a new transaction
    td = new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED);
    ts = tm.getTransaction(td);
    assert dfss.getDatabaseById(fileDatabase.getId(), false)
            .equals(fileDatabase) : "the databases should be equal";

    assert dfss.getDatabaseByName(fs.getId(),
            fileDatabase.getName()) != null : "should be able to find the file database";

    tm.commit(ts);

    dfss.deleteFileServer(fs.getName());
    assert dfss.getFileServer(fs.getName()) == null : "Should not find the file server";

}

From source file:org.fcrepo.camel.FcrepoTransactionManagerTest.java

@Test
public void testTransactionCommit() throws FcrepoOperationFailedException {
    final String baseUrl = "http://localhost:8080/rest";
    final String tx = "tx:1234567890";
    final URI commitUri = URI.create(baseUrl + "/" + tx + FcrepoConstants.COMMIT);
    final URI beginUri = URI.create(baseUrl + FcrepoConstants.TRANSACTION);
    final FcrepoTransactionManager txMgr = new FcrepoTransactionManager();
    txMgr.setBaseUrl(baseUrl);/*  ww w .  ja  v a 2 s.com*/
    TestUtils.setField(txMgr, "fcrepoClient", mockClient);

    final TransactionTemplate transactionTemplate = new TransactionTemplate(txMgr);
    final DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(
            TransactionDefinition.PROPAGATION_REQUIRED);

    transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    transactionTemplate.afterPropertiesSet();

    when(mockClient.post(eq(beginUri))).thenReturn(mockPostBuilder);
    when(mockClient.post(eq(commitUri))).thenReturn(mockPostBuilder2);
    when(mockPostBuilder.perform()).thenReturn(new FcrepoResponse(beginUri, 201,
            singletonMap("Location", singletonList(baseUrl + "/" + tx)), null));
    when(mockPostBuilder2.perform()).thenReturn(new FcrepoResponse(commitUri, 201, emptyMap(), null));

    DefaultTransactionStatus status = (DefaultTransactionStatus) txMgr.getTransaction(txDef);
    FcrepoTransactionObject txObj = (FcrepoTransactionObject) status.getTransaction();

    assertEquals(tx, txObj.getSessionId());
    assertFalse(status.isCompleted());

    status = (DefaultTransactionStatus) txMgr.getTransaction(txDef);

    txMgr.commit(status);

    txObj = (FcrepoTransactionObject) status.getTransaction();

    assertNull(txObj.getSessionId());
    assertTrue(status.isCompleted());
}

From source file:org.wildfly.camel.test.jms.TransactedJMSIntegrationTest.java

@Before
public void setUp() throws Exception {
    JtaTransactionManager jtaTransactionManager = new JtaTransactionManager();
    jtaTransactionManager.setTransactionManager(transactionManager);
    jtaTransactionManager.setUserTransaction(userTransaction);

    TransactionTemplate template = new TransactionTemplate(jtaTransactionManager,
            new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));

    SpringTransactionPolicy transactionPolicy = new SpringTransactionPolicy();
    transactionPolicy.setTransactionTemplate(template);
    transactionPolicy.setTransactionManager(jtaTransactionManager);

    initialctx.bind("PROPAGATION_REQUIRED", transactionPolicy);
    initialctx.bind("transactionManager", jtaTransactionManager);

    jmsComponent = JmsComponent.jmsComponentTransacted(connectionFactory, jtaTransactionManager);
}

From source file:alfio.manager.system.DataMigrator.java

@Autowired
public DataMigrator(EventMigrationRepository eventMigrationRepository, EventRepository eventRepository,
        TicketCategoryRepository ticketCategoryRepository, @Value("${alfio.version}") String currentVersion,
        @Value("${alfio.build-ts}") String buildTimestamp, PlatformTransactionManager transactionManager,
        ConfigurationRepository configurationRepository, NamedParameterJdbcTemplate jdbc) {
    this.eventMigrationRepository = eventMigrationRepository;
    this.eventRepository = eventRepository;
    this.ticketCategoryRepository = ticketCategoryRepository;
    this.configurationRepository = configurationRepository;
    this.jdbc = jdbc;
    this.currentVersion = parseVersion(currentVersion);
    this.currentVersionAsString = currentVersion;
    this.buildTimestamp = ZonedDateTime.parse(buildTimestamp);
    this.transactionTemplate = new TransactionTemplate(transactionManager,
            new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW));
}

From source file:com.jaspersoft.jasperserver.api.metadata.user.service.impl.RoleManagerServiceImpl.java

public PaginatedOperationResult getUsersWithRole(final ExecutionContext context, final String roleName,
        final String userName, Set assignedUserNameSet, Set unassignedUserNameSet, int firstResult,
        int maxResults) {

    PaginatedOperationResult result;/*from   w w w.  j  a va2  s . c om*/

    TransactionStatus transaction = null;
    try {

        // start transaction
        transaction = transactionManager.getTransaction(
                new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW));

        userService.assignUsers(context, roleName, assignedUserNameSet);
        userService.unassignUsers(context, roleName, unassignedUserNameSet);

        getHibernateTemplate().flush();

        result = PaginationHelper.paginatedGetOperationResult(firstResult, maxResults,
                new PaginationHelper.JasperService() {
                    public List getResultList(int firstResult, int maxResults) {
                        return userService.getUsersWithRole(context, roleName, userName, firstResult,
                                maxResults);
                    }

                    public int getResultCount() {
                        return userService.getUsersCountWithRole(context, roleName, userName);
                    }
                });

    } finally {
        if (transaction != null && !transaction.isCompleted()) {
            try {
                // rollback
                transactionManager.rollback(transaction);
            } catch (Exception e) {
                // suppress exception
            }
        }
    }

    return result;
}

From source file:hoot.services.controllers.wps.MarkItemsReviewedProcesslet.java

@Override
public void process(ProcessletInputs inputParams, ProcessletOutputs outputParams,
        ProcessletExecutionInfo processletExecInfo) throws ProcessletException {
    final String errorMessageStart = "marking items as reviewed";
    Connection conn = DbUtils.createConnection();
    MarkItemsReviewedResponse markItemsReviewedResponse = null;
    try {/*from w w w .  j a v  a2 s. co  m*/
        //Any changes to these default parameters must also be reflected in 
        //$HOOT_HOME/hoot-services/src/main/webapp/WEB-INF/workspace/MarkItemsReviewedProcesslet.xml
        //and vice versa.
        ReviewInputParamsValidator inputParamsValidator = new ReviewInputParamsValidator(inputParams);
        final String mapId = (String) inputParamsValidator.validateAndParseInputParam("mapId", "", null, null,
                false, null);
        final boolean markAll = (Boolean) inputParamsValidator.validateAndParseInputParam("markAll", false,
                null, null, true, false);
        final String reviewedItemsStr = (String) inputParamsValidator
                .validateAndParseInputParam("reviewedItems", "", null, null, true, null);
        ReviewedItems reviewedItems = null;
        if (reviewedItemsStr != null) {
            reviewedItems = (new ObjectMapper()).readValue(reviewedItemsStr, ReviewedItems.class);
        }
        if (!markAll && (reviewedItems == null || reviewedItems.getReviewedItems() == null
                || reviewedItems.getReviewedItems().length == 0)) {
            throw new Exception("Invalid input parameter: markAll set to false and "
                    + "markItemsReviewedRequest.reviewedItems empty.");
        }
        final String reviewedItemsChangesetStr = (String) inputParamsValidator
                .validateAndParseInputParam("reviewedItemsChangeset", "", null, null, true, "");
        MarkItemsReviewedRequest markItemsReviewedRequest = new MarkItemsReviewedRequest();
        markItemsReviewedRequest.setReviewedItems(reviewedItems);
        markItemsReviewedRequest.setReviewedItemsChangeset(reviewedItemsChangesetStr);

        log.debug("Initializing transaction manager...");
        PlatformTransactionManager transactionManager = appContext.getBean("transactionManager",
                PlatformTransactionManager.class);

        log.debug("Initializing database connection...");

        //TODO: verify that no other writes are seen during this transaction

        log.debug("Intializing transaction...");
        TransactionStatus transactionStatus = transactionManager
                .getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));
        conn.setAutoCommit(false);

        try {
            markItemsReviewedResponse = (new ReviewItemsMarker(conn, mapId))
                    .markItemsReviewed(markItemsReviewedRequest, markAll);
        } catch (Exception e) {
            log.debug("Rolling back database transaction for MarkItemsReviewedProcesslet...");
            transactionManager.rollback(transactionStatus);
            conn.rollback();
            throw e;
        }

        log.debug("Committing MarkItemsReviewedProcesslet database transaction...");
        transactionManager.commit(transactionStatus);
        conn.commit();

        if (StringUtils.trimToNull(markItemsReviewedResponse.getChangesetUploadResponse()) != null) {
            log.debug("Returning changeset upload response: "
                    + StringUtils.abbreviate(markItemsReviewedResponse.getChangesetUploadResponse(), 100)
                    + " ...");
        } else {
            log.debug("Returning null changeset upload response...");
        }
        ((LiteralOutput) outputParams.getParameter("changesetUploadResponse"))
                .setValue(markItemsReviewedResponse.getChangesetUploadResponse());
        log.debug("Returning number of items marked as reviewed: "
                + markItemsReviewedResponse.getNumItemsMarkedReviewed() + " ...");
        ((LiteralOutput) outputParams.getParameter("numItemsMarkedReviewed"))
                .setValue(String.valueOf(markItemsReviewedResponse.getNumItemsMarkedReviewed()));
        log.debug("Returning changeset ID: " + markItemsReviewedResponse.getChangesetId() + " ...");
        ((LiteralOutput) outputParams.getParameter("changesetId"))
                .setValue(String.valueOf(markItemsReviewedResponse.getChangesetId()));
    } catch (Exception e) {
        try {
            ReviewUtils.handleError(e, errorMessageStart, true);
        } catch (Exception e2) {
            throw (ProcessletException) e2;
        }
    } finally {
        try {
            conn.setAutoCommit(true);
            DbUtils.closeConnection(conn);
        } catch (Exception e) {
            try {
                ReviewUtils.handleError(e, errorMessageStart, true);
            } catch (Exception e2) {
                throw (ProcessletException) e2;
            }
        }
    }
}

From source file:alfio.manager.AdminReservationRequestManager.java

private Result<Triple<TicketReservation, List<Ticket>, Event>> processReservation(
        AdminReservationRequest request, Pair<Event, User> p) {
    DefaultTransactionDefinition definition = new DefaultTransactionDefinition(
            TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    TransactionTemplate template = new TransactionTemplate(transactionManager, definition);
    return template.execute(status -> {
        try {/* w  w w  . j a  v a  2  s .  co m*/
            String eventName = p.getLeft().getShortName();
            String username = p.getRight().getUsername();
            Result<Triple<TicketReservation, List<Ticket>, Event>> result = adminReservationManager
                    .createReservation(request.getBody(), eventName, username)
                    .flatMap(r -> adminReservationManager.confirmReservation(eventName, r.getLeft().getId(),
                            username));
            if (!result.isSuccess()) {
                status.setRollbackOnly();
            }
            return result;
        } catch (Exception ex) {
            status.setRollbackOnly();
            return Result.error(singletonList(ErrorCode.custom("", ex.getMessage())));
        }
    });
}

From source file:edu.ur.file.db.service.DefaultFileServerServiceTest.java

/**
 * Test File Folder persistence/*from   ww w.j a  va 2  s .co m*/
 * 
 * - Make sure a file folder can be created.
 * - Makes sure a file folder can be found.
 * @throws LocationAlreadyExistsException 
 * 
 */
@Test
public void createFileFolderTest() throws LocationAlreadyExistsException {
    // Start the transaction this is for lazy loading
    TransactionDefinition td = new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus ts = tm.getTransaction(td);

    DefaultFileServer fs = dfss.createFileServer("service_file_server");

    DefaultFileDatabase fileDatabase = fs.createFileDatabase("nates file server", "file_server_1",
            properties.getProperty("defaultFileServerService.server_path"), "description");

    TreeFolderInfo treeFolderInfo = fileDatabase.createRootFolder("Nates Folder", "folder 1");

    dfss.saveFileServer(fs);

    //commit the transaction this will assing an id to the 
    //file database and folder information
    tm.commit(ts);

    //begin a new transaction
    td = new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED);
    ts = tm.getTransaction(td);

    assert dfss.getTreeFolderInfoById(treeFolderInfo.getId(), true)
            .equals(treeFolderInfo) : "The folder information should be the same";

    tm.commit(ts);

    dfss.deleteFileServer(fs.getName());
    assert dfss.getFileServer(fs.getName()) == null : "Should not find the file server";

}