From: James William Dumay Date: Sat, 5 Jul 2008 08:40:27 +0000 (+0000) Subject: MRM-829 - Replace Company POM feature with simple Appearence customisation X-Git-Tag: archiva-r676265~18 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5378f9b2f53bae243d2cd11933baa7dfd27df4bd;p=archiva.git MRM-829 - Replace Company POM feature with simple Appearence customisation git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@674161 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo index 1455d9f71..b7523ef13 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo @@ -158,6 +158,17 @@ The webapp configuration. + + organisationInfo + 1.1.0+ + + OrganisationInformation + 1 + + + The organisation info. + + @@ -1034,6 +1045,40 @@ --> + + OrganisationInformation + 1.1.0+ + + The organisation information settings. + + + + name + name of the organisation + 1.1.0+ + + String + + + + url + name of the organisation + 1.1.0+ + + String + + + + logoLocation + name of the organisation + 1.1.0+ + + String + + + + + WebappConfiguration 1.0.0+ diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractAppearanceAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractAppearanceAction.java index 8fcaeb5c0..f8d6bf73f 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractAppearanceAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractAppearanceAction.java @@ -19,14 +19,12 @@ package org.apache.maven.archiva.web.action.admin.appearance; * under the License. */ -import org.apache.commons.lang.StringUtils; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.OrganisationInformation; import org.codehaus.plexus.xwork.action.PlexusActionSupport; -import java.io.File; -import java.util.Map; +import com.opensymphony.xwork.Preparable; /** * AbstractAppearanceAction @@ -36,35 +34,68 @@ import java.util.Map; */ public abstract class AbstractAppearanceAction extends PlexusActionSupport + implements Preparable { /** - * @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout" - */ - private Map repositoryLayouts; - - /** + * Archiva Application Configuration * @plexus.requirement */ - private ArtifactRepositoryFactory repoFactory; + protected ArchivaConfiguration configuration; + + private String organisationLogo; - protected ArtifactRepository createLocalRepository() + private String organisationUrl; + + private String organisationName; + + public void setConfiguration(ArchivaConfiguration configuration) + { + this.configuration = configuration; + } + + public String getOrganisationLogo() { - String id = "archiva-local-repo"; - String layout = "default"; - String directory = System.getProperty( "user.home" ) + "/.m2/archiva"; + return organisationLogo; + } - ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) repositoryLayouts.get( layout ); - File repository = new File( directory ); - repository.mkdirs(); + public String getOrganisationName() + { + return organisationName; + } - String repoDir = repository.toURI().toString(); - //workaround for spaces non converted by PathUtils in wagon - //TODO: remove it when PathUtils will be fixed - if ( repoDir.indexOf( "%20" ) >= 0 ) + public String getOrganisationUrl() + { + return organisationUrl; + } + + public void setOrganisationLogo(String organisationLogo) + { + this.organisationLogo = organisationLogo; + } + + public void setOrganisationName(String organisationName) + { + this.organisationName = organisationName; + } + + public void setOrganisationUrl(String organisationUrl) + { + this.organisationUrl = organisationUrl; + } + + public void prepare() + throws Exception + { + Configuration config = configuration.getConfiguration(); + if (config != null) { - repoDir = StringUtils.replace( repoDir, "%20", " " ); + OrganisationInformation orgInfo = config.getOrganisationInfo(); + if (orgInfo != null) + { + setOrganisationLogo(orgInfo.getLogoLocation()); + setOrganisationName(orgInfo.getName()); + setOrganisationUrl(orgInfo.getUrl()); + } } - - return repoFactory.createArtifactRepository( id, repoDir, repositoryLayout, null, null ); } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/CompanyInfoAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/CompanyInfoAction.java deleted file mode 100644 index c682f8144..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/CompanyInfoAction.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.apache.maven.archiva.web.action.admin.appearance; - -/* - * 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 org.apache.maven.model.Model; -import org.apache.maven.shared.app.company.CompanyPomHandler; -import org.apache.maven.shared.app.configuration.MavenAppConfiguration; - -/** - * Stores the company information for displaying on the page. - * - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="companyInfo" - */ -public class CompanyInfoAction - extends AbstractAppearanceAction -{ - private String companyLogo; - - private String companyUrl; - - private String companyName; - - /** - * @plexus.requirement - */ - private CompanyPomHandler handler; - - /** - * @plexus.requirement - */ - private MavenAppConfiguration appConfigurationStore; - - public String execute() - throws Exception - { - Model model = handler.getCompanyPomModel( appConfigurationStore.getConfiguration().getCompanyPom(), - createLocalRepository() ); - - if ( model != null ) - { - if ( model.getOrganization() != null ) - { - companyName = model.getOrganization().getName(); - companyUrl = model.getOrganization().getUrl(); - } - - companyLogo = model.getProperties().getProperty( "organization.logo" ); - } - - return SUCCESS; - } - - public String getCompanyLogo() - { - return companyLogo; - } - - public String getCompanyUrl() - { - return companyUrl; - } - - public String getCompanyName() - { - return companyName; - } -} \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/ConfigureAppearanceAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/ConfigureAppearanceAction.java deleted file mode 100644 index 093bc6faf..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/ConfigureAppearanceAction.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.apache.maven.archiva.web.action.admin.appearance; - -/* - * 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 com.opensymphony.xwork.ModelDriven; -import com.opensymphony.xwork.Preparable; - -import org.apache.maven.archiva.security.ArchivaRoleConstants; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.model.Model; -import org.apache.maven.project.ProjectBuildingException; -import org.apache.maven.shared.app.company.CompanyPomHandler; -import org.apache.maven.shared.app.configuration.Configuration; -import org.apache.maven.shared.app.configuration.MavenAppConfiguration; -import org.codehaus.plexus.redback.rbac.Resource; -import org.codehaus.plexus.redback.xwork.interceptor.SecureAction; -import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle; -import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException; -import org.codehaus.plexus.registry.RegistryException; - -import java.io.IOException; - -/** - * @author Brett Porter - * @version $Id: ConfigurationAction.java 480950 2006-11-30 14:58:35Z evenisse $ - * @plexus.component role="com.opensymphony.xwork.Action" - * role-hint="configureAppearance" - */ -public class ConfigureAppearanceAction - extends AbstractAppearanceAction - implements ModelDriven, SecureAction, Preparable -{ - /** - * @plexus.requirement - */ - private MavenAppConfiguration appConfigurationStore; - - /** - * The configuration. - */ - private Configuration configuration; - - private Model companyModel; - - /** - * @plexus.requirement - */ - private CompanyPomHandler companyPomHandler; - - public String execute() - throws IOException, RegistryException - { - appConfigurationStore.save( configuration ); - - return SUCCESS; - } - - public Object getModel() - { - return configuration; - } - - public void prepare() - throws ProjectBuildingException, ArtifactMetadataRetrievalException - { - configuration = appConfigurationStore.getConfiguration(); - - companyModel = companyPomHandler.getCompanyPomModel( configuration.getCompanyPom(), createLocalRepository() ); - } - - public SecureActionBundle getSecureActionBundle() - throws SecureActionException - { - SecureActionBundle bundle = new SecureActionBundle(); - bundle.setRequiresAuthentication( true ); - bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL ); - - return bundle; - } - - public Model getCompanyModel() - { - return companyModel; - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java new file mode 100644 index 000000000..1304b5046 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java @@ -0,0 +1,74 @@ +package org.apache.maven.archiva.web.action.admin.appearance; + +/* + * 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 org.codehaus.plexus.redback.xwork.interceptor.SecureAction; + +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; +import org.apache.maven.archiva.configuration.OrganisationInformation; +import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.codehaus.plexus.redback.rbac.Resource; +import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle; +import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException; +import org.codehaus.plexus.registry.RegistryException; + +/** + * @author Brett Porter + * @version $Id: ConfigurationAction.java 480950 2006-11-30 14:58:35Z evenisse $ + * + * @plexus.component role="com.opensymphony.xwork.Action" + * role-hint="editOrganisationInfo" + */ +public class EditOrganisationInfoAction + extends AbstractAppearanceAction + implements SecureAction +{ + @Override + public String execute() + throws RegistryException, IndeterminateConfigurationException + { + Configuration config = configuration.getConfiguration(); + if (config != null) + { + OrganisationInformation orgInfo = config.getOrganisationInfo(); + if (orgInfo == null) + { + config.setOrganisationInfo(orgInfo); + } + + orgInfo.setLogoLocation(getOrganisationLogo()); + orgInfo.setName(getOrganisationName()); + orgInfo.setUrl(getOrganisationUrl()); + + configuration.save(config); + } + return SUCCESS; + } + + public SecureActionBundle getSecureActionBundle() + throws SecureActionException + { + SecureActionBundle bundle = new SecureActionBundle(); + bundle.setRequiresAuthentication( true ); + bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL ); + return bundle; + } +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditPomAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditPomAction.java deleted file mode 100644 index 874eded6e..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditPomAction.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.apache.maven.archiva.web.action.admin.appearance; - -/* - * 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 com.opensymphony.xwork.ModelDriven; -import com.opensymphony.xwork.Preparable; - -import org.apache.maven.archiva.security.ArchivaRoleConstants; -import org.apache.maven.artifact.installer.ArtifactInstallationException; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.model.Model; -import org.apache.maven.project.ProjectBuildingException; -import org.apache.maven.shared.app.company.CompanyPomHandler; -import org.apache.maven.shared.app.configuration.CompanyPom; -import org.apache.maven.shared.app.configuration.Configuration; -import org.apache.maven.shared.app.configuration.MavenAppConfiguration; -import org.codehaus.plexus.redback.rbac.Resource; -import org.codehaus.plexus.redback.xwork.interceptor.SecureAction; -import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle; -import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException; - -import java.io.IOException; - -/** - * @author Brett Porter - * @version $Id: ConfigurationAction.java 480950 2006-11-30 14:58:35Z evenisse $ - * - * @plexus.component role="com.opensymphony.xwork.Action" - * role-hint="editPom" - */ -public class EditPomAction - extends AbstractAppearanceAction - implements ModelDriven, SecureAction, Preparable -{ - /** - * @plexus.requirement - */ - private MavenAppConfiguration appConfigurationStore; - - /** - * The configuration. - */ - private Configuration configuration; - - /** - * @plexus.requirement - */ - private CompanyPomHandler companyPomHandler; - - private Model companyModel; - - public String execute() - throws IOException, ArtifactInstallationException - { - // TODO: hack for passed in String[] - String[] logo = (String[]) companyModel.getProperties().get( "organization.logo" ); - if ( logo != null ) - { - companyModel.getProperties().put( "organization.logo", logo[0] ); - } - - companyPomHandler.save( companyModel, createLocalRepository() ); - - return SUCCESS; - } - - public Object getModel() - { - return companyModel; - } - - public void prepare() - throws ProjectBuildingException, ArtifactMetadataRetrievalException - { - configuration = appConfigurationStore.getConfiguration(); - - CompanyPom companyPom = configuration.getCompanyPom(); - companyModel = companyPomHandler.getCompanyPomModel( companyPom, createLocalRepository() ); - - if ( companyModel == null ) - { - companyModel = new Model(); - companyModel.setModelVersion( "4.0.0" ); - companyModel.setPackaging( "pom" ); - - if ( companyPom != null ) - { - companyModel.setGroupId( companyPom.getGroupId() ); - companyModel.setArtifactId( companyPom.getArtifactId() ); - } - } - } - - public SecureActionBundle getSecureActionBundle() - throws SecureActionException - { - SecureActionBundle bundle = new SecureActionBundle(); - bundle.setRequiresAuthentication( true ); - bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL ); - - return bundle; - } - - public Model getCompanyModel() - { - return companyModel; - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/OrganisationInfoAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/OrganisationInfoAction.java new file mode 100644 index 000000000..bcacf1ea4 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/OrganisationInfoAction.java @@ -0,0 +1,30 @@ +package org.apache.maven.archiva.web.action.admin.appearance; + +/* + * 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. + */ + +/** + * Stores the organisation information for displaying on the page. + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="organisationInfo" + */ +public class OrganisationInfoAction + extends AbstractAppearanceAction +{ +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance-validation.xml index 0628a0dcc..64c011f1f 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance-validation.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance-validation.xml @@ -22,14 +22,14 @@ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> - - - + + + - - - + + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance.properties b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance.properties index bfcaf5bcf..2084ccd4a 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance.properties +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance.properties @@ -17,5 +17,5 @@ # under the License. # -appearance.groupId.required = You must define a group identifier. -appearance.artifactId.required = You must define an artifact identifier. \ No newline at end of file +appearance.organisation.url = You must define an organisation url." +appearance.organisation.logourl = You must define an organisation logo url." \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction-validation.xml new file mode 100644 index 000000000..38b3bcfa8 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction-validation.xml @@ -0,0 +1,40 @@ + + + + + + + + + You must enter a name + + + + + You must enter a URL + + + + + You must enter a URL + + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/xwork.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/xwork.xml index c85744f25..21d0363f6 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/xwork.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/xwork.xml @@ -212,7 +212,7 @@ - + /WEB-INF/jsp/components/companyLogo.jsp @@ -432,17 +432,15 @@ - - - - /WEB-INF/jsp/admin/appearance.jsp + + /WEB-INF/jsp/admin/appearance.jsp - + /WEB-INF/jsp/admin/editAppearance.jsp - + /WEB-INF/jsp/admin/editAppearance.jsp configureAppearance @@ -450,18 +448,6 @@ - - /WEB-INF/jsp/admin/editPom.jsp - - - - /WEB-INF/jsp/admin/editPom.jsp - - configureAppearance - /admin - - - diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/appearance.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/appearance.jsp index dfebffbc9..d2b24e83a 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/appearance.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/appearance.jsp @@ -19,6 +19,7 @@ <%@ taglib prefix="ww" uri="/webwork" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + Configure Appearance @@ -31,66 +32,37 @@ -

Company Details

+

Organization Details

- The logo in the top right of the screen is controlled by your selected 'company POM'. + The logo in the top right of the screen is controlled by the following settings. + Change your appearence

- - - -

- You have not yet specified a company POM. Select a Company POM -

-
- - -

- Your selected company POM is below. If you would like to change the organization name, url or logo, you can - edit the POM. -

- - - - - - - - -
- - -

POM Information

- - - +

Organization Information

- + - + + + +
Name${companyModel.organization.name}${organisationName}
URL - ${companyModel.organization.url} + + ${organisationUrl}
Logo URL - ${companyModel.properties['organization.logo']} + ${organisationLogo} +
  +
-
- - Company POM '${companyPom.groupId}:${companyPom.artifactId}' doesn't exist. - Create company POM - -
-
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editAppearance.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editAppearance.jsp index 9061a3137..5f5316a2a 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editAppearance.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editAppearance.jsp @@ -27,19 +27,20 @@

Appearance

-

Company Details

+

Organization Details

- Enter the details of the company super POM below. If it exists, the organization name, URL and logo will be read - from it. + Enter the details of your organization below.

+ - - + + + - \ No newline at end of file + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editPom.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editPom.jsp deleted file mode 100644 index 7887ea21e..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editPom.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<%-- - ~ 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. - --%> - -<%@ taglib prefix="ww" uri="/webwork" %> - - - Edit Company POM - - - - -

Company POM

- - - - - - - Version - - - (The version will automatically be incremented when you save this form) - - - - -

Organization

- - - - <%-- TODO: how to get it to be a string, not a String[]? --%> - - -
- - - \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/components/companyLogo.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/components/companyLogo.jsp index 1a1815a3f..5627e2631 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/components/companyLogo.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/components/companyLogo.jsp @@ -19,17 +19,16 @@ <%@ taglib uri="/webwork" prefix="ww" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - - - + + - + - + - + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java new file mode 100644 index 000000000..c840c2381 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java @@ -0,0 +1,47 @@ +package org.apache.maven.archiva.web.action.admin.appearance; + +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.web.action.AbstractWebworkTestCase; +import org.easymock.MockControl; + +/** + * @author James William Dumay + */ +public abstract class AbstractOrganizationInfoActionTest extends AbstractWebworkTestCase +{ + protected MockControl archivaConfigurationControl; + + protected ArchivaConfiguration configuration; + + protected AbstractAppearanceAction action; + + protected Configuration config; + + protected abstract AbstractAppearanceAction getAction(); + + @Override + protected void setUp() + throws Exception + { + super.setUp(); + + config = new Configuration(); + archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class ); + configuration = (ArchivaConfiguration) archivaConfigurationControl.getMock(); + + configuration.getConfiguration(); + archivaConfigurationControl.setReturnValue(config, 1, 2); + + configuration.save(config); + archivaConfigurationControl.setVoidCallable(1, 2); + + archivaConfigurationControl.replay(); + } + + protected void reloadAction() + { + action = getAction(); + action.setConfiguration( configuration ); + } +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java new file mode 100644 index 000000000..66ca872c2 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java @@ -0,0 +1,69 @@ +package org.apache.maven.archiva.web.action.admin.appearance; + +/* + * 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 com.opensymphony.xwork.Action; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.OrganisationInformation; +import org.apache.maven.archiva.web.action.AbstractWebworkTestCase; +import org.easymock.MockControl; + +/** + * @author James William Dumay + */ +public class EditOrganizationInfoActionTest extends AbstractOrganizationInfoActionTest +{ + public void testOrganisationInfoSaves() + throws Exception + { + config.setOrganisationInfo(new OrganisationInformation()); + OrganisationInformation orginfo = config.getOrganisationInfo(); + orginfo.setLogoLocation("LOGO"); + orginfo.setName("NAME"); + orginfo.setUrl("URL"); + + configuration.save(config); + + reloadAction(); + + action.prepare(); + + assertEquals("LOGO", action.getOrganisationLogo()); + assertEquals("NAME", action.getOrganisationName()); + assertEquals("URL", action.getOrganisationUrl()); + + action.setOrganisationLogo("LOGO1"); + action.setOrganisationName("NAME1"); + action.setOrganisationUrl("URL1"); + + action.execute(); + + assertEquals("LOGO1", orginfo.getLogoLocation()); + assertEquals("NAME1", orginfo.getName()); + assertEquals("URL1", orginfo.getUrl()); + } + + @Override + protected AbstractAppearanceAction getAction() + { + return (EditOrganisationInfoAction) lookup( Action.class.getName(), "editOrganisationInfo" ); + } +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java new file mode 100644 index 000000000..fec9e8f81 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java @@ -0,0 +1,58 @@ +package org.apache.maven.archiva.web.action.admin.appearance; + +/* + * 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 com.opensymphony.xwork.Action; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.OrganisationInformation; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.web.action.AbstractWebworkTestCase; + +/** + * @author James William Dumay + */ +public class OrganizationInfoActionTest extends AbstractOrganizationInfoActionTest +{ + public void testOrganisationInfoLoads() + throws Exception + { + config.setOrganisationInfo(new OrganisationInformation()); + OrganisationInformation orginfo = config.getOrganisationInfo(); + orginfo.setLogoLocation("LOGO"); + orginfo.setName("NAME"); + orginfo.setUrl("URL"); + + configuration.save(config); + + reloadAction(); + + action.prepare(); + + assertEquals("URL", action.getOrganisationUrl()); + assertEquals("NAME", action.getOrganisationName()); + assertEquals("LOGO", action.getOrganisationLogo()); + } + + @Override + protected AbstractAppearanceAction getAction() + { + return (OrganisationInfoAction) lookup( Action.class.getName(), "organisationInfo" ); + } +}