protected Target getRestToNexusResource( RepositoryTargetResource resource ) throws ConfigurationException, PatternSyntaxException { ContentClass cc = getRepositoryTypeRegistry().getContentClasses().get( resource.getContentClass() ); if ( cc == null ) { throw new ConfigurationException( "Content class with ID=\"" + resource.getContentClass() + "\" does not exists!" ); } Target target = new Target( resource.getId(), resource.getName(), cc, resource.getPatterns() ); return target; }
@Override protected RepositoryTargetResource createSettings( final String id ) { final RepositoryTargetResource resource = new RepositoryTargetResource(); resource.setId( id ); return resource; }
@Override public RepositoryTarget addPattern( final String pattern ) { settings().addPattern( pattern ); return this; } }
protected RepositoryTargetResource getNexusToRestResource(Target target, Request request) { RepositoryTargetResource resource = new RepositoryTargetResource(); resource.setId(target.getId()); resource.setName(target.getName()); resource.setResourceURI(request.getResourceRef().getPath()); resource.setContentClass(target.getContentClass().getId()); List<String> patterns = new ArrayList<String>(target.getPatternTexts()); for (String pattern : patterns) { resource.addPattern(pattern); } return resource; }
RepositoryTargetResource target = new RepositoryTargetResource(); target.setContentClass("maven2"); target.setName(repositoryId + "-target"); target.addPattern("/some-pattern"); privReq.setMethod(Arrays.asList("create", "read", "update", "delete")); // pick and choose privReq.setName(repositoryId + "-priv"); privReq.setRepositoryTargetId(target.getId()); privReq.setType(TargetPrivilegeDescriptor.TYPE);
/** * Method addPattern * * @param string */ public void addPattern(String string) { if ( !(string instanceof String) ) { throw new ClassCastException( "RepositoryTargetResource.addPatterns(string) parameter must be instanceof " + String.class.getName() ); } getPatterns().add( string ); } //-- void addPattern(String)
public Response sendMessage( Method method, RepositoryTargetResource resource ) throws IOException { XStreamRepresentation representation = new XStreamRepresentation( xstream, "", mediaType ); String repoTargetId = ( resource.getId() == null ) ? "?undefined" : "/" + resource.getId(); String serviceURI = "service/local/repo_targets" + repoTargetId; RepositoryTargetResourceResponse requestResponse = new RepositoryTargetResourceResponse(); requestResponse.setData( resource ); // now set the payload representation.setPayload( requestResponse ); return RequestFacade.sendMessage( serviceURI, method, representation ); }
@Override public String name() { return settings().getName(); }
@Override public String contentClass() { return settings().getContentClass(); }
@Override public RepositoryTarget withName( final String name ) { settings().setName( name ); return this; }
@Override public RepositoryTarget withContentClass( final String cls ) { settings().setContentClass( cls ); return this; }
private RepositoryTargetResource otherDTO( final RepositoryTargetListResource resource ) { final RepositoryTargetResource targetResource = new RepositoryTargetResource(); try { BeanUtils.copyProperties( targetResource, resource ); } catch ( Exception e ) { Throwables.propagate( e ); } return targetResource; }
protected RepositoryTargetResource getNexusToRestResource( Target target, Request request ) { RepositoryTargetResource resource = new RepositoryTargetResource(); resource.setId( target.getId() ); resource.setName( target.getName() ); resource.setResourceURI( request.getResourceRef().getPath() ); resource.setContentClass( target.getContentClass().getId() ); List<String> patterns = new ArrayList<String>( target.getPatternTexts() ); for ( String pattern : patterns ) { resource.addPattern( pattern ); } return resource; }
/** * Method removePattern * * @param string */ public void removePattern(String string) { if ( !(string instanceof String) ) { throw new ClassCastException( "RepositoryTargetResource.removePatterns(string) parameter must be instanceof " + String.class.getName() ); } getPatterns().remove( string ); } //-- void removePattern(String)
private JerseyRepositoryTarget convert( @Nullable final RepositoryTargetResource resource ) { if ( resource == null ) { return null; } final JerseyRepositoryTarget privilege = new JerseyRepositoryTarget( getNexusClient(), resource.getId(), resource ); privilege.overwriteWith( resource ); return privilege; }
protected Target getRestToNexusResource(RepositoryTargetResource resource) throws ConfigurationException, PatternSyntaxException { ContentClass cc = getRepositoryTypeRegistry().getContentClasses().get(resource.getContentClass()); if (cc == null) { throw new ConfigurationException("Content class with ID=\"" + resource.getContentClass() + "\" does not exists!"); } Target target = new Target(resource.getId(), resource.getName(), cc, resource.getPatterns()); return target; }
@Override public List<String> patterns() { return settings().getPatterns(); }
/** * IMPORTANT: Make sure to release the Response in a finally block when you are done with it. */ public Response sendMessage(Method method, RepositoryTargetResource resource) throws IOException { XStreamRepresentation representation = new XStreamRepresentation(xstream, "", mediaType); String repoTargetId = (resource.getId() == null) ? "?undefined" : "/" + resource.getId(); String serviceURI = "service/local/repo_targets" + repoTargetId; RepositoryTargetResourceResponse requestResponse = new RepositoryTargetResourceResponse(); requestResponse.setData(resource); // now set the payload representation.setPayload(requestResponse); return RequestFacade.sendMessage(serviceURI, method, representation); }