@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { this.elementStack.push(localName); if (FileConstants.FILE_ELEMENT.equals(localName)) { this.name = Constants.EMPTY_STRING; this.fileProperties = new FileProperties(); } if (FileConstants.DIRECTORY_ELEMENT.equals(localName)) { this.name = Constants.EMPTY_STRING; this.directoryProperties = new FileDirectoryProperties(); } }
private void updatePropertiesFromResponse(HttpURLConnection request) { // ETag this.getProperties().setEtag(request.getHeaderField(Constants.HeaderConstants.ETAG)); // Last Modified if (0 != request.getLastModified()) { final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); lastModifiedCalendar.setTime(new Date(request.getLastModified())); this.getProperties().setLastModified(lastModifiedCalendar.getTime()); } }
/** * Gets the FileDirectoryAttributes from the given request. * * @param request * the request to get attributes from. * @param usePathStyleUris * a value indicating if the account is using pathSytleUris. * @return the FileDirectoryAttributes from the given request. * @throws StorageException */ public static FileDirectoryAttributes getFileDirectoryAttributes(final HttpURLConnection request, final boolean usePathStyleUris) throws StorageException { final FileDirectoryAttributes directoryAttributes = new FileDirectoryAttributes(); URI tempURI; try { tempURI = PathUtility.stripSingleURIQueryAndFragment(request.getURL().toURI()); } catch (final URISyntaxException e) { final StorageException wrappedUnexpectedException = Utility.generateNewUnexpectedStorageException(e); throw wrappedUnexpectedException; } directoryAttributes.setName(PathUtility.getDirectoryNameFromURI(tempURI, usePathStyleUris)); final FileDirectoryProperties directoryProperties = directoryAttributes.getProperties(); directoryProperties.setEtag(BaseResponse.getEtag(request)); directoryProperties.setLastModified(new Date(request.getLastModified())); directoryAttributes.setMetadata(getMetadata(request)); directoryProperties.setServerEncrypted( Constants.TRUE.equals(request.getHeaderField(Constants.HeaderConstants.SERVER_ENCRYPTED))); return directoryAttributes; }
assertNotNull(topDir1.getProperties().getEtag()); assertNotNull(topDir1.getProperties().getLastModified());
@Test public void testDirectoryAttributesEncryption() throws URISyntaxException, StorageException, IOException { assertFalse(this.dir.getProperties().isServerEncrypted()); CloudFileDirectory testDir = this.share.getRootDirectoryReference().getDirectoryReference("dir"); testDir.downloadAttributes(); assertTrue(testDir.getProperties().isServerEncrypted()); }
/** * Gets the FileDirectoryAttributes from the given request. * * @param request * the request to get attributes from. * @param usePathStyleUris * a value indicating if the account is using pathSytleUris. * @return the FileDirectoryAttributes from the given request. * @throws StorageException */ public static FileDirectoryAttributes getFileDirectoryAttributes(final HttpURLConnection request, final boolean usePathStyleUris) throws StorageException { final FileDirectoryAttributes directoryAttributes = new FileDirectoryAttributes(); URI tempURI; try { tempURI = PathUtility.stripSingleURIQueryAndFragment(request.getURL().toURI()); } catch (final URISyntaxException e) { final StorageException wrappedUnexpectedException = Utility.generateNewUnexpectedStorageException(e); throw wrappedUnexpectedException; } directoryAttributes.setName(PathUtility.getDirectoryNameFromURI(tempURI, usePathStyleUris)); final FileDirectoryProperties directoryProperties = directoryAttributes.getProperties(); directoryProperties.setEtag(BaseResponse.getEtag(request)); directoryProperties.setLastModified(new Date(request.getLastModified())); directoryAttributes.setMetadata(getMetadata(request)); directoryProperties.setServerEncrypted( Constants.TRUE.equals(request.getHeaderField(Constants.HeaderConstants.SERVER_ENCRYPTED))); return directoryAttributes; }
private void setProperties(String currentNode, String value) throws ParseException { // Called in both the file and the directory case. if (Constants.LAST_MODIFIED_ELEMENT.equals(currentNode)) { this.directoryProperties.setLastModified(Utility.parseRFC1123DateFromStringInGMT(value)); } else if (Constants.ETAG_ELEMENT.equals(currentNode)) { this.directoryProperties.setEtag(Utility.formatETag(value)); } else if (Constants.HeaderConstants.CONTENT_LENGTH.equals(currentNode)) { this.fileProperties.setLength(Long.parseLong(value)); } } }
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { this.elementStack.push(localName); if (FileConstants.FILE_ELEMENT.equals(localName)) { this.name = Constants.EMPTY_STRING; this.fileProperties = new FileProperties(); } if (FileConstants.DIRECTORY_ELEMENT.equals(localName)) { this.name = Constants.EMPTY_STRING; this.directoryProperties = new FileDirectoryProperties(); } }
private void setProperties(String currentNode, String value) throws ParseException { // Called in both the file and the directory case. if (Constants.LAST_MODIFIED_ELEMENT.equals(currentNode)) { this.directoryProperties.setLastModified(Utility.parseRFC1123DateFromStringInGMT(value)); } else if (Constants.ETAG_ELEMENT.equals(currentNode)) { this.directoryProperties.setEtag(Utility.formatETag(value)); } else if (Constants.HeaderConstants.CONTENT_LENGTH.equals(currentNode)) { this.fileProperties.setLength(Long.parseLong(value)); } } }
/** * Initializes a new instance of the FileDirectoryAttributes class */ public FileDirectoryAttributes() { this.setMetadata(new HashMap<String, String>()); this.setProperties(new FileDirectoryProperties()); }
private void updatePropertiesFromResponse(HttpURLConnection request) { // ETag this.getProperties().setEtag(request.getHeaderField(Constants.HeaderConstants.ETAG)); // Last Modified if (0 != request.getLastModified()) { final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); lastModifiedCalendar.setTime(new Date(request.getLastModified())); this.getProperties().setLastModified(lastModifiedCalendar.getTime()); } }
/** * Initializes a new instance of the FileDirectoryAttributes class */ public FileDirectoryAttributes() { this.setMetadata(new HashMap<String, String>()); this.setProperties(new FileDirectoryProperties()); }