Returns the name of the restore space, if it exists, associated with a snapshot

@param request
@param snapshotId
@return
@throws ParseException
185970
@RequestMapping(value = "/spaces/snapshots/{storeId}/{snapshotId}/restore-space-id", method = RequestMethod.GET)
    @ResponseBody
    public String restoreSpaceId(HttpServletRequest request,
                                 @PathVariable("storeId") String storeId,
                                 @PathVariable("snapshotId") String snapshotId) throws Exception {
        ContentStore contentStore = getContentStore(storeId);

        String spaceId = SnapshotIdentifier.parseSnapshotId(snapshotId).getRestoreSpaceId();

        if (contentStore.spaceExists(spaceId)) {
            return "{ \"spaceId\": \"" + spaceId + "\"," + "\"storeId\": \"" + storeId + "\"}";
        } else {
            return "{}";
        }
    }
893895
public com.google.protobuf.ByteString
      getSnapshotNameBytes() {
    java.lang.Object ref = snapshotName_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      snapshotName_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
862261
protected String callBridge(RestHttpHelper restHelper,
                                String snapshotURL,
                                String snapshotBody) throws Exception {
        log.info("Making SNAPSHOT call to URL {} with body {}",
                 snapshotURL, snapshotBody);

        Map<String, String> headers = new HashMap<>();
        headers.put(HttpHeaders.CONTENT_TYPE, "application/json");
        RestHttpHelper.HttpResponse response = restHelper.put(snapshotURL, snapshotBody, headers);
        int statusCode = response.getStatusCode();
        if (statusCode != 200 && statusCode != 201) {
            String responseStr = response.getResponseBody();

            try {
                String m = getMessageValue(responseStr);
                if (m != null) {
                    responseStr = m;
                }
            } catch (IOException ex) {
                log.warn(ex.getMessage(), ex);
            }

            if (statusCode == 409) {
                throw new ServerConflictException(responseStr);
            } else {
                throw new RuntimeException(responseStr + " (" + statusCode + ")");
            }

        }
        return response.getResponseBody();
    }
1246504
@Override
    public Snapshot requestRestoreSnapshot(String snapshotId, DuracloudEndPointConfig destination, String userEmail)
        throws SnapshotException {

        checkInitialized();

        Snapshot snapshot = getSnapshot(snapshotId);

        String host = destination.getHost();
        String port = destination.getPort() + "";
        String storeId = destination.getStoreId();

        String url =
            "http"
            + (port.endsWith("443") ? "s" : "") + "://" + host + ":" + port + "/duradmin/spaces/sm/" + storeId + "/"
            + snapshotId + "?snapshot=true";
        // send email to DuraCloud team to request starting a restore
        String subject = "Snapshot Restoration Request for Snapshot ID = " + snapshotId;
        String format =
            "Please initiate a snapshot restore via the duracloud interface ( {0} ).\n"
            + "\nSnapshot ID: {1}\nHost:{2}\nPort: {3}\nStore ID: {4}\nRequestor email: {5}";
        String body = MessageFormat.format(format, url, snapshotId, host, port, storeId, userEmail);
        String[] duracloudEmailAddresses = this.config.getDuracloudEmailAddresses();
        notificationManager.sendNotification(NotificationType.EMAIL, subject, body, duracloudEmailAddresses);

        log.info("sent email to {}: message body = {}", duracloudEmailAddresses, body);

        return snapshot;
    }
686713
private MultipartParsingResult parseRequest(HttpRequest request) throws MultipartException {
        String encoding = determineEncoding(request);
        FileUpload fileUpload = prepareFileUpload(encoding);
        try {
            RequestBody body = request.getBody();
            Assert.notNull(body, "The body cannot be null.");
            List<FileItem> fileItems = fileUpload.parseRequest(new BodyContext(body));
            return parseFileItems(fileItems, encoding);
        } catch (FileUploadBase.SizeLimitExceededException ex) {
            throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
        } catch (FileUploadBase.FileSizeLimitExceededException ex) {
            throw new MaxUploadSizeExceededException(fileUpload.getFileSizeMax(), ex);
        } catch (FileUploadException ex) {
            throw new MultipartException("Failed to parse multipart servlet request.", ex);
        }
    }
729822
def restore_from_snapshot(self, volume_id, snapshot_id):
        

        return self.client.call('Network_Storage', 'restoreFromSnapshot',
                                snapshot_id, id=volume_id)
975180
@Override
    @Transactional
    public Restoration restartRestore(String restoreId) throws SnapshotException {
        Restoration restoration = this.jobManager.stopRestore(restoreId);
        restoration.setEndDate(null);
        restoration.setStatus(RestoreStatus.RETRIEVING_FROM_STORAGE);
        restoration = restoreRepo.save(restoration);
        eventLog.logRestoreUpdate(restoration);
        return this.restoreCompleted(restoration);
    }
67726
private static Object getSessionVar(HttpServletRequest request, ServletContext servletContext, String name)
    {
        StorageHandler sh = Handlers.get( servletContext ).getStorageHandler();

        HttpServletRequest unwrappedRequest = PageFlowUtils.unwrapMultipart( request );
        RequestContext rc = new RequestContext( unwrappedRequest, null );
        String attrName = ScopedServletUtils.getScopedSessionAttrName(name, unwrappedRequest);
        return sh.getAttribute( rc, attrName );
    }
10194
def _parse_snapshot_share(response, name):
    '''
    
    '''
    snapshot = response.headers.get('x-ms-snapshot')

    return _parse_share(response, name, snapshot)
748920
def delete_snapshot(self, snapshot_id):
        """"""
        query = self.query_factory(
            action="DeleteSnapshot", creds=self.creds, endpoint=self.endpoint,
            other_params={"SnapshotId": snapshot_id})
        d = query.submit()
        return d.addCallback(self.parser.truth_return)
1298078
private String parseLayerId(HttpServletRequest request) {
		StringTokenizer tokenizer = new StringTokenizer(request.getRequestURI(), "/");
		String token = "";
		while (tokenizer.hasMoreTokens()) {
			token = tokenizer.nextToken();
		}
		return token;
	}
847469
protected String getSnapshotIdFromProperties(String spaceId) {
        Properties props = new Properties();
        try (InputStream is = this.snapshotProvider.getContent(spaceId, Constants.SNAPSHOT_PROPS_FILENAME)
                                                   .getContentStream()) {
            props.load(is);
            return props.getProperty(Constants.SNAPSHOT_ID_PROP);
        } catch (NotFoundException ex) {
            return null;
        } catch (Exception e) {
            throw new TaskException(
                MessageFormat.format("Call to create snapshot failed, unable to determine existence of " +
                                     "snapshot properties file in {0}. Error: {1}", spaceId, e.getMessage()));
        }
    }
439701
public CompletableFuture<BackupResponse> backup(BackupRequest request) {
    ComposableFuture<BackupResponse> future = new ComposableFuture<>();
    threadContext.execute(() -> {
      role.backup(request).whenComplete(future);
    });
    return future;
  }
204664
public ListSnapshotsResponse listSnapshots(ListSnapshotsRequest request) {
        checkNotNull(request, "request should not be null.");
        InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, SNAPSHOT_PREFIX);
        if (!Strings.isNullOrEmpty(request.getMarker())) {
            internalRequest.addParameter("marker", request.getMarker());
        }
        if (request.getMaxKeys() > 0) {
            internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys()));
        }
        if (!Strings.isNullOrEmpty(request.getVolumeId())) {
            internalRequest.addParameter("volumeId", request.getVolumeId());
        }
        return invokeHttpClient(internalRequest, ListSnapshotsResponse.class);
    }
336447
@SuppressWarnings("unchecked")
    protected final <T extends AmazonWebServiceRequest> T beforeMarshalling(
            T request) {

        T local = request;
        for (RequestHandler2 handler : requestHandler2s) {
            local = (T) handler.beforeMarshalling(local);
        }
        return local;
    }
1008393
public GetSessionTokenResponse getSessionToken(GetSessionTokenRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        checkIsTrue(request.getDurationSeconds() > 0, "the durationSeconds parameter should be greater than zero");

        InternalRequest internalRequest = new InternalRequest(HttpMethodName.POST,
                HttpUtils.appendUri(this.getEndpoint(), URL_PREFIX, GET_SESSION_TOKEN_PATH));
        if (request.getDurationSeconds() != null) {
            internalRequest.addParameter("durationSeconds", String.valueOf(request.getDurationSeconds()));
        }
        internalRequest.setCredentials(request.getRequestCredentials());
        internalRequest.addHeader(Headers.CONTENT_LENGTH,
                String.valueOf(request.getAcl() == null ? 0 : request.getAcl().length()));
        internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json");
        if (request.getAcl() != null) {
            internalRequest.setContent(RestartableInputStream.wrap(request.getAcl().getBytes()));
        }
        return this.invokeHttpClient(internalRequest, GetSessionTokenResponse.class);
    }
137587
private HashMap<String, String> getPropertyFromRequest(
            HashMap<String, String> tokens, HttpServletRequest request) {
        // Iterate through all of the other property keys looking for the first property
        // named like propname that has a value in the request
        HashMap<String, String> retHash = new HashMap<>();

        for (Map.Entry<String, String> entry : tokens.entrySet()) {
            String contextName = entry.getKey();
            String parmName = entry.getValue();
            String parmValue;
            if (request.getAttribute(parmName) != null) {
                // Upstream components (like servlet filters) may supply information
                // for the authentication process using request attributes.
                try {
                    parmValue = (String) request.getAttribute(parmName);
                } catch (ClassCastException cce) {
                    String msg = "The request attribute '" + parmName + "' must be a String.";
                    throw new RuntimeException(msg, cce);
                }
            } else {
                // If a configured parameter isn't provided by a request attribute,
                // check request parameters (i.e. querystring, form fields).
                parmValue = request.getParameter(parmName);
            }
            // null value causes exception in context.authentication
            // alternately we could just not set parm if value is null
            if ("password".equals(parmName)) {
                // make sure we don't trim passwords, since they might have
                // leading or trailing spaces
                parmValue = (parmValue == null ? "" : parmValue);
            } else {
                parmValue = (parmValue == null ? "" : parmValue).trim();
            }

            // The relationship between the way the properties are stored and the way
            // the subcontexts are named has to be closely looked at to make this work.
            // The keys are either "root" or the subcontext name that follows "root.". As
            // as example, the contexts ["root", "root.simple", "root.cas"] are represented
            // as ["root", "simple", "cas"].
            String key = (contextName.startsWith("root.") ? contextName.substring(5) : contextName);
            retHash.put(key, parmValue);
        }
        return (retHash);
    }