Skip to content

Commit 1d1c508

Browse files
committed
Removed public_muo license
1 parent 9ec3de9 commit 1d1c508

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

shared/common/src/main/java/cz/incad/kramerius/security/database/SecurityDbInitializer.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ public static void initDatabase(Connection connection, VersionService versionSer
239239

240240
updateExistingActions(connection);
241241
checkLabelExists(connection);
242-
242+
243+
dropDeprecatedLabels(connection);
243244

244245
} catch (SQLException e) {
245246
LOGGER.log(Level.SEVERE, e.getMessage(), e);
@@ -249,6 +250,40 @@ public static void initDatabase(Connection connection, VersionService versionSer
249250
}
250251

251252

253+
private static void dropDeprecatedLabels(Connection connection) {
254+
CzechEmbeddedLicenses.DEPRECATED_LICENSES.forEach(lic->{
255+
256+
List<String> labels = new JDBCQueryTemplate<String>(connection, false) {
257+
@Override
258+
public boolean handleRow(ResultSet rs, List<String> returnsList) throws SQLException {
259+
returnsList.add(rs.getString("label_name"));
260+
return super.handleRow(rs, returnsList);
261+
}
262+
}.executeQuery("select * from labels_entity where label_name = ?", lic.getName());
263+
if (!labels.isEmpty()) {
264+
try {
265+
JDBCUpdateTemplate template = new JDBCUpdateTemplate(connection, false);
266+
template.setUseReturningKeys(false);
267+
268+
template.executeUpdate(
269+
"DELETE FROM labels_entity WHERE label_name = ?",
270+
lic.getName()
271+
);
272+
273+
// template.executeUpdate(
274+
// "insert into labels_entity(label_id,label_group,label_name, label_description, label_priority) \n" +
275+
// "values(nextval('LABEL_ID_SEQUENCE'), 'embedded', ?, ?, (select coalesce(max(label_priority),0)+1 from labels_entity))",
276+
// lic.getName(), lic.getDescription());
277+
278+
} catch (SQLException e) {
279+
LOGGER.log(Level.SEVERE, String.format("Cannot create embedded label %s", lic.getName()));
280+
}
281+
282+
}
283+
});
284+
}
285+
286+
252287

253288
private static void checkLabelExists(Connection connection) {
254289

shared/common/src/main/java/cz/incad/kramerius/security/licenses/impl/embedded/cz/CzechEmbeddedLicenses.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ public class CzechEmbeddedLicenses {
6161
ONSITE_LICENSE,
6262
ORPHAN_LICENSE,
6363
PUBLIC_LICENSE,
64-
PUBLIC_MUO_LICENSE,
64+
//PUBLIC_MUO_LICENSE,
6565
SHHETMUSIC_ONSITE_LICENSE
6666
);
6767

68+
public static List<License> DEPRECATED_LICENSES = Arrays.asList(PUBLIC_MUO_LICENSE);
69+
6870
}

0 commit comments

Comments
 (0)