Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: MetaData Extension #48

Open
datenwort opened this issue Feb 15, 2018 · 1 comment
Open

Question: MetaData Extension #48

datenwort opened this issue Feb 15, 2018 · 1 comment
Labels

Comments

@datenwort
Copy link

Hi,

is there a tutorial for using the CPLNoteMetaDataProvider?

package com.communote.plugins.meta;

import com.communote.server.api.core.note.NoteData;
import com.communote.server.web.fe.widgets.extension.note.CPLNoteMetaDataProvider;
import com.communote.common.util.Orderable;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class NotesMetaProvider extends CPLNoteMetaDataProvider implements Orderable {

    private static Logger LOGGER = LoggerFactory.getLogger(NotesMetaProvider.class);

	@Override
	public int getOrder() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void addMetaData(Map<String, String> requestParameters, NoteData data, Map<String, Object> metaData) {
		LOGGER.info("Note content:" + data.getContent());
	}
}

Is there something to add?

@rwi
Copy link
Member

rwi commented Feb 16, 2018

No there isn't a tutorial yet.

The metadata stored in the metaData map can be used to transport data about a note to the frontend. The map is prepared in com.communote.server.web.fe.widgets.blog.ChronologicalPostListWidget and already populated with information like whether the current user likes the note or the number of user liking it. The extension point CPLNoteMetaDataProvider allows adding further data in a plugin.
The JavaScript part of the ChronologicalPostListWidget has the method getNoteMetaData(noteId) to access the metadata of a note rendered by the widget. This is for example used by the NoteActionHandler.js which provides the logic of the reply, edit, delete, .... links below the note.

To get your NotesMetaProvider automagically loaded and called you will have to add the following iPOJO annotations to your class

  • org.apache.felix.ipojo.annotations.Component
  • org.apache.felix.ipojo.annotations.Instantiate
  • org.apache.felix.ipojo.annotations.Provides

Moreover, you have to explicitly implement the interface com.communote.server.web.fe.widgets.extension.WidgetExtension. The maven bundle-plugin needs this to correctly resolve the OSGi imports and exports when building your Communote plugin and creating the MANIFEST.MF file (feels like a bug). Alternatively you could add the imports and exports manually via Import-Package and Export-Package instructions in the configuration part of the maven-bundle-plugin in your pom.xml.

@rwi rwi added the question label Feb 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants