#8771 create the Permission DTO

This commit is contained in:
Mohamed Karray
2018-08-14 16:44:42 +02:00
parent 8c541b8dec
commit 012ac34a6a
3 changed files with 85 additions and 48 deletions

View File

@@ -1,32 +1,32 @@
/** /*
* Copyright (c) 2010, Sebastian Sdorra Copyright (c) 2010, Sebastian Sdorra
* All rights reserved. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this contributors may be used to endorse or promote products derived from this
* software without specific prior written permission. software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager http://bitbucket.org/sdorra/scm-manager
*
*/ */
@@ -57,10 +57,11 @@ import javax.xml.bind.annotation.XmlRootElement;
public class Permission implements PermissionObject, Serializable public class Permission implements PermissionObject, Serializable
{ {
/** Field description */
private static final long serialVersionUID = -2915175031430884040L; private static final long serialVersionUID = -2915175031430884040L;
//~--- constructors --------------------------------------------------------- private boolean groupPermission = false;
private String name;
private PermissionType type = PermissionType.READ;
/** /**
* Constructs a new {@link Permission}. * Constructs a new {@link Permission}.
@@ -153,12 +154,7 @@ public class Permission implements PermissionObject, Serializable
return Objects.hashCode(name, type, groupPermission); return Objects.hashCode(name, type, groupPermission);
} }
/**
* Method description
*
*
* @return
*/
@Override @Override
public String toString() public String toString()
{ {
@@ -242,15 +238,4 @@ public class Permission implements PermissionObject, Serializable
{ {
this.type = type; this.type = type;
} }
//~--- fields ---------------------------------------------------------------
/** Field description */
private boolean groupPermission = false;
/** Field description */
private String name;
/** Field description */
private PermissionType type = PermissionType.READ;
} }

View File

@@ -0,0 +1,26 @@
package sonia.scm.api.v2.resources;
import com.fasterxml.jackson.annotation.JsonInclude;
import de.otto.edison.hal.HalRepresentation;
import de.otto.edison.hal.Links;
import lombok.Getter;
import lombok.Setter;
@Getter @Setter
public class PermissionDto extends HalRepresentation {
@JsonInclude(JsonInclude.Include.NON_NULL)
private PermissionTypeDto type = PermissionTypeDto.READ;
@JsonInclude(JsonInclude.Include.NON_NULL)
private String name;
private boolean groupPermission = false;
@Override
@SuppressWarnings("squid:S1185") // We want to have this method available in this package
protected HalRepresentation add(Links links) {
return super.add(links);
}
}

View File

@@ -0,0 +1,26 @@
package sonia.scm.api.v2.resources;
/**
* Type of permissionPrefix for a {@link RepositoryDto}.
*
* @author mkarray
*/
public enum PermissionTypeDto {
/**
* read permission
*/
READ,
/**
* read and write permission
*/
WRITE,
/**
* read, write and manage the properties and permissions
*/
OWNER
}