Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Sonatype Nexus (TM) Open Source Version Copyright (c) 2007-2012 Sonatype, Inc. All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the Eclipse Foundation. All other trademarks are the property of their respective owners.
 
 package org.sonatype.nexus.rest.model;
 
 import  org.sonatype.plexus.rest.xstream.HtmlEscapeStringConverter;
 
 
 public class XStreamConfigurator
 {
     public static XStream configureXStreamXStream xstream )
     {
         // protect against XSS, escape HTML from input.
         xstream.registerConverternew HtmlEscapeStringConverter() );
 
         xstream.registerConverter(
             new RepositoryBaseResourceConverterxstream.getMapper(), xstream.getReflectionProvider() ),
             . );
         xstream.registerConverter(
             new RepositoryResourceResponseConverterxstream.getMapper(), xstream.getReflectionProvider() ),
             . ); // strips the class="class.name" attribute from
         // data
 
         xstream.registerConverter(
             new ScheduledServiceBaseResourceConverterxstream.getMapper(), xstream.getReflectionProvider() ),
             . );
         xstream.registerConverter(
             new ScheduledServicePropertyResourceConverterxstream.getMapper(), xstream.getReflectionProvider() ),
             . );
         xstream.registerConverter(
             new ScheduledServiceResourceResponseConverterxstream.getMapper(), xstream.getReflectionProvider() ),
             . ); // strips the class="class.name" attribute from
 
         // data
 
         // Maven POM
         xstream.alias"project"Model.class );
 
         xstream.processAnnotationsErrorReportResponse.class );
         xstream.processAnnotationsErrorReportRequest.class );
         xstream.processAnnotationsArtifactResolveResourceResponse.class );
         xstream.processAnnotationsGlobalConfigurationResourceResponse.class );
         xstream.processAnnotationsRepositoryStatusListResourceResponse.class );
         xstream.processAnnotationsRepositoryListResourceResponse.class );
         xstream.processAnnotationsRepositoryResourceResponse.class );
         xstream.processAnnotationsRepositoryStatusResourceResponse.class );
        xstream.processAnnotationsRepositoryMetaResourceResponse.class );
        xstream.processAnnotationsRepositoryGroupResourceResponse.class );
        xstream.processAnnotationsRepositoryRouteResourceResponse.class );
        xstream.processAnnotationsScheduledServiceResourceResponse.class );
        xstream.processAnnotationsContentListResourceResponse.class );
        xstream.processAnnotationsLogsListResourceResponse.class );
        xstream.processAnnotationsConfigurationsListResourceResponse.class );
        xstream.processAnnotationsFeedListResourceResponse.class );
        xstream.processAnnotationsNFCResourceResponse.class );
        xstream.processAnnotationsStatusResourceResponse.class );
        xstream.processAnnotationsWastebasketResourceResponse.class );
        xstream.processAnnotationsRepositoryTargetResourceResponse.class );
        xstream.processAnnotationsLogConfigResourceResponse.class );
        xstream.processAnnotationsMirrorResourceListResponse.class );
        xstream.processAnnotationsMirrorResourceListRequest.class );
        xstream.processAnnotationsMirrorStatusResourceListResponse.class );
        xstream.processAnnotationsSmtpSettingsResourceRequest.class );
        xstream.processAnnotationsPrivilegeResourceRequest.class );
        xstream.processAnnotationsMaven2ArtifactInfoResourceRespose.class );
        xstream.alias"nexus-error"ErrorResponse.class );
        xstream.alias"error"ErrorMessage.class );
        xstream.registerLocalConverterErrorResponse.class"errors"new AliasingListConverterErrorMessage.class,
            "error" ) );
        xstream.registerLocalConverterContentListResourceResponse.class"data"new AliasingListConverter(
            ContentListResource.class"content-item" ) );
        xstream.registerLocalConverterRepositoryListResourceResponse.class"data"new AliasingListConverter(
            RepositoryListResource.class"repositories-item" ) );
        xstream.registerLocalConverterNexusRepositoryTypeListResourceResponse.class"data",
            new AliasingListConverterNexusRepositoryTypeListResource.class"repositoryType" ) );
            RepositoryStatusListResource.class"repository-status-list-item" ) );
        xstream.registerLocalConverterRepositoryGroupListResource.class"repositories"new AliasingListConverter(
            RepositoryGroupMemberRepository.class"repo-group-member" ) );
        xstream.registerLocalConverterRepositoryGroupResource.class"repositories"new AliasingListConverter(
            RepositoryGroupMemberRepository.class"repo-group-member" ) );
            RepositoryGroupListResource.class"repo-group-list-item" ) );
            RepositoryRouteListResource.class"repo-routes-list-item" ) );
        xstream.registerLocalConverterRepositoryRouteListResource.class"repositories"new AliasingListConverter(
            RepositoryRouteMemberRepository.class"repo-routes-member" ) );
        xstream.registerLocalConverterRepositoryRouteResource.class"repositories"new AliasingListConverter(
            RepositoryRouteMemberRepository.class"repository" ) );
        xstream.registerLocalConverterGlobalConfigurationListResourceResponse.class"data",
            new AliasingListConverterGlobalConfigurationListResource.class"global-settings-list-item" ) );
        xstream.registerLocalConverterLogsListResourceResponse.class"data"new AliasingListConverter(
            LogsListResource.class"logs-list-item" ) );
            ConfigurationsListResource.class"configs-list-item" ) );
        xstream.registerLocalConverterFeedListResourceResponse.class"data"new AliasingListConverter(
            FeedListResource.class"feeds-list-item" ) );
        xstream.alias"authentication-login"AuthenticationLoginResourceResponse.class ); // Look at
        // NexusAuthenticationLoginResourceConverter,
        // we are only converting
        // the clientPermissions
        // field
        xstream.registerLocalConverterAuthenticationClientPermissions.class"permissions",
            new AliasingListConverterClientPermission.class"permission" ) );
        xstream.registerLocalConverterStatusConfigurationValidationResponse.class"validationErrors",
            new AliasingListConverterString.class"error" ) );
        xstream.registerLocalConverterStatusConfigurationValidationResponse.class"validationWarnings",
            new AliasingListConverterString.class"warning" ) );
        xstream.registerLocalConverterScheduledServiceBaseResource.class"properties"new AliasingListConverter(
            ScheduledServicePropertyResource.class"scheduled-task-property" ) );
        xstream.registerLocalConverterScheduledServiceWeeklyResource.class"recurringDay",
            new AliasingListConverterString.class"day" ) );
            ScheduledServiceTypeResource.class"schedule-type" ) );
        xstream.registerLocalConverterScheduledServiceTypeResource.class"formFields"new AliasingListConverter(
            FormFieldResource.class"form-field" ) );
            ScheduledServiceListResource.class"schedules-list-item" ) );
        xstream.aliasField"methods"PrivilegeResource.class"method" );
        xstream.registerLocalConverterNFCResource.class"nfcContents"new AliasingListConverter(
            NFCRepositoryResource.class"nfc-repo-info" ) );
        xstream.registerLocalConverterNFCRepositoryResource.class"nfcPaths"new AliasingListConverter(
            String.class"path" ) );
        xstream.registerLocalConverterRepositoryTargetResource.class"patterns"new AliasingListConverter(
            String.class"pattern" ) );
            RepositoryTargetListResource.class"repo-targets-list-item" ) );
            new AliasingListConverterRepositoryContentClassListResource.class"repo-content-classes-list-item" ) );
            PlexusComponentListResource.class"component" ) );
        xstream.registerLocalConverterMirrorResourceListRequest.class"data"new AliasingListConverter(
            MirrorResource.class"mirrorResource" ) );
        xstream.registerLocalConverterMirrorResourceListResponse.class"data"new AliasingListConverter(
            MirrorResource.class"mirrorResource" ) );
            MirrorStatusResource.class"mirrorResource" ) );
        xstream.registerLocalConverterContentListDescribeRequestResource.class"requestContext",
            new AliasingListConverterString.class"requestContextItem" ) );
        xstream.registerLocalConverterContentListDescribeResponseResource.class"appliedMappings",
            new AliasingListConverterString.class"appliedMappingItem" ) );
        xstream.registerLocalConverterContentListDescribeResponseResource.class"attributes",
            new AliasingListConverterString.class"attributeItem" ) );
        xstream.registerLocalConverterContentListDescribeResponseResource.class"processedRepositoriesList",
            new AliasingListConverterString.class"processedRepositoriesListItem" ) );
        xstream.registerLocalConverterContentListDescribeResponseResource.class"properties",
            new AliasingListConverterString.class"propertyItem" ) );
        xstream.registerLocalConverterContentListDescribeResponseResource.class"sources",
            new AliasingListConverterString.class"sourceItem" ) );
        xstream.registerLocalConverterRepositoryStatusResource.class"dependentRepos"new AliasingListConverter(
            RepositoryDependentStatusResource.class"dependentRepoItem" ) );
        xstream.registerLocalConverterGlobalConfigurationResource.class"securityRealms"new AliasingListConverter(
            String.class"securityRealmItem" ) );
        // Maven model
        xstream.omitFieldModel.class"modelEncoding" );
        xstream.omitFieldModelBase.class"modelEncoding" );
        xstream.omitFieldScm.class"modelEncoding" );
        // SECURITY below
        xstream.processAnnotationsUserResourceResponse.class );
        xstream.processAnnotationsUserListResourceResponse.class );
        xstream.processAnnotationsUserResourceRequest.class );
        xstream.processAnnotationsUserForgotPasswordRequest.class );
        xstream.processAnnotationsUserChangePasswordRequest.class );
        xstream.registerLocalConverterUserResource.class"roles"new AliasingListConverterString.class"role" ) );
        xstream.registerLocalConverterUserListResourceResponse.class"data"new AliasingListConverter(
            UserResource.class"users-list-item" ) );
        xstream.processAnnotationsRoleListResourceResponse.class );
        xstream.processAnnotationsRoleResource.class );
        xstream.processAnnotationsRoleResourceRequest.class );
        xstream.processAnnotationsRoleResourceResponse.class );
        xstream.registerLocalConverterRoleListResourceResponse.class"data"new AliasingListConverter(
            RoleResource.class"roles-list-item" ) );
        xstream.registerLocalConverterRoleResource.class"roles"new AliasingListConverterString.class"role" ) );
        xstream.registerLocalConverterRoleResource.class"privileges"new AliasingListConverterString.class,
            "privilege" ) );
        xstream.processAnnotationsPrivilegeListResourceResponse.class );
        xstream.processAnnotationsPrivilegeStatusResourceResponse.class );
        xstream.processAnnotationsPrivilegeTypeResourceResponse.class );
        xstream.registerLocalConverterPrivilegeListResourceResponse.class"data"new AliasingListConverter(
            PrivilegeStatusResource.class"privilege-item" ) );
        xstream.registerLocalConverterPrivilegeResource.class"method"new AliasingListConverterString.class,
            "method" ) );
        xstream.registerLocalConverterPrivilegeStatusResource.class"properties"new AliasingListConverter(
            PrivilegeProperty.class"privilege-property" ) );
        xstream.registerLocalConverterPrivilegeTypeResourceResponse.class"data"new AliasingListConverter(
            PrivilegeTypeResource.class"privilege-type" ) );
        xstream.registerLocalConverterPrivilegeTypeResource.class"properties"new AliasingListConverter(
            PrivilegeTypePropertyResource.class"privilege-type-property" ) );
        xstream.processAnnotationsUserToRoleResourceRequest.class );
        xstream.registerLocalConverterUserToRoleResource.class"roles"new AliasingListConverterString.class,
            "role" ) );
        xstream.processAnnotationsPlexusUserResourceResponse.class );
        xstream.registerLocalConverterPlexusUserResource.class"roles"new AliasingListConverter(
            PlexusRoleResource.class"plexus-role" ) );
        xstream.processAnnotationsPlexusRoleResource.class );
        xstream.processAnnotationsPlexusUserListResourceResponse.class );
        xstream.registerLocalConverterPlexusUserListResourceResponse.class"data"new AliasingListConverter(
            PlexusUserResource.class"plexus-user" ) );
        xstream.processAnnotationsExternalRoleMappingResource.class );
        xstream.registerLocalConverterExternalRoleMappingListResourceResponse.class"data",
            new AliasingListConverterExternalRoleMappingResource.class"mapping" ) );
        xstream.registerLocalConverterExternalRoleMappingResource.class"mappedRoles"new AliasingListConverter(
            PlexusRoleResource.class"plexus-role" ) );
        xstream.processAnnotationsPlexusRoleListResourceResponse.class );
        xstream.registerLocalConverterPlexusRoleListResourceResponse.class"data"new AliasingListConverter(
            PlexusRoleResource.class"plexus-role" ) );
            "data"new AliasingListConverterorg.sonatype.security.rest.model.PlexusComponentListResource.class,
                "component" ) );
        return xstream;
    }
New to GrepCode? Check out our FAQ X