Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
@Singleton
public class ProjectDaoImpl implements ProjectDao {

private static final int Min_BlocklyCodeSize = 48;
private static final Logger LOG = LoggerFactory.getLogger(ProjectDao.class);
private DSLContext create;

Expand Down Expand Up @@ -63,9 +64,11 @@ public ProjectRecord getProject(Long idProject) {
.where(Tables.PROJECT.ID.equal(idProject))
.fetchOne();

if (record == null) {
LOG.warn("Unable to retreive project {}", idProject);
return null;
}
// Return the project after checking if for depricated blocks
//
// Todo: Verify that the record was fetched - it sometimes is not.
return alterReadRecord(record);
}

Expand Down Expand Up @@ -652,22 +655,26 @@ private ProjectRecord doProjectClone(ProjectRecord original) {
// horribly wrong with the string conversions.
//
private ProjectRecord alterReadRecord(ProjectRecord record) {
LOG.info("Verify project block characteristics");
String currentCode, newCode;

if (record == null) {
LOG.error("Null project record detected.");
throw new NullPointerException("Cannot alter a null project record.");
LOG.error("alterReadRecod detected a null project record.");
return null;
}

try {
LOG.info("Verify project {} block characteristics", record.getId());
currentCode = record.getCode();

// Return immediately if there is no code to adjust
if (currentCode == null) {
LOG.warn("Project () code block is empty.", record.getId());
return record;
}

if (currentCode.length() < Min_BlocklyCodeSize ) {
LOG.warn("Project code appears to be missing");
}

/*
* Make a copy of the project. We will use this after the updates
Expand Down