Skip to content

Commit 8b7fdc8

Browse files
authored
SAK-48241 - Remove unneeded legacy XML columns in ContentHosting (cruft) (sakaiproject#11142)
1 parent 3cfa955 commit 8b7fdc8

File tree

8 files changed

+132
-228
lines changed

8 files changed

+132
-228
lines changed

kernel/kernel-impl/src/main/java/org/sakaiproject/content/impl/DbContentService.java

+42-222
Large diffs are not rendered by default.

kernel/kernel-impl/src/main/sql/hsqldb/sakai_content.sql

-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ CREATE TABLE CONTENT_RESOURCE
127127
FILE_PATH VARCHAR (128),
128128
FILE_SIZE BIGINT,
129129
RESOURCE_TYPE_ID VARCHAR (255),
130-
XML LONGVARCHAR,
131130
BINARY_ENTITY LONGVARBINARY,
132131
CONSTRAINT CONTENT_RESOURCE_INDEX UNIQUE (RESOURCE_ID)
133132
-- for BINARY body, add BODY BINARY -- and drop the content_resource_body_binary tables -ggolden

kernel/kernel-impl/src/main/sql/hsqldb/sakai_content_delete.sql

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ CREATE TABLE CONTENT_RESOURCE_DELETE
1313
RESOURCE_TYPE_ID VARCHAR (255),
1414
DELETE_DATE DATE,
1515
DELETE_USERID VARCHAR (36),
16-
XML LONGVARCHAR,
1716
BINARY_ENTITY LONGVARBINARY,
1817
CONSTRAINT CONTENT_RESOURCE_UUID_DELETE_I UNIQUE (RESOURCE_UUID)
1918
);

kernel/kernel-impl/src/main/sql/mysql/sakai_content.sql

-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ CREATE TABLE CONTENT_RESOURCE
131131
FILE_PATH VARCHAR (128),
132132
FILE_SIZE BIGINT,
133133
RESOURCE_TYPE_ID VARCHAR (255),
134-
XML LONGTEXT,
135134
BINARY_ENTITY BLOB
136135

137136
-- for BLOB body, add BODY BLOB -- and drop the content_resource_body_binary tables -ggolden

kernel/kernel-impl/src/main/sql/mysql/sakai_content_delete.sql

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ CREATE TABLE CONTENT_RESOURCE_DELETE
1313
RESOURCE_TYPE_ID VARCHAR (255),
1414
DELETE_DATE DATETIME,
1515
DELETE_USERID VARCHAR (36),
16-
XML LONGTEXT,
1716
BINARY_ENTITY BLOB
1817
);
1918

kernel/kernel-impl/src/main/sql/oracle/sakai_content.sql

-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ CREATE TABLE CONTENT_RESOURCE
132132
FILE_PATH VARCHAR2 (128),
133133
FILE_SIZE NUMBER(18),
134134
RESOURCE_TYPE_ID VARCHAR2 (255),
135-
XML CLOB,
136135
BINARY_ENTITY BLOB
137136
-- for BLOB body, add BODY BLOB -- and drop the content_resource_body_binary tables -ggolden
138137
);

kernel/kernel-impl/src/main/sql/oracle/sakai_content_delete.sql

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ CREATE TABLE CONTENT_RESOURCE_DELETE
1313
RESOURCE_TYPE_ID VARCHAR2 (255),
1414
DELETE_DATE DATE,
1515
DELETE_USERID VARCHAR2 (36),
16-
XML LONG,
1716
BINARY_ENTITY BLOB
1817
);
1918

kernel/kernel-impl/src/test/java/org/sakaiproject/content/impl/test/ContentHostingServiceTest.java

+90
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
import java.net.URLDecoder;
2323
import java.util.Arrays;
2424
import java.util.List;
25+
import java.util.Iterator;
26+
import java.sql.Connection;
27+
import java.sql.Statement;
28+
import java.sql.SQLException;
2529

2630
import lombok.extern.slf4j.Slf4j;
2731

@@ -47,6 +51,7 @@
4751
import org.sakaiproject.tool.api.Session;
4852
import org.sakaiproject.tool.api.SessionManager;
4953
import org.sakaiproject.util.BasicConfigItem;
54+
import org.sakaiproject.db.api.SqlService;
5055

5156
@FixMethodOrder(NAME_ASCENDING)
5257
@Slf4j
@@ -264,4 +269,89 @@ public void testMimeDetection() throws Exception {
264269
stream.close();
265270
}
266271
}
272+
273+
@Test
274+
public void testSqlSanity() {
275+
ContentHostingService ch = getService(ContentHostingService.class);
276+
SqlService m_sqlService = getService(SqlService.class);
277+
278+
// Make sure that the structure of the CONTENT_ tables passes the "modern schema" test
279+
try {
280+
Connection connection = m_sqlService.borrowConnection();
281+
Statement statement = connection.createStatement();
282+
283+
try {
284+
statement.execute("select BINARY_ENTITY from CONTENT_COLLECTION where COLLECTION_ID = 'does-not-exist' " );
285+
} catch ( Exception ex ) {
286+
Assert.fail();
287+
}
288+
try {
289+
statement.execute("select XML from CONTENT_COLLECTION where COLLECTION_ID = 'does-not-exist' ");
290+
} catch ( Exception ex ) {
291+
Assert.fail();
292+
}
293+
294+
try {
295+
statement.execute("select BINARY_ENTITY from CONTENT_RESOURCE where RESOURCE_ID = 'does-not-exist' " );
296+
} catch ( Exception ex ) {
297+
Assert.fail();
298+
}
299+
try {
300+
statement.execute("select XML from CONTENT_RESOURCE where RESOURCE_ID = 'does-not-exist' ");
301+
Assert.fail();
302+
} catch ( Exception ex ) {
303+
// Pass
304+
}
305+
try {
306+
statement.execute("select BINARY_ENTITY from CONTENT_RESOURCE_DELETE where RESOURCE_ID = 'does-not-exist' " );
307+
} catch ( Exception ex ) {
308+
Assert.fail();
309+
}
310+
try {
311+
statement.execute("select XML from CONTENT_RESOURCE_DELETE where RESOURCE_ID = 'does-not-exist' ");
312+
Assert.fail();
313+
} catch ( Exception ex ) {
314+
// pass
315+
}
316+
317+
// Yes, these are a bit less than exciting, post autoDDL - but what they heck -
318+
// they should not fail and be correct
319+
checkCount("select count(*) from CONTENT_COLLECTION where BINARY_ENTITY IS NULL ", 0);
320+
checkCount("select count(*) from CONTENT_RESOURCE where BINARY_ENTITY IS NULL ", 0);
321+
checkCount("select count(*) from CONTENT_RESOURCE_DELETE where BINARY_ENTITY IS NULL ", 0);
322+
323+
checkCount("select count(*) from CONTENT_COLLECTION where XML IS NOT NULL ", 0);
324+
325+
} catch ( Exception ex ) {
326+
Assert.fail();
327+
}
328+
}
329+
330+
protected void checkCount(String sql, int expected) throws Exception
331+
{
332+
333+
SqlService m_sqlService = getService(SqlService.class);
334+
List list = m_sqlService.dbRead(sql, null, null);
335+
if (list == null) Assert.fail("Nothing returned for: "+sql);
336+
337+
Iterator iter = list.iterator();
338+
if (iter.hasNext())
339+
{
340+
Object val = null;
341+
try
342+
{
343+
val = iter.next();
344+
Integer found = Integer.parseInt((String) val);
345+
if ( found == expected ) return;
346+
Assert.fail("Mismatch expecting: " + expected + " found: " + found + " sql: "+sql);
347+
}
348+
catch (Exception ignore)
349+
{
350+
Assert.fail("Bad integer: " + val + " from: "+sql);
351+
}
352+
}
353+
Assert.fail("Empty list for: "+sql);
354+
return;
355+
}
356+
267357
}

0 commit comments

Comments
 (0)