mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
remove label api
This commit is contained in:
parent
c8e0b92ef5
commit
b79930394d
@ -21,4 +21,6 @@ public interface LabelManager {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
Label getLabelByTitle(@NotNull final String title, @NotNull final User user);
|
Label getLabelByTitle(@NotNull final String title, @NotNull final User user);
|
||||||
|
|
||||||
|
void removeLabel(@NotNull final Label label);
|
||||||
}
|
}
|
||||||
|
@ -44,5 +44,10 @@ public class LabelManagerImpl extends HibernateDaoSupport
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeLabel(@NotNull Label label) {
|
||||||
|
getHibernateTemplate().delete(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -93,4 +93,16 @@ public class LabelController extends BaseController {
|
|||||||
mindmapService.updateMindmap(mindmap, false);
|
mindmapService.updateMindmap(mindmap, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.DELETE, value = "/labels/{id}")
|
||||||
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||||
|
public void deleteMapById(@PathVariable int id) throws WiseMappingException {
|
||||||
|
final User user = Utils.getUser();
|
||||||
|
final Label label = labelService.getLabelById(id);
|
||||||
|
if (label == null) {
|
||||||
|
throw new LabelCouldNotFoundException("Label could not be found. Id: " + id);
|
||||||
|
}
|
||||||
|
assert user != null;
|
||||||
|
labelService.removeLabel(label, user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,4 +18,6 @@ public interface LabelService {
|
|||||||
Label getLabelById(int id);
|
Label getLabelById(int id);
|
||||||
|
|
||||||
public Label getLabelByTitle(@NotNull String title, @NotNull final User user);
|
public Label getLabelByTitle(@NotNull String title, @NotNull final User user);
|
||||||
|
|
||||||
|
void removeLabel(@NotNull final Label label, @NotNull final User user) throws WiseMappingException;
|
||||||
}
|
}
|
||||||
|
@ -40,4 +40,14 @@ public class LabelServiceImpl implements LabelService {
|
|||||||
public Label getLabelByTitle(@NotNull String title, @NotNull final User user) {
|
public Label getLabelByTitle(@NotNull String title, @NotNull final User user) {
|
||||||
return labelManager.getLabelByTitle(title, user);
|
return labelManager.getLabelByTitle(title, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeLabel(@NotNull Label label, @NotNull User user) throws WiseMappingException {
|
||||||
|
if (label.getCreator().equals(user)) {
|
||||||
|
labelManager.removeLabel(label);
|
||||||
|
} else {
|
||||||
|
throw new WiseMappingException("User: "+ user.getFullName() + "has no ownership on label " + label.getTitle());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user