Package org.sonatype.nexus.proxy.attributes

Examples of org.sonatype.nexus.proxy.attributes.DefaultAttributes


   * it "repacks" the deprecated fields as loaded by XStream (as back then XStream was used to serialize Item instances)
   * into new Attributes.
   */
  public void upgrade() {
    this.context = new RequestContext();
    this.itemAttributes = new DefaultAttributes();

    // this here is for ITs only, some of them use "manually crafter" attributes XML files and would NPE
    // In "real life", all the files stored in Nexus have at least sha1/md5 set as attributes, meaning,
    // all the real life items has at least two attributes and this map would never be null!
    if (attributes != null) {
View Full Code Here


   * @deprecated This constructor is here for legacy reasons, do not use it!
   */
  @Deprecated
  private AbstractStorageItem() {
    this.context = new RequestContext();
    this.itemAttributes = new DefaultAttributes();
  }
View Full Code Here

    try {
      final Map<String, String> attributesMap =
          objectMapper.readValue(inputStream, new TypeReference<Map<String, String>>()
          {
          });
      return new DefaultAttributes(attributesMap);
    }
    catch (JsonProcessingException e) {
      throw new InvalidInputException("Persisted attribute malformed!", e);
    }
    catch (CharConversionException e) {
View Full Code Here

  protected void doTestSimpleRoundtrip(final Marshaller marshaller)
      throws IOException
  {
    // simple roundtrip
    final Attributes attributes1 = new DefaultAttributes();
    attributes1.put("foo", "fooVal");
    attributes1.put("bar", "barVal");
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    marshaller.marshal(attributes1, bos);
    final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    final Attributes attributes2 = marshaller.unmarshal(bis);
    // size same
    assertThat(attributes2.asMap().size(), equalTo(attributes1.asMap().size()));
    // as maps are equal
    assertThat(attributes2.asMap(), equalTo(attributes1.asMap()));
    // but we deal with two different instances
    assertThat(System.identityHashCode(attributes2), not(equalTo(System.identityHashCode(attributes1))));
  }
View Full Code Here

  protected void doTestUnparseableRoundtrip(final Marshaller marshaller)
      throws IOException
  {
    // simple roundtrip
    final Attributes attributes1 = new DefaultAttributes();
    attributes1.put("foo", "fooVal");
    attributes1.put("bar", "barVal");
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    marshaller.marshal(attributes1, bos);

    // break the data
    final byte[] data = bos.toByteArray();
View Full Code Here

  public void setup() {
    when(repository.getId()).thenReturn("test");
    when(repository.getName()).thenReturn("test");
    when(storageFileItem.getItemContext()).thenReturn(new RequestContext());
    when(storageFileItem.getRepositoryItemUid()).thenReturn(repositoryItemUid);
    when(storageFileItem.getRepositoryItemAttributes()).thenReturn(new DefaultAttributes());
    when(storageFileItem.getResourceStoreRequest()).thenReturn(new ResourceStoreRequest("blah"));
    when(repositoryItemUid.getRepository()).thenReturn(repository);
  }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.attributes.DefaultAttributes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.