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
56aefac3
Commit
56aefac3
authored
13 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
FXOLAT-358: remove very old converter
parent
c9f8e903
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/olat/migration/Convert314To32.java
+0
-148
0 additions, 148 deletions
src/main/java/org/olat/migration/Convert314To32.java
src/main/java/org/olat/modules/cp/CPOfflineReadableManager.java
+0
-1
0 additions, 1 deletion
...in/java/org/olat/modules/cp/CPOfflineReadableManager.java
with
0 additions
and
149 deletions
src/main/java/org/olat/migration/Convert314To32.java
deleted
100644 → 0
+
0
−
148
View file @
c9f8e903
/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package
org.olat.migration
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
org.olat.core.util.FileUtils
;
import
org.olat.core.util.FileVisitor
;
import
org.olat.modules.cp.CPOfflineReadableManager
;
/**
* Initial Date: Dec 22, 2004
* @author Alexander Schneider
*/
public
class
Convert314To32
{
private
String
fromEnc
=
"iso-8859-1"
;
private
String
toEnc
=
"utf-8"
;
/**
* @param pathToCPOfflineMatDir
* @param pathToRepository
*/
public
void
addMenuToZip
(
String
pathToCPOfflineMatDir
,
String
pathToRepository
)
{
final
File
cpOfflineMatDir
=
new
File
(
pathToCPOfflineMatDir
);
File
pathToRepositoryDir
=
new
File
(
pathToRepository
);
FileUtils
.
visitRecursively
(
pathToRepositoryDir
,
new
FileVisitor
()
{
private
CPOfflineReadableManager
corm
=
CPOfflineReadableManager
.
getInstance
();
public
void
visit
(
File
file
)
{
if
(
file
.
getName
().
equals
(
"imsmanifest.xml"
))
{
File
unzippedDir
=
file
.
getParentFile
();
System
.
out
.
println
(
"> >> >>>\nimsmanifest.xml found in: \n"
+
unzippedDir
.
getPath
());
File
cpDir
=
unzippedDir
.
getParentFile
();
File
[]
files
=
cpDir
.
listFiles
();
int
foundZip
=
0
;
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
if
(
files
[
i
].
isFile
()
&&
files
[
i
].
getName
().
toLowerCase
().
endsWith
(
".zip"
))
{
File
targetZip
=
files
[
i
];
System
.
out
.
println
(
"zip-file found in: "
+
targetZip
.
getPath
());
foundZip
++;
if
(
foundZip
==
1
)
corm
.
makeCPOfflineReadable
(
unzippedDir
,
targetZip
,
cpOfflineMatDir
);
}
}
if
(
foundZip
!=
1
)
System
.
out
.
println
(
"ERROR: no or more than one zip-file found in: "
+
cpDir
.
getPath
());
}
}
});
}
/**
* @param args
*/
public
static
void
main
(
String
args
[])
{
if
(
args
.
length
==
3
)
{
String
pathToCPOfflineMatDir
=
args
[
0
];
String
pathToRepositoryHome
=
args
[
1
];
String
pathToCourseHome
=
args
[
2
];
System
.
out
.
println
(
"'"
+
pathToCPOfflineMatDir
+
"'\n'"
+
pathToRepositoryHome
+
"'\n'"
+
pathToCourseHome
+
"'\n\nis this ok (type 'yes')"
);
if
(
readOneLineFromConsole
().
equals
(
"yes"
))
{
Convert314To32
conv
=
new
Convert314To32
();
System
.
out
.
println
(
"Adding offline files to content packaging"
);
conv
.
addMenuToZip
(
pathToCPOfflineMatDir
,
pathToRepositoryHome
);
System
.
out
.
println
(
"\n\n\nAdding header to internal course xml files"
);
conv
.
convertRunAndEditorStructureToUtf8
(
pathToCourseHome
);
}
else
{
System
.
out
.
println
(
"cancelled"
);
}
}
else
{
System
.
out
.
println
(
"usage:\n1. param: pathToCPOfflineMatDir like maybe: C:/eclipsedata/olat3/webapp/static/cp_offline_menu_mat"
);
System
.
out
.
println
(
"2. param: pathToRepositoryHome, e.g. C:/olatdata3/bcroot/repository"
);
System
.
out
.
println
(
"3. param: pathToCourseHome, e.g. C:/olatdata3/bcroot/course"
);
}
}
/**
*
*/
private
void
convertRunAndEditorStructureToUtf8
(
String
pathToCourseHome
)
{
final
File
courseHome
=
new
File
(
pathToCourseHome
);
FileUtils
.
visitRecursively
(
courseHome
,
new
FileVisitor
()
{
public
void
visit
(
File
file
)
{
//System.out.println("visiting file " + file.getAbsolutePath());
String
fName
=
file
.
getName
();
// all files named editortreemodel.xml and runstructure.xml in a
// subfolder of the course home
if
((
fName
.
equals
(
"editortreemodel.xml"
)
||
fName
.
equals
(
"runstructure.xml"
))
&&
file
.
getParentFile
().
getParentFile
().
equals
(
courseHome
))
{
System
.
out
.
println
(
"converting "
+
file
.
getAbsolutePath
());
String
inh
=
FileUtils
.
load
(
file
,
fromEnc
);
if
(
inh
.
startsWith
(
"<?xml"
))
{
// encoding given, convert to utf-8
// xml file -> adjust the encoding
// e.g. <?xml version="1.0" encoding="utf-8"?>
int
pos
=
inh
.
indexOf
(
'>'
);
if
(
pos
==
-
1
)
throw
new
RuntimeException
(
"error: wrong xml header"
);
String
rest
=
inh
.
substring
(
pos
+
1
);
inh
=
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+
rest
;
}
else
{
// no encoding yet, prepend xml header
inh
=
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+
inh
;
}
// write inh back
FileUtils
.
save
(
file
,
inh
,
toEnc
);
}
}
});
// TODO Auto-generated method stub
}
private
static
String
readOneLineFromConsole
()
{
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
));
String
line
=
null
;
try
{
line
=
br
.
readLine
();
}
catch
(
IOException
ioe
)
{
ioe
.
printStackTrace
();
throw
new
RuntimeException
(
""
);
}
return
line
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/org/olat/modules/cp/CPOfflineReadableManager.java
+
0
−
1
View file @
56aefac3
...
...
@@ -85,7 +85,6 @@ public class CPOfflineReadableManager {
/**
* Used for migration purposes
*
* @see org.olat.migration.Convert314To32#main(String[])
* @param unzippedDir
* @param targetZip
* @param cpOfflineMat
...
...
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