Foros de discusión

Pulling messageboard information api?

thumbnail
Cameron McBride, modificado hace 12 años.

Pulling messageboard information api?

Expert Mensajes: 269 Fecha de incorporación: 8/02/11 Mensajes recientes
I am wanting to pull some messageboard information. I have the following code that works "pretty" well.

int threadsCount = MBThreadLocalServiceUtil.getGroupThreadsCount(groupId, userId, 0);
System.out.println("Threads count: "+threadsCount);
			
List<mbthread> threadsList = MBThreadLocalServiceUtil.getGroupThreads(groupId, userId, 0, 0, threadsCount-1);
for (MBThread t : threadsList) {
	int c = t.getMessageCount();
	int s = t.getStatus();
	int v = t.getViewCount();
	System.out.println("Thread info: "+c+" - status: "+s+" - views: "+v);
	
	long id = t.getThreadId();
	MBThread m = MBThreadLocalServiceUtil.getThread(id);
	long messageId = m.getRootMessageId();				
	MBMessage message = MBMessageServiceUtil.getMessage(messageId);
	String subject = message.getSubject();
	System.out.println("Subject: "+subject);
}
</mbthread>


The problem is there is a lot of rogue information that gets printed out, see my output:
Threads count: 8
Thread info: 1 - status: 0 - views: 0
Subject: 17610
Thread info: 1 - status: 0 - views: 0
Subject: 17603
[b]Thread info: 2 - status: 0 - views: 2
Subject: Test Thread[/b]
Thread info: 1 - status: 0 - views: 0
Subject: 14717
Thread info: 1 - status: 0 - views: 0
Subject: 14706
Thread info: 1 - status: 0 - views: 0
Subject: 13606
Thread info: 1 - status: 0 - views: 0
Subject: 13507


The bolded piece is the only actual post on my test forum.

My questions are:

1. What is "status"? I assume there is a class that defines the constants for it somewhere.

2. How better can I grab a list of threads for a message board, that doesn't include the bogus entires? I dont want to have to get every message subject and make sure it is not a number.
thumbnail
Mika Koivisto, modificado hace 12 años.

RE: Pulling messageboard information api?

Liferay Legend Mensajes: 1519 Fecha de incorporación: 7/08/06 Mensajes recientes
Cameron McBride:
1. What is "status"? I assume there is a class that defines the constants for it somewhere.


status is used by workflow. You can find the different statuses in WorkflowConstants

Cameron McBride:
2. How better can I grab a list of threads for a message board, that doesn't include the bogus entires? I dont want to have to get every message subject and make sure it is not a number.


The bogus entries are comments of discussion threads. Something like this should return you all approved forum threads:

List<mbthread> threadsList = MBThreadLocalServiceUtil.getGroupThreads(groupId, 0, WorkflowConstants.STATUS_APPROVED, false, true, -1, -1)</mbthread>