package net.pterodactylus.demoscenemusic.page.admin;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map.Entry;
-
import net.pterodactylus.demoscenemusic.core.Core;
import net.pterodactylus.demoscenemusic.data.Artist;
import net.pterodactylus.demoscenemusic.page.ServletRequest;
String name = request.getServletRequest().getParameter("name");
artist.setName(name);
- /* check if properties were changed. */
- List<String> propertiesToDelete = new ArrayList<String>();
- for (Entry<String, String> property : artist.getProperties()) {
- if (request.getServletRequest().getParameter("delete." + property.getKey()) != null) {
- propertiesToDelete.add(property.getKey());
- continue;
- }
- String value = request.getServletRequest().getParameter("value." + property.getKey()).trim();
- artist.getProperties().set(property.getKey(), value);
- }
-
- /* check if properties are deleted. */
- if (!propertiesToDelete.isEmpty()) {
- for (String propertyToDelete : propertiesToDelete) {
- artist.getProperties().remove(propertyToDelete);
- }
- }
-
- /* check for a new property. */
- if ("true".equals(request.getServletRequest().getParameter("new-property"))) {
- String property = request.getServletRequest().getParameter("property").trim();
- String value = request.getServletRequest().getParameter("value").trim();
- if ((property.length() > 0) && (value.length() > 0)) {
- artist.getProperties().set(property, value);
- }
- }
+ /* process property changes. */
+ processProperties(request, artist);
getCore().getDataManager().saveArtist(artist);
throw new RedirectException("admin.edit-artist?id=" + artist.getId());