Fixed more bugs.

This commit is contained in:
CalDescent 2023-05-07 12:27:51 +01:00
parent 94f4c501fa
commit c0f29f848f
3 changed files with 19 additions and 7 deletions

View File

@ -101,6 +101,10 @@ public class ArbitraryResourceMetadata {
return this.category;
}
public boolean hasMetadata() {
return title != null || description != null || tags != null || category != null || files != null || mimeType != null;
}
public void setArbitraryResourceData(ArbitraryResourceData arbitraryResourceData) {
this.arbitraryResourceData = arbitraryResourceData;
}

View File

@ -115,15 +115,15 @@ public abstract class RepositoryManager {
}
repository.saveChanges();
LOGGER.info("Completed build of initial arbitrary resources cache.");
LOGGER.info("Completed build of arbitrary resources cache.");
return true;
}
catch (DataException e) {
LOGGER.info("Unable to build initial arbitrary resources cache: {}. The database may have been left in an inconsistent state.", e.getMessage());
LOGGER.info("Unable to build arbitrary resources cache: {}. The database may have been left in an inconsistent state.", e.getMessage());
// Throw an exception so that the node startup is halted, allowing for a retry next time.
repository.discardChanges();
throw new DataException("Build of initial arbitrary resources cache failed.");
throw new DataException("Build of arbitrary resources cache failed.");
}
}

View File

@ -391,7 +391,9 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
if (tag5 != null) tags.add(tag5);
metadata.setTags(!tags.isEmpty() ? tags : null);
arbitraryResourceData.metadata = metadata;
if (metadata.hasMetadata()) {
arbitraryResourceData.metadata = metadata;
}
return arbitraryResourceData;
} catch (SQLException e) {
@ -465,7 +467,9 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
if (tag5 != null) tags.add(tag5);
metadata.setTags(!tags.isEmpty() ? tags : null);
arbitraryResourceData.metadata = metadata;
if (metadata.hasMetadata()) {
arbitraryResourceData.metadata = metadata;
}
arbitraryResources.add(arbitraryResourceData);
} while (resultSet.next());
@ -608,7 +612,9 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
if (tag5 != null) tags.add(tag5);
metadata.setTags(!tags.isEmpty() ? tags : null);
arbitraryResourceData.metadata = metadata;
if (metadata.hasMetadata()) {
arbitraryResourceData.metadata = metadata;
}
}
arbitraryResources.add(arbitraryResourceData);
@ -782,7 +788,9 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
if (tag5 != null) tags.add(tag5);
metadata.setTags(!tags.isEmpty() ? tags : null);
arbitraryResourceData.metadata = metadata;
if (metadata.hasMetadata()) {
arbitraryResourceData.metadata = metadata;
}
}
arbitraryResources.add(arbitraryResourceData);