--- /dev/null
+package org.apache.archiva.admin.repository.admin;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class OrganisationInformation
+{
+ /**
+ * name of the organisation.
+ */
+ private String name;
+
+ /**
+ * name of the organisation.
+ */
+ private String url;
+
+ /**
+ * name of the organisation.
+ */
+ private String logoLocation;
+
+ public OrganisationInformation()
+ {
+ // no op
+ }
+
+ public OrganisationInformation( String name, String url, String logoLocation )
+ {
+ this.name = name;
+ this.url = url;
+ this.logoLocation = logoLocation;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getUrl()
+ {
+ return url;
+ }
+
+ public void setUrl( String url )
+ {
+ this.url = url;
+ }
+
+ public String getLogoLocation()
+ {
+ return logoLocation;
+ }
+
+ public void setLogoLocation( String logoLocation )
+ {
+ this.logoLocation = logoLocation;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "OrganisationInformation" );
+ sb.append( "{name='" ).append( name ).append( '\'' );
+ sb.append( ", url='" ).append( url ).append( '\'' );
+ sb.append( ", logoLocation='" ).append( logoLocation ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
<dependencies>
<dependency>
<groupId>org.apache.archiva</groupId>
- <artifactId>archiva-security</artifactId>
+ <artifactId>archiva-security-common</artifactId>
+
</dependency>
<dependency>
--- /dev/null
+package org.apache.archiva.rest.api.model;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+@XmlRootElement( name = "organisationInformation" )
+public class OrganisationInformation
+{
+ /**
+ * name of the organisation.
+ */
+ private String name;
+
+ /**
+ * name of the organisation.
+ */
+ private String url;
+
+ /**
+ * name of the organisation.
+ */
+ private String logoLocation;
+
+ public OrganisationInformation()
+ {
+ // no op
+ }
+
+ public OrganisationInformation( String name, String url, String logoLocation )
+ {
+ this.name = name;
+ this.url = url;
+ this.logoLocation = logoLocation;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getUrl()
+ {
+ return url;
+ }
+
+ public void setUrl( String url )
+ {
+ this.url = url;
+ }
+
+ public String getLogoLocation()
+ {
+ return logoLocation;
+ }
+
+ public void setLogoLocation( String logoLocation )
+ {
+ this.logoLocation = logoLocation;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "OrganisationInformation" );
+ sb.append( "{name='" ).append( name ).append( '\'' );
+ sb.append( ", url='" ).append( url ).append( '\'' );
+ sb.append( ", logoLocation='" ).append( logoLocation ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
import org.apache.archiva.rest.api.model.FileType;
import org.apache.archiva.rest.api.model.LegacyArtifactPath;
+import org.apache.archiva.rest.api.model.OrganisationInformation;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
List<String> getInvalidContentConsumers()
throws ArchivaRestServiceException;
+
+ @Path( "getOrganisationInformation" )
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
+ @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+ OrganisationInformation getOrganisationInformation()
+ throws ArchivaRestServiceException;
+
+ @Path( "setOrganisationInformation" )
+ @POST
+ @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+ void setOrganisationInformation( OrganisationInformation organisationInformation )
+ throws ArchivaRestServiceException;
}
+
import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
import org.apache.archiva.rest.api.model.FileType;
import org.apache.archiva.rest.api.model.LegacyArtifactPath;
+import org.apache.archiva.rest.api.model.OrganisationInformation;
import org.apache.archiva.rest.api.services.ArchivaAdministrationService;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.springframework.stereotype.Service;
throw new ArchivaRestServiceException( e.getMessage() );
}
}
+
+ public OrganisationInformation getOrganisationInformation()
+ throws ArchivaRestServiceException
+ {
+ try
+ {
+ org.apache.archiva.admin.repository.admin.OrganisationInformation organisationInformation =
+ archivaAdministration.getOrganisationInformation();
+
+ return organisationInformation == null
+ ? null
+ : new BeanReplicator().replicateBean( organisationInformation, OrganisationInformation.class );
+ }
+ catch ( RepositoryAdminException e )
+ {
+ throw new ArchivaRestServiceException( e.getMessage() );
+ }
+ }
+
+ public void setOrganisationInformation( OrganisationInformation organisationInformation )
+ throws ArchivaRestServiceException
+ {
+ try
+ {
+ if ( organisationInformation == null )
+ {
+ archivaAdministration.setOrganisationInformation( null );
+ }
+ else
+ {
+ archivaAdministration.setOrganisationInformation(
+ new BeanReplicator().replicateBean( organisationInformation,
+ org.apache.archiva.admin.repository.admin.OrganisationInformation.class ) );
+ }
+ }
+ catch ( RepositoryAdminException e )
+ {
+ throw new ArchivaRestServiceException( e.getMessage() );
+ }
+ }
}
import org.apache.archiva.rest.api.model.FileType;
import org.apache.archiva.rest.api.model.LegacyArtifactPath;
+import org.apache.archiva.rest.api.model.OrganisationInformation;
+import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import java.util.Arrays;
getArchivaAdministrationService().removeFileType( "footwo" );
- assertEquals( initialSize , getArchivaAdministrationService().getFileTypes().size() );
+ assertEquals( initialSize, getArchivaAdministrationService().getFileTypes().size() );
assertNull( getArchivaAdministrationService().getFileType( "footwo" ) );
}
+
+ @Test
+ public void organisationInformationUpdate()
+ throws Exception
+ {
+ OrganisationInformation organisationInformation =
+ getArchivaAdministrationService().getOrganisationInformation();
+
+ // rest return an empty bean
+ assertNotNull( organisationInformation );
+ assertTrue( StringUtils.isBlank( organisationInformation.getLogoLocation() ) );
+ assertTrue( StringUtils.isBlank( organisationInformation.getName() ) );
+ assertTrue( StringUtils.isBlank( organisationInformation.getUrl() ) );
+
+ organisationInformation = new OrganisationInformation();
+ organisationInformation.setLogoLocation( "http://foo.com/bar.png" );
+ organisationInformation.setName( "foo org" );
+ organisationInformation.setUrl( "http://foo.com" );
+
+ getArchivaAdministrationService().setOrganisationInformation( organisationInformation );
+
+ organisationInformation = getArchivaAdministrationService().getOrganisationInformation();
+ assertNotNull( organisationInformation );
+ assertEquals( "http://foo.com/bar.png", organisationInformation.getLogoLocation() );
+ assertEquals( "foo org", organisationInformation.getName() );
+ assertEquals( "http://foo.com", organisationInformation.getUrl() );
+ }
}