13
13
import com .parallax .server .blocklyprop .db .generated .tables .records .ProjectRecord ;
14
14
import com .parallax .server .blocklyprop .security .BlocklyPropSecurityUtils ;
15
15
16
+ //import com.parallax.server.blocklyprop.services.impl.ProjectSharingServiceImpl;
17
+ import com .parallax .server .blocklyprop .services .ProjectSharingService ;
18
+
16
19
import com .google .inject .Inject ;
17
20
import com .google .inject .Singleton ;
18
21
import java .util .GregorianCalendar ;
19
22
import java .util .List ;
23
+
20
24
import org .apache .shiro .authz .UnauthorizedException ;
21
25
import org .jooq .Condition ;
22
26
import org .jooq .DSLContext ;
@@ -72,7 +76,15 @@ public void setDSLContext(DSLContext dsl) {
72
76
this .create = dsl ;
73
77
}
74
78
75
-
79
+
80
+ private ProjectSharingService projectSharingService ;
81
+
82
+ @ Inject
83
+ public void setProjectSharingContext (ProjectSharingService projectSharingService ) {
84
+ this .projectSharingService = projectSharingService ;
85
+ }
86
+
87
+
76
88
/**
77
89
*
78
90
* Retrieve a new project record based from an existing project.
@@ -674,7 +686,12 @@ public ProjectRecord saveProjectCodeAs(Long idProject, String code, String newNa
674
686
// by the current user OR if the source project is designated as a
675
687
// shared or community project
676
688
// --------------------------------------------------------------------
677
- if (original .getIdUser ().equals (idUser ) || original .getShared ()) {
689
+ boolean sharedStatus = projectSharingService .isProjectShared (idProject );
690
+ LOG .info ("Project shared status: {}" , sharedStatus );
691
+
692
+ if (original .getIdUser ().equals (idUser ) || // Project is owned by currently logged in user
693
+ sharedStatus || // Project is shared
694
+ (!original .getPrivate ())) { // Project is public
678
695
679
696
ProjectRecord cloned = createProject (
680
697
newName ,
@@ -688,7 +705,7 @@ public ProjectRecord saveProjectCodeAs(Long idProject, String code, String newNa
688
705
original .getId ());
689
706
690
707
if (cloned == null ) {
691
- LOG .warn ("Unable to create a copy og the project." );
708
+ LOG .warn ("Unable to create a copy of the project." );
692
709
}
693
710
return cloned ;
694
711
} else {
0 commit comments