Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Removal of PluginSettings values on repo delete

Josh Wheeler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 30, 2014

Hi Atlassian,

On the post PluginSettings how to manage? it states, "If the repository is deleted all the settings are removed."  When I'm using PluginSettings to store data, and the repository is deleted and recreated with the same name under the same project, the data that was stored by the plugin before is retrieved.  Below is how we're storing/retrieving the data - is there a different way to do it so the repo delete functions correctly? 

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String pathInfo = req.getPathInfo();
    String[] components = pathInfo.split("/");
	String projectName, storedName, PROJECT_KEY;
 
	/* Check for valid repository */
    if (components.length < 4) {
        resp.sendError(HttpServletResponse.SC_NOT_FOUND);
        return;
    }
    Repository repository = repositoryService.getBySlug(components[1], components[2]);
    if (repository == null) {
        resp.sendError(HttpServletResponse.SC_NOT_FOUND);
      	return;
    }
 
	projectName = req.getParameter("d-fname"); //field in HTML
 
	PROJECT_KEY = repository.getProject().getKey();
    PluginSettings pluginSettings = pluginSettingsFactory.createSettingsForKey(PROJECT_KEY);
    storedName = (String) (pluginSettings.get(repository.getSlug() + "." + PLUGIN_SETTINGS_PROJECT_NAME));

	/* Do more data retrieval/manipulation */
 
	pluginSettings.put(repository.getSlug() + "." + PLUGIN_SETTINGS_PROJECT_NAME, projectName);
 
	doGet(req, resp);
}

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Mike Friedrich
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 30, 2014

I believe you need to write an event listener service which deletes your settings on the repo delete event.

Mike Friedrich
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 30, 2014
Josh Wheeler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 30, 2014

Because writing plugins is a new topic for me, this would mean creating a new plugin and not adding to my existing one - correct?

Mike Friedrich
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 30, 2014

Add it to your existing plugin.

TAGS
AUG Leaders

Atlassian Community Events