@@ -43,6 +43,10 @@ public void setDSLContext(DSLContext dsl) {
4343 *
4444 * Create a ProjectRecord object from an existing project.
4545 *
46+ * Note: There are private getProject methods that retrieve
47+ * a project record based on a number of parameters
48+ * passed in.
49+ *
4650 * TODO: add details.
4751 *
4852 * @param idProject
@@ -58,6 +62,8 @@ public ProjectRecord getProject(Long idProject) {
5862 .fetchOne ();
5963
6064 // Return the project after checking if for depricated blocks
65+ //
66+ // Todo: Verify that the record was fetched - it sometimes is not.
6167 return alterReadRecord (record );
6268 }
6369
@@ -215,8 +221,10 @@ public ProjectRecord createProject(
215221 */
216222 @ Override
217223 public ProjectRecord updateProject (
218- Long idProject , String name , String description ,
219- String descriptionHtml , boolean privateProject ,
224+ Long idProject , String name ,
225+ String description ,
226+ String descriptionHtml ,
227+ boolean privateProject ,
220228 boolean sharedProject ) {
221229
222230 LOG .info ("Update project {}." , idProject );
@@ -259,8 +267,12 @@ public ProjectRecord updateProject(
259267 */
260268 @ Override
261269 public ProjectRecord updateProject (
262- Long idProject , String name , String description ,
263- String descriptionHtml , String code , boolean privateProject ,
270+ Long idProject ,
271+ String name ,
272+ String description ,
273+ String descriptionHtml ,
274+ String code ,
275+ boolean privateProject ,
264276 boolean sharedProject ) {
265277
266278 LOG .info ("Update project {}." , idProject );
@@ -301,10 +313,14 @@ public ProjectRecord saveCode(Long idProject, String code) {
301313 ProjectRecord record = getProject (idProject , true );
302314 if (record != null ) {
303315 record .setCode (code );
304- ProjectRecord returningRecord = create .update (Tables .PROJECT ).set (record ).returning ().fetchOne ();
316+ ProjectRecord returningRecord = create
317+ .update (Tables .PROJECT )
318+ .set (record )
319+ .returning ()
320+ .fetchOne ();
305321 return returningRecord ;
306322 }
307- LOG .warn ("Unable to save code for project {}" , idProject );
323+ LOG .error ("Unable to save code for project {}" , idProject );
308324 return null ;
309325 }
310326
@@ -550,7 +566,9 @@ public ProjectRecord saveProjectCodeAs(Long idProject, String code, String newNa
550566 return null ;
551567 }
552568
553-
569+ // Private over-ride of the public getProject()
570+ //
571+ //
554572 private ProjectRecord getProject (Long idProject , boolean toEdit ) {
555573 LOG .info ("Retreiving project {}." , idProject );
556574 ProjectRecord record = create
@@ -564,6 +582,8 @@ private ProjectRecord getProject(Long idProject, boolean toEdit) {
564582 // Return a project if the edit flag is off or the edit flag is
565583 // on and the project owner is the current user
566584 if (!toEdit || record .getIdUser ().equals (idUser )) {
585+
586+ // Todo: Verify that the record was fetched - it sometimes is not.
567587 return alterReadRecord (record );
568588 } else {
569589 LOG .error ("User {} attempted to edit project {} without authorization." ,
@@ -573,6 +593,8 @@ private ProjectRecord getProject(Long idProject, boolean toEdit) {
573593 }
574594
575595 // Return the project after checking if for depricated blocks
596+ //
597+ // Todo: Verify that the record was fetched - it sometimes is not.
576598 return alterReadRecord (record );
577599 }
578600
@@ -597,12 +619,17 @@ private ProjectRecord doProjectClone(ProjectRecord original) {
597619 }
598620
599621
600- // Swap out old block definitions
622+ // Evaluate project code and replace any depricated or updated blocks
623+ //
624+ // Return a ProjectRecord object. The code field may be altered to correct
625+ // any old, depricated or updated blocks. The method will throw an
626+ // exception if the ProjectRecord parameter is null or something has gone
627+ // horribly wrong with the string conversions.
628+ //
601629 private ProjectRecord alterReadRecord (ProjectRecord record ) {
602630 LOG .info ("Verify project block characteristics" );
603631 String currentCode , newCode ;
604632
605-
606633 if (record == null ) {
607634 LOG .error ("Null project record detected." );
608635 throw new NullPointerException ("Cannot alter a null project record." );
@@ -613,7 +640,7 @@ private ProjectRecord alterReadRecord(ProjectRecord record) {
613640
614641 // Return immediately if there is no code to adjust
615642 if (currentCode == null ) {
616- LOG .warn ("Project is empty." );
643+ LOG .warn ("Project () code block is empty." , record . getId () );
617644 return record ;
618645 }
619646
@@ -633,13 +660,13 @@ private ProjectRecord alterReadRecord(ProjectRecord record) {
633660
634661 // Check for any difference from the original code
635662 if (! currentCode .equals (newCode )) {
636- LOG .info ("Updating converted project." );
663+ LOG .info ("Updated depricated project code blocks in project {}." , record . getId () );
637664 record .setCode (newCode );
638665 }
639666 }
640667
641668 catch (Exception ex ) {
642- LOG .error ("Exception trapped. Messate is: {}" , ex .getMessage ());
669+ LOG .error ("Exception trapped. Message is: {}" , ex .getMessage ());
643670 }
644671
645672 return record ;
0 commit comments