API for Category domains (only method definitions, no implementation yet)
Former-commit-id: 8fe5c38cb9
restapi
parent
ac6d3b3d65
commit
94704d9e4a
|
|
@ -18,8 +18,28 @@
|
|||
*/
|
||||
package org.libreccm.api.admin.categorization;
|
||||
|
||||
import org.libreccm.api.admin.categorization.dto.DomainData;
|
||||
import org.libreccm.api.admin.categorization.dto.DomainOwnershipData;
|
||||
import org.libreccm.api.dto.ListView;
|
||||
import org.libreccm.core.CoreConstants;
|
||||
import org.libreccm.security.AuthorizationRequired;
|
||||
import org.libreccm.security.RequiresPrivilege;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -28,21 +48,100 @@ import javax.ws.rs.Path;
|
|||
@RequestScoped
|
||||
@Path("/domains")
|
||||
public class DomainsApi {
|
||||
|
||||
@GET
|
||||
@Path("/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public ListView<DomainData> getDomains(
|
||||
@QueryParam("limit") @DefaultValue("20") final int limit,
|
||||
@QueryParam("offset") @DefaultValue("0") final int offset
|
||||
) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{domainIdentifier}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public DomainData getDomain(
|
||||
@PathParam("domainIdentifier") final String domainIdentifierParam) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public ListView<DomainData> addDomain(final DomainData domainData) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/{domainIdentifier}")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public DomainData updateDomain(
|
||||
@PathParam("domainIdentifier") final String domainIdentifierParam,
|
||||
final DomainData domainData) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/{domainIdentifier}")
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public DomainData deleteDomain(
|
||||
@PathParam("domainIdentifier") final String domainIdentifierParam) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
// GET Domains @Path("/")
|
||||
@GET
|
||||
@Path("/{domainIdentifier}/owners")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<DomainOwnershipData> getOwners(
|
||||
@PathParam("domainIdentifier") final String domainIdentifierParam
|
||||
) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{domainIdentifier}/owners/{ownerIdentifier}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<DomainOwnershipData> addOwner(
|
||||
@PathParam("domainIdentifier") final String domainIdentifierParam,
|
||||
@PathParam("ownerIdentifier") final String ownerIdentifierParam
|
||||
) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
// GET Domain @Path("/domain-identifier")
|
||||
@DELETE
|
||||
@Path("/{domainIdentifier}/owners/{ownerIdentifier}")
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<DomainOwnershipData> removeOwner(
|
||||
@PathParam("domainIdentifier") final String domainIdentifierParam,
|
||||
@PathParam("ownerIdentifier") final String ownerIdentifierParam
|
||||
) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
// POST @Path("/") create new
|
||||
|
||||
// PUT Domain @Path("/domain-identifier")
|
||||
|
||||
|
||||
// DELETE Domain @Path("/domain-identifier")
|
||||
|
||||
// GET owners @Path("/domain-identifier/owners")
|
||||
|
||||
// PUT Add owner @Path("/domain-identifier/owners/owner-identifier")
|
||||
|
||||
// DELETE Remove owner @Path("/domain-identifier/owners/owner-identifier")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (C) 2020 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.libreccm.api.admin.categorization.dto;
|
||||
|
||||
import org.libreccm.categorization.Category;
|
||||
|
||||
/**
|
||||
* Provides the informations for identifing a {@link Category}.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class CategoryId {
|
||||
|
||||
private long categoryId;
|
||||
|
||||
private String uuid;
|
||||
|
||||
private String uniqueId;
|
||||
|
||||
/**
|
||||
* Constructor for creating empty instances.
|
||||
*/
|
||||
public CategoryId() {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance from the provided catgory.
|
||||
*
|
||||
* @param category The {@link Category} used as source.
|
||||
*/
|
||||
public CategoryId(final Category category) {
|
||||
categoryId = category.getObjectId();
|
||||
uuid = category.getUuid();
|
||||
uniqueId = category.getUniqueId();
|
||||
}
|
||||
|
||||
public long getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setCategoryId(final long categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getUniqueId() {
|
||||
return uniqueId;
|
||||
}
|
||||
|
||||
public void setUniqueId(final String uniqueId) {
|
||||
this.uniqueId = uniqueId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (C) 2020 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.libreccm.api.admin.categorization.dto;
|
||||
|
||||
import org.libreccm.categorization.Domain;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class DomainData {
|
||||
|
||||
private long domainId;
|
||||
|
||||
private String uuid;
|
||||
|
||||
private String domainKey;
|
||||
|
||||
private String uri;
|
||||
|
||||
private LocalizedString title;
|
||||
|
||||
private LocalizedString description;
|
||||
|
||||
private String version;
|
||||
|
||||
private String released;
|
||||
|
||||
private CategoryId root;
|
||||
|
||||
private List<DomainOwnershipData> owners;
|
||||
|
||||
public DomainData() {
|
||||
owners = new ArrayList<>();
|
||||
}
|
||||
|
||||
public DomainData(final Domain domain) {
|
||||
domainId = domain.getObjectId();
|
||||
uuid = domain.getUuid();
|
||||
domainKey = domain.getDomainKey();
|
||||
uri = domain.getUri();
|
||||
title = domain.getTitle();
|
||||
description = domain.getDescription();
|
||||
version = domain.getVersion();
|
||||
released = DateTimeFormatter
|
||||
.ISO_DATE_TIME
|
||||
.format(domain.getReleased().toInstant());
|
||||
root = new CategoryId(domain.getRoot());
|
||||
|
||||
owners = domain
|
||||
.getOwners()
|
||||
.stream()
|
||||
.map(DomainOwnershipData::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public void setDomainId(final long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getDomainKey() {
|
||||
return domainKey;
|
||||
}
|
||||
|
||||
public void setDomainKey(final String domainKey) {
|
||||
this.domainKey = domainKey;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(final String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public LocalizedString getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(final LocalizedString title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public LocalizedString getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final LocalizedString description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(final String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getReleased() {
|
||||
return released;
|
||||
}
|
||||
|
||||
public void setReleased(final String released) {
|
||||
this.released = released;
|
||||
}
|
||||
|
||||
public CategoryId getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
public void setRoot(final CategoryId root) {
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
public List<DomainOwnershipData> getOwners() {
|
||||
return new ArrayList<>(owners);
|
||||
}
|
||||
|
||||
public void setOwners(final List<DomainOwnershipData> owners) {
|
||||
this.owners = new ArrayList<>(owners);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright (C) 2020 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.libreccm.api.admin.categorization.dto;
|
||||
|
||||
import org.libreccm.api.admin.web.dto.CcmApplicationId;
|
||||
import org.libreccm.categorization.DomainOwnership;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class DomainOwnershipData {
|
||||
|
||||
private long ownershipId;
|
||||
|
||||
private String uuid;
|
||||
|
||||
private CcmApplicationId owner;
|
||||
|
||||
public DomainOwnershipData() {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
public DomainOwnershipData(final DomainOwnership ownership) {
|
||||
ownershipId = ownership.getOwnershipId();
|
||||
uuid = ownership.getUuid();
|
||||
owner = new CcmApplicationId(ownership.getOwner());
|
||||
}
|
||||
|
||||
public long getOwnershipId() {
|
||||
return ownershipId;
|
||||
}
|
||||
|
||||
public void setOwnershipId(final long ownershipId) {
|
||||
this.ownershipId = ownershipId;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public CcmApplicationId getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(final CcmApplicationId owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (C) 2020 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.libreccm.api.admin.categorization.dto;
|
||||
|
||||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class SubCategoryId extends CategoryId {
|
||||
|
||||
private String name;
|
||||
|
||||
private LocalizedString title;
|
||||
|
||||
public SubCategoryId() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SubCategoryId(final Category category) {
|
||||
super(category);
|
||||
name = category.getName();
|
||||
title = category.getTitle();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public LocalizedString getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(final LocalizedString title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (C) 2020 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.libreccm.api.admin.web.dto;
|
||||
|
||||
import org.libreccm.api.core.dto.CcmObjectId;
|
||||
import org.libreccm.web.CcmApplication;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class CcmApplicationId extends CcmObjectId {
|
||||
|
||||
private String applicationType;
|
||||
|
||||
private String primaryUrl;
|
||||
|
||||
public CcmApplicationId() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CcmApplicationId(final CcmApplication application) {
|
||||
applicationType = application.getApplicationType();
|
||||
primaryUrl = application.getPrimaryUrl();
|
||||
}
|
||||
|
||||
public String getApplicationType() {
|
||||
return applicationType;
|
||||
}
|
||||
|
||||
public void setApplicationType(final String applicationType) {
|
||||
this.applicationType = applicationType;
|
||||
}
|
||||
|
||||
public String getPrimaryUrl() {
|
||||
return primaryUrl;
|
||||
}
|
||||
|
||||
public void setPrimaryUrl(final String primaryUrl) {
|
||||
this.primaryUrl = primaryUrl;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue