Package org.sonatype.nexus.rest.model

Examples of org.sonatype.nexus.rest.model.ContentListDescribeResponseResource


  protected ContentListDescribeResponseResource describeResponse(Context context, Request req, Response res,
                                                                 Variant variant, ResourceStoreRequest request,
                                                                 StorageItem item, Throwable e)
  {
    ContentListDescribeResponseResource result = new ContentListDescribeResponseResource();

    result.getProcessedRepositoriesList().addAll(request.getProcessedRepositories());

    // applied mappings
    for (Map.Entry<String, List<String>> mappingEntry : request.getAppliedMappings().entrySet()) {
      result.addAppliedMapping(mappingEntry.getKey() + " repository applied " + mappingEntry.getValue());
    }

    if (item == null) {
      result.setResponseType("NOT_FOUND");

      if (e != null) {
        result.addNotFoundReasoning(buildNotFoundReasoning(null, e));
      }

      return result;
    }

    if (item instanceof StorageFileItem) {
      result.setResponseType("FILE");

    }
    else if (item instanceof StorageCollectionItem) {
      result.setResponseType("COLL");

    }
    else if (item instanceof StorageLinkItem) {
      result.setResponseType("LINK");
    }
    else {
      result.setResponseType(item.getClass().getName());
    }

    result.setResponseActualClass(item.getClass().getName());

    result.setResponsePath(item.getPath());

    if (!item.isVirtual()) {
      result.setResponseUid(item.getRepositoryItemUid().toString());

      result.setOriginatingRepositoryId(item.getRepositoryItemUid().getRepository().getId());

      result.setOriginatingRepositoryName(item.getRepositoryItemUid().getRepository().getName());

      result.setOriginatingRepositoryMainFacet(
          item.getRepositoryItemUid().getRepository().getRepositoryKind().getMainFacet().getName());
    }
    else {
      result.setResponseUid("virtual");
    }

    // properties
    result.addProperty("created=" + item.getCreated());
    result.addProperty("modified=" + item.getModified());
    result.addProperty("lastRequested=" + item.getLastRequested());
    result.addProperty("remoteChecked=" + item.getRemoteChecked());
    result.addProperty("remoteUrl=" + item.getRemoteUrl());
    result.addProperty("storedLocally=" + item.getStoredLocally());
    result.addProperty("isExpired=" + item.isExpired());
    result.addProperty("readable=" + item.isReadable());
    result.addProperty("writable=" + item.isWritable());
    result.addProperty("virtual=" + item.isVirtual());

    // attributes
    final TreeMap<String, String> sortedAttributes = Maps.newTreeMap();
    sortedAttributes.putAll(item.getRepositoryItemAttributes().asMap());
    for (Map.Entry<String, String> entry : sortedAttributes.entrySet()) {
      result.addAttribute(entry.toString());
    }

    // sources
    if (item instanceof StorageCompositeItem) {
      StorageCompositeItem composite = (StorageCompositeItem) item;
      for (StorageItem source : composite.getSources()) {
        if (!source.isVirtual()) {
          result.addSource(source.getRepositoryItemUid().toString());
        }
        else {
          result.addSource(source.getPath());
        }
      }
    }

    return result;
View Full Code Here


    requestRes.setRequestPath("requestpath");
    requestRes.setRequestUrl("requestUrl");

    resource.setRequest(requestRes);

    ContentListDescribeResponseResource responseRes = new ContentListDescribeResponseResource();
    // TODO: Figure out why this is causing test to fail.
    // responseRes.setAppliedMappings( Arrays.asList( "map1", "map2" ) );
    // TODO: Figure out why this is causing test to fail.
    // responseRes.setAttributes( Arrays.asList( "attr1", "attr2" ) );
    responseRes.setOriginatingRepositoryId("originatingRepoId");
    responseRes.setOriginatingRepositoryMainFacet("mainfacet");
    responseRes.setOriginatingRepositoryName("name");
    // TODO: Figure out why this is causing test to fail.
    // responseRes.setProcessedRepositoriesList( Arrays.asList( "proc1", "proc2" ) );
    // TODO: Figure out why this is causing test to fail.
    // responseRes.setProperties( Arrays.asList( "prop1", "prop2" ) );
    responseRes.setResponseActualClass("actualclass");
    responseRes.setResponsePath("responsepath");
    responseRes.setResponseType("responseType");
    responseRes.setResponseUid("responseuid");
    // TODO: Figure out why this is causing test to fail.
    // responseRes.setSources( Arrays.asList( "source1", "source2" ) );

    resource.setResponse(responseRes);
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.rest.model.ContentListDescribeResponseResource

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.