Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
bd04b4a3
Commit
bd04b4a3
authored
10 years ago
by
Florian Gnaegi - frentix GmbH
Browse files
Options
Downloads
Patches
Plain Diff
OO-1065 properly update cp derlivery options to use defaults from repo
parent
0b17130f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/olat/course/nodes/CPCourseNode.java
+52
-27
52 additions, 27 deletions
src/main/java/org/olat/course/nodes/CPCourseNode.java
src/main/java/org/olat/course/nodes/cp/CPRunController.java
+7
-21
7 additions, 21 deletions
src/main/java/org/olat/course/nodes/cp/CPRunController.java
with
59 additions
and
48 deletions
src/main/java/org/olat/course/nodes/CPCourseNode.java
+
52
−
27
View file @
bd04b4a3
...
...
@@ -37,6 +37,8 @@ import org.olat.core.gui.control.generic.iframe.DeliveryOptions;
import
org.olat.core.gui.control.generic.tabbable.TabbableController
;
import
org.olat.core.id.Identity
;
import
org.olat.core.id.OLATResourceable
;
import
org.olat.core.logging.OLog
;
import
org.olat.core.logging.Tracing
;
import
org.olat.core.util.Util
;
import
org.olat.core.util.resource.OresHelper
;
import
org.olat.course.ICourse
;
...
...
@@ -179,14 +181,19 @@ public class CPCourseNode extends AbstractAccessableCourseNode {
* previous behaviour
*/
public
void
updateModuleConfigDefaults
(
boolean
isNewNode
)
{
int
CURRENTVERSION
=
7
;
ModuleConfiguration
config
=
getModuleConfiguration
();
if
(
isNewNode
)
{
// use defaults for new course building blocks
config
.
setBooleanEntry
(
NodeEditController
.
CONFIG_STARTPAGE
,
Boolean
.
FALSE
.
booleanValue
());
config
.
setBooleanEntry
(
NodeEditController
.
CONFIG_COMPONENT_MENU
,
Boolean
.
TRUE
.
booleanValue
());
//
fxdiff VCRP-13:
cp navigation
// cp navigation
config
.
setBooleanEntry
(
CPEditController
.
CONFIG_SHOWNAVBUTTONS
,
Boolean
.
TRUE
.
booleanValue
());
config
.
setConfigurationVersion
(
2
);
// how to render files (include jquery etc)
DeliveryOptions
nodeDeliveryOptions
=
DeliveryOptions
.
defaultWithGlossary
();
nodeDeliveryOptions
.
setInherit
(
Boolean
.
TRUE
);
config
.
set
(
CPEditController
.
CONFIG_DELIVERYOPTIONS
,
nodeDeliveryOptions
);
config
.
setConfigurationVersion
(
CURRENTVERSION
);
}
else
{
config
.
remove
(
NodeEditController
.
CONFIG_INTEGRATION
);
if
(
config
.
getConfigurationVersion
()
<
2
)
{
...
...
@@ -210,47 +217,65 @@ public class CPCourseNode extends AbstractAccessableCourseNode {
config
.
setBooleanEntry
(
CPEditController
.
CONFIG_SHOWNAVBUTTONS
,
Boolean
.
TRUE
.
booleanValue
());
config
.
setConfigurationVersion
(
4
);
}
if
(
config
.
getConfigurationVersion
()
<
5
)
{
// Version 5 was ineffective since the delivery options were not set. We have to redo this and
// save it as version 6
if
(
config
.
getConfigurationVersion
()
<
7
)
{
String
contentEncoding
=
(
String
)
config
.
get
(
NodeEditController
.
CONFIG_CONTENT_ENCODING
);
if
(
contentEncoding
!=
null
&&
contentEncoding
.
equals
(
"auto"
))
{
contentEncoding
=
null
;
// new style for auto
}
String
jsEncoding
=
(
String
)
config
.
get
(
NodeEditController
.
CONFIG_JS_ENCODING
);
if
(
jsEncoding
!=
null
&&
jsEncoding
.
equals
(
"auto"
))
{
jsEncoding
=
null
;
// new style for auto
}
CPPackageConfig
reConfig
=
null
;
DeliveryOptions
nodeDeliveryOptions
=
new
DeliveryOptions
();
RepositoryEntry
re
=
getReferencedRepositoryEntry
();
if
(
re
!=
null
)
{
reConfig
=
CPManager
.
getInstance
().
getCPPackageConfig
(
re
.
getOlatResource
());
//move the settings from the node to the repo
if
(
reConfig
==
null
||
reConfig
.
getDeliveryOptions
()
==
null
)
{
DeliveryOptions
nodeDeliveryOptions
=
(
DeliveryOptions
)
config
.
get
(
CPEditController
.
CONFIG_DELIVERYOPTIONS
);
if
(
nodeDeliveryOptions
==
null
)
{
// Update missing delivery options now, inherit from repo by default
nodeDeliveryOptions
=
DeliveryOptions
.
defaultWithGlossary
();
nodeDeliveryOptions
.
setInherit
(
Boolean
.
TRUE
);
RepositoryEntry
re
=
getReferencedRepositoryEntry
();
// Check if delivery options are set for repo entry, if not create default
if
(
re
!=
null
)
{
reConfig
=
CPManager
.
getInstance
().
getCPPackageConfig
(
re
.
getOlatResource
());
if
(
reConfig
==
null
)
{
reConfig
=
new
CPPackageConfig
();
}
reConfig
.
setDeliveryOptions
(
new
DeliveryOptions
());
nodeDeliveryOptions
.
setInherit
(
Boolean
.
TRUE
);
nodeDeliveryOptions
.
setStandardMode
(
Boolean
.
TRUE
);
reConfig
.
getDeliveryOptions
().
setStandardMode
(
Boolean
.
TRUE
);
reConfig
.
getDeliveryOptions
().
setContentEncoding
(
contentEncoding
);
reConfig
.
getDeliveryOptions
().
setJavascriptEncoding
(
jsEncoding
);
CPManager
.
getInstance
().
setCPPackageConfig
(
re
.
getOlatResource
(),
reConfig
);
}
else
{
DeliveryOptions
repoDeliveryOptions
=
reConfig
.
getDeliveryOptions
();
if
(((
contentEncoding
==
null
&&
repoDeliveryOptions
.
getContentEncoding
()
==
null
)
||
(
contentEncoding
!=
null
&&
contentEncoding
.
equals
(
repoDeliveryOptions
.
getContentEncoding
())))
&&
((
jsEncoding
==
null
&&
repoDeliveryOptions
.
getJavascriptEncoding
()
==
null
)
||
(
jsEncoding
!=
null
&&
jsEncoding
.
equals
(
repoDeliveryOptions
.
getJavascriptEncoding
()))))
{
nodeDeliveryOptions
.
setInherit
(
Boolean
.
TRUE
);
if
(
repoDeliveryOptions
==
null
)
{
// migrate existing config back to repo entry using the default as a base
repoDeliveryOptions
=
DeliveryOptions
.
defaultWithGlossary
();
reConfig
.
setDeliveryOptions
(
repoDeliveryOptions
);
repoDeliveryOptions
.
setContentEncoding
(
contentEncoding
);
repoDeliveryOptions
.
setJavascriptEncoding
(
jsEncoding
);
CPManager
.
getInstance
().
setCPPackageConfig
(
re
.
getOlatResource
(),
reConfig
);
}
else
{
nodeDeliveryOptions
.
setInherit
(
Boolean
.
FALSE
);
nodeDeliveryOptions
.
setContentEncoding
(
contentEncoding
);
nodeDeliveryOptions
.
setJavascriptEncoding
(
jsEncoding
);
// see if we have any different settings than the repo. if so, don't use inherit mode
if
(
contentEncoding
!=
repoDeliveryOptions
.
getContentEncoding
()
||
jsEncoding
!=
repoDeliveryOptions
.
getJavascriptEncoding
())
{
nodeDeliveryOptions
.
setInherit
(
Boolean
.
FALSE
);
nodeDeliveryOptions
.
setContentEncoding
(
contentEncoding
);
nodeDeliveryOptions
.
setJavascriptEncoding
(
jsEncoding
);
}
}
}
// remove old config parameters
config
.
remove
(
NodeEditController
.
CONFIG_CONTENT_ENCODING
);
config
.
remove
(
NodeEditController
.
CONFIG_JS_ENCODING
);
// replace with new delivery options
config
.
set
(
CPEditController
.
CONFIG_DELIVERYOPTIONS
,
nodeDeliveryOptions
);
}
config
.
setConfigurationVersion
(
5
);
config
.
setConfigurationVersion
(
7
);
}
// else node is up-to-date - nothing to do
}
if
(
config
.
getConfigurationVersion
()
!=
CURRENTVERSION
)
{
OLog
logger
=
Tracing
.
createLoggerFor
(
CPCourseNode
.
class
);
logger
.
error
(
"CP course node version not updated to lastest version::"
+
CURRENTVERSION
+
", was::"
+
config
.
getConfigurationVersion
()
+
". Check the code, programming error."
);
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/olat/course/nodes/cp/CPRunController.java
+
7
−
21
View file @
bd04b4a3
...
...
@@ -162,7 +162,7 @@ public class CPRunController extends BasicController implements ControllerEventL
}
@Override
//
fxdiff BAKS-7
Resume function
// Resume function
public
void
activate
(
UserRequest
ureq
,
List
<
ContextEntry
>
entries
,
StateEntry
state
)
{
if
(
entries
==
null
||
entries
.
isEmpty
())
return
;
...
...
@@ -205,8 +205,8 @@ public class CPRunController extends BasicController implements ControllerEventL
//fxdiff VCRP-13: cp navigation
boolean
navButtons
=
isNavButtonConfigured
();
cpDispC
=
CPUIFactory
.
getInstance
().
createContentOnlyCPDisplayController
(
ureq
,
getWindowControl
(),
new
LocalFolderImpl
(
cpRoot
),
activateFirstPage
,
navButtons
,
deliveryOptions
,
nodecmd
,
courseResource
);
cpDispC
.
setContentEncoding
(
getContentEncoding
());
cpDispC
.
setJSEncoding
(
getJS
Encoding
());
cpDispC
.
setContentEncoding
(
deliveryOptions
.
getContentEncoding
());
cpDispC
.
setJSEncoding
(
deliveryOptions
.
getJavascript
Encoding
());
cpDispC
.
addControllerListener
(
this
);
main
.
setContent
(
cpDispC
.
getInitialComponent
());
...
...
@@ -232,29 +232,15 @@ public class CPRunController extends BasicController implements ControllerEventL
private
boolean
isExternalMenuConfigured
()
{
return
(
config
.
getBooleanEntry
(
NodeEditController
.
CONFIG_COMPONENT_MENU
).
booleanValue
());
}
//fxdiff VCRP-13: cp navigation
/**
* @return true: show next-previous buttons; false: hide next-previous buttons
*/
private
boolean
isNavButtonConfigured
()
{
Boolean
navButton
=
config
.
getBooleanEntry
(
CPEditController
.
CONFIG_SHOWNAVBUTTONS
);
return
navButton
==
null
?
true
:
navButton
.
booleanValue
();
}
private
String
getContentEncoding
()
{
String
encoding
=
(
String
)
config
.
get
(
NodeEditController
.
CONFIG_CONTENT_ENCODING
);
if
(!
encoding
.
equals
(
NodeEditController
.
CONFIG_CONTENT_ENCODING_AUTO
))
{
return
encoding
;
}
return
null
;
}
private
String
getJSEncoding
()
{
String
encoding
=
(
String
)
config
.
get
(
NodeEditController
.
CONFIG_JS_ENCODING
);
if
(!
encoding
.
equals
(
NodeEditController
.
CONFIG_JS_ENCODING_AUTO
))
{
return
encoding
;
}
return
null
;
}
/**
* @see org.olat.core.gui.control.DefaultController#doDispose(boolean)
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment