mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
add avatarUrl / fix conditions_os to list of string
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* <p>
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* <p>
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
@@ -13,7 +13,7 @@
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@@ -24,13 +24,11 @@
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* <p>
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
@@ -39,6 +37,8 @@ import com.github.sdorra.ssp.PermissionObject;
|
||||
import com.github.sdorra.ssp.StaticPermissions;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Objects;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import sonia.scm.Validateable;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
@@ -46,43 +46,38 @@ import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@StaticPermissions(
|
||||
value = "plugin",
|
||||
generatedClass = "PluginPermissions",
|
||||
permissions = {},
|
||||
globalPermissions = { "read", "manage" },
|
||||
globalPermissions = {"read", "manage"},
|
||||
custom = true, customGlobal = true
|
||||
)
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "plugin-information")
|
||||
public class PluginInformation
|
||||
implements PermissionObject, Validateable, Cloneable, Serializable
|
||||
{
|
||||
@Getter
|
||||
@Setter
|
||||
public class PluginInformation implements PermissionObject, Validateable, Cloneable, Serializable {
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = 461382048865977206L;
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
private String author;
|
||||
private String category;
|
||||
private PluginCondition condition;
|
||||
private String description;
|
||||
private String name;
|
||||
private PluginState state;
|
||||
private String version;
|
||||
private String avatarUrl;
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @since 1.11
|
||||
*/
|
||||
@Override
|
||||
public PluginInformation clone()
|
||||
{
|
||||
public PluginInformation clone() {
|
||||
PluginInformation clone = new PluginInformation();
|
||||
clone.setName(name);
|
||||
clone.setAuthor(author);
|
||||
@@ -90,33 +85,22 @@ public class PluginInformation
|
||||
clone.setDescription(description);
|
||||
clone.setState(state);
|
||||
clone.setVersion(version);
|
||||
clone.setAvatarUrl(avatarUrl);
|
||||
|
||||
if (condition != null)
|
||||
{
|
||||
if (condition != null) {
|
||||
clone.setCondition(condition.clone());
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param obj
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getClass() != obj.getClass())
|
||||
{
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -130,32 +114,19 @@ public class PluginInformation
|
||||
&& Objects.equal(description, other.description)
|
||||
&& Objects.equal(name, other.name)
|
||||
&& Objects.equal(state, other.state)
|
||||
&& Objects.equal(version, other.version);
|
||||
&& Objects.equal(version, other.version)
|
||||
&& Objects.equal(avatarUrl, other.avatarUrl);
|
||||
//J+
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(author, category, condition,
|
||||
description, name, state, version);
|
||||
description, name, state, version, avatarUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
//J-
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("author", author)
|
||||
@@ -165,236 +136,27 @@ public class PluginInformation
|
||||
.add("name", name)
|
||||
.add("state", state)
|
||||
.add("version", version)
|
||||
.add("avatarUrl", avatarUrl)
|
||||
.toString();
|
||||
//J+
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getAuthor()
|
||||
{
|
||||
return author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getCategory()
|
||||
{
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public PluginCondition getCondition()
|
||||
{
|
||||
return condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
public String getId() {
|
||||
return getName(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param withVersion
|
||||
*
|
||||
* @return
|
||||
* @since 1.21
|
||||
*/
|
||||
public String getName(boolean withVersion)
|
||||
{
|
||||
public String getName(boolean withVersion) {
|
||||
StringBuilder id = new StringBuilder(name);
|
||||
|
||||
if (withVersion)
|
||||
{
|
||||
if (withVersion) {
|
||||
id.append(":").append(version);
|
||||
}
|
||||
|
||||
return id.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public PluginState getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
public boolean isValid() {
|
||||
return Util.isNotEmpty(name) && Util.isNotEmpty(version);
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param author
|
||||
*/
|
||||
public void setAuthor(String author)
|
||||
{
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param category
|
||||
*/
|
||||
public void setCategory(String category)
|
||||
{
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param condition
|
||||
*/
|
||||
public void setCondition(PluginCondition condition)
|
||||
{
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param description
|
||||
*/
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
public void setState(PluginState state)
|
||||
{
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param version
|
||||
*/
|
||||
public void setVersion(String version)
|
||||
{
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private String author;
|
||||
|
||||
/** Field description */
|
||||
private String category;
|
||||
|
||||
/** Field description */
|
||||
private PluginCondition condition;
|
||||
|
||||
/** Field description */
|
||||
private String description;
|
||||
|
||||
/** Field description */
|
||||
private String name;
|
||||
|
||||
/** Field description */
|
||||
private PluginState state;
|
||||
|
||||
/** Field description */
|
||||
private String version;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
//@flow
|
||||
import type { Collection, Links } from "./hal";
|
||||
import type {Collection, Links} from "./hal";
|
||||
|
||||
export type Plugin = {
|
||||
name: string,
|
||||
type: string,
|
||||
version: string,
|
||||
author: string,
|
||||
avatarUrl: string,
|
||||
description?: string,
|
||||
_links: Links
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||
import type { Plugin } from "@scm-manager/ui-types";
|
||||
import { Image } from "@scm-manager/ui-components";
|
||||
import {ExtensionPoint} from "@scm-manager/ui-extensions";
|
||||
import type {Plugin} from "@scm-manager/ui-types";
|
||||
import {Image} from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
plugin: Plugin
|
||||
@@ -14,7 +14,7 @@ export default class PluginAvatar extends React.Component<Props> {
|
||||
return (
|
||||
<p className="image is-64x64">
|
||||
<ExtensionPoint name="plugins.plugin-avatar" props={{ plugin }}>
|
||||
<Image src="/images/blib.jpg" alt="Logo" />
|
||||
<Image src={plugin.avatarUrl ? plugin.avatarUrl : "/images/blib.jpg"} alt="Logo" />
|
||||
</ExtensionPoint>
|
||||
</p>
|
||||
);
|
||||
|
||||
@@ -3,7 +3,6 @@ package sonia.scm.api.v2.resources;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
@@ -51,6 +50,7 @@ public final class PluginCenterDto implements Serializable {
|
||||
private String category;
|
||||
private String version;
|
||||
private String author;
|
||||
private String avatarUrl;
|
||||
private String sha256;
|
||||
|
||||
@XmlElement(name = "conditions")
|
||||
@@ -69,7 +69,7 @@ public final class PluginCenterDto implements Serializable {
|
||||
@AllArgsConstructor
|
||||
public static class Condition {
|
||||
|
||||
private String os;
|
||||
private List<String> os;
|
||||
private String arch;
|
||||
private String minVersion;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package sonia.scm.api.v2.resources;
|
||||
import sonia.scm.plugin.PluginCondition;
|
||||
import sonia.scm.plugin.PluginInformation;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -24,7 +23,7 @@ public class PluginCenterDtoMapper {
|
||||
|
||||
if (plugin.getConditions() != null) {
|
||||
PluginCenterDto.Condition condition = plugin.getConditions();
|
||||
pluginInformation.setCondition(new PluginCondition(condition.getMinVersion(), Collections.singletonList(condition.getOs()), condition.getArch()));
|
||||
pluginInformation.setCondition(new PluginCondition(condition.getMinVersion(), condition.getOs(), condition.getArch()));
|
||||
}
|
||||
|
||||
pluginInformationSet.add(pluginInformation);
|
||||
|
||||
@@ -3,7 +3,6 @@ package sonia.scm.api.v2.resources;
|
||||
import de.otto.edison.hal.HalRepresentation;
|
||||
import de.otto.edison.hal.Links;
|
||||
import lombok.Getter;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -16,6 +15,7 @@ public class PluginDto extends HalRepresentation {
|
||||
private String category;
|
||||
private String version;
|
||||
private String author;
|
||||
private String avatarUrl;
|
||||
private String description;
|
||||
|
||||
public PluginDto(Links links) {
|
||||
|
||||
@@ -4,9 +4,10 @@ import de.otto.edison.hal.Links;
|
||||
import sonia.scm.plugin.PluginInformation;
|
||||
import sonia.scm.plugin.PluginState;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static de.otto.edison.hal.Link.*;
|
||||
import static de.otto.edison.hal.Link.link;
|
||||
import static de.otto.edison.hal.Links.linkingTo;
|
||||
|
||||
public class PluginDtoMapper {
|
||||
@@ -43,6 +44,7 @@ public class PluginDtoMapper {
|
||||
pluginDto.setVersion(pluginInformation.getVersion());
|
||||
pluginDto.setAuthor(pluginInformation.getAuthor());
|
||||
pluginDto.setDescription(pluginInformation.getDescription());
|
||||
pluginDto.setAvatarUrl(pluginInformation.getAvatarUrl());
|
||||
|
||||
return pluginDto;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static sonia.scm.api.v2.resources.PluginCenterDto.*;
|
||||
import static sonia.scm.api.v2.resources.PluginCenterDto.Condition;
|
||||
import static sonia.scm.api.v2.resources.PluginCenterDto.Dependency;
|
||||
import static sonia.scm.api.v2.resources.PluginCenterDto.Plugin;
|
||||
|
||||
class PluginCenterDtoMapperTest {
|
||||
|
||||
@@ -32,8 +34,9 @@ class PluginCenterDtoMapperTest {
|
||||
"Travel",
|
||||
"2.0.0",
|
||||
"trillian",
|
||||
"http://avatar.url",
|
||||
"555000444",
|
||||
new Condition("linux", "amd64","2.0.0"),
|
||||
new Condition(Collections.singletonList("linux"), "amd64","2.0.0"),
|
||||
new Dependency("scm-review-plugin"),
|
||||
new HashMap<>());
|
||||
|
||||
@@ -44,7 +47,7 @@ class PluginCenterDtoMapperTest {
|
||||
assertThat(result.getVersion()).isEqualTo(plugin.getVersion());
|
||||
assertThat(result.getCondition().getArch()).isEqualTo(plugin.getConditions().getArch());
|
||||
assertThat(result.getCondition().getMinVersion()).isEqualTo(plugin.getConditions().getMinVersion());
|
||||
assertThat(result.getCondition().getOs().iterator().next()).isEqualTo(plugin.getConditions().getOs());
|
||||
assertThat(result.getCondition().getOs().iterator().next()).isEqualTo(plugin.getConditions().getOs().iterator().next());
|
||||
assertThat(result.getDescription()).isEqualTo(plugin.getDescription());
|
||||
assertThat(result.getName()).isEqualTo(plugin.getName());
|
||||
}
|
||||
@@ -52,26 +55,28 @@ class PluginCenterDtoMapperTest {
|
||||
@Test
|
||||
void shouldMapMultiplePlugins() {
|
||||
Plugin plugin1 = new Plugin(
|
||||
"scm-hitchhiker-plugin",
|
||||
"SCM Hitchhiker Plugin",
|
||||
"plugin for hitchhikers",
|
||||
"Travel",
|
||||
"2.0.0",
|
||||
"dent",
|
||||
"555000444",
|
||||
new Condition("linux", "amd64","2.0.0"),
|
||||
new Dependency("scm-review-plugin"),
|
||||
new HashMap<>());
|
||||
|
||||
Plugin plugin2 = new Plugin(
|
||||
"scm-review-plugin",
|
||||
"SCM Hitchhiker Plugin",
|
||||
"plugin for hitchhikers",
|
||||
"Travel",
|
||||
"2.1.0",
|
||||
"trillian",
|
||||
"https://avatar.url",
|
||||
"12345678aa",
|
||||
new Condition("linux", "amd64","2.0.0"),
|
||||
new Condition(Collections.singletonList("linux"), "amd64","2.0.0"),
|
||||
new Dependency("scm-review-plugin"),
|
||||
new HashMap<>());
|
||||
|
||||
Plugin plugin2 = new Plugin(
|
||||
"scm-hitchhiker-plugin",
|
||||
"SCM Hitchhiker Plugin",
|
||||
"plugin for hitchhikers",
|
||||
"Travel",
|
||||
"2.0.0",
|
||||
"dent",
|
||||
"http://avatar.url",
|
||||
"555000444",
|
||||
new Condition(Collections.singletonList("linux"), "amd64","2.0.0"),
|
||||
new Dependency("scm-review-plugin"),
|
||||
new HashMap<>());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user