/** * {@inheritDoc} * * @see org.modeshape.graph.property.basic.AbstractPath#resolve(org.modeshape.graph.property.Path) */ @Override public Path resolve( Path relativePath ) { CheckArg.isNotNull(relativePath, "relative path"); String msg = GraphI18n.unableToResolvePathRelativeToIdentifierPath.text(relativePath, this); throw new InvalidPathException(msg); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.PathFactory#createRelativePath(java.lang.Iterable) */ public Path createRelativePath( Iterable<Segment> segments ) { List<Segment> segmentsList = new LinkedList<Segment>(); for (Segment segment : segments) { if (segment == null) { CheckArg.containsNoNulls(segments, "segments"); } assert segment != null; if (segment.isIdentifier()) { throw new InvalidPathException( GraphI18n.unableToCreateRelativePathWithIdentifierSegment.text(segments.toString())); } segmentsList.add(segment); } if (segmentsList.isEmpty()) return BasicPath.EMPTY_RELATIVE; return new BasicPath(segmentsList, false); }
/** * {@inheritDoc} */ public Path createRelativePath( Segment... segments ) { if (segments == null || segments.length == 0) return BasicPath.EMPTY_RELATIVE; List<Segment> segmentsList = new ArrayList<Segment>(segments.length); for (Segment segment : segments) { if (segment == null) { CheckArg.containsNoNulls(segments, "segments"); } assert segment != null; if (segment.isIdentifier()) { throw new InvalidPathException( GraphI18n.unableToCreateRelativePathWithIdentifierSegment.text(segments.toString())); } segmentsList.add(segment); } return new BasicPath(segmentsList, false); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.PathFactory#create(org.modeshape.graph.property.Path, java.lang.Iterable) */ public Path create( Path parentPath, Iterable<Segment> segments ) { CheckArg.isNotNull(parentPath, "parent path"); if (parentPath.isIdentifier()) { throw new InvalidPathException(GraphI18n.unableToCreatePathBasedUponIdentifierPath.text(parentPath, segments.toString())); } List<Segment> segmentsList = new LinkedList<Segment>(); segmentsList.addAll(parentPath.getSegmentsList()); for (Segment segment : segments) { if (segment == null) { CheckArg.containsNoNulls(segments, "segments"); } assert segment != null; if (segment.isIdentifier()) { throw new InvalidPathException( GraphI18n.unableToCreatePathUsingIdentifierPathAndAnotherPath.text(parentPath, segments.toString())); } segmentsList.add(segment); } if (segmentsList.isEmpty()) return RootPath.INSTANCE; if (segmentsList.size() == 0) return new ChildPath(parentPath, segmentsList.get(0)); return new BasicPath(segmentsList, parentPath.isAbsolute()); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.Path#getCanonicalPath() */ public Path getCanonicalPath() { if (!this.isAbsolute()) { String msg = GraphI18n.pathIsNotAbsolute.text(this); throw new InvalidPathException(msg); } if (this.isNormalized()) return this; return this.getNormalizedPath(); }
CheckArg.isNotNull(subpath, "subpath"); if (parentPath.isIdentifier()) { throw new InvalidPathException(GraphI18n.unableToCreatePathBasedUponIdentifierPath.text(parentPath, subpath)); Path.Segment childSegment = createSegment(subpath); if (childSegment.isIdentifier()) { throw new InvalidPathException(GraphI18n.unableToCreatePathUsingIdentifierPathAndAnotherPath.text(parentPath, subpath));
if (segments.length == 1 && segments[0] != null) { if (parentPath.isIdentifier()) { throw new InvalidPathException(GraphI18n.unableToCreatePathBasedUponIdentifierPath.text(parentPath, segments.toString())); throw new InvalidPathException( GraphI18n.unableToCreatePathUsingIdentifierPathAndAnotherPath.text(parentPath, segments.toString())); throw new InvalidPathException( GraphI18n.unableToCreatePathUsingIdentifierPathAndAnotherPath.text(parentPath, segments.toString()));
/** * {@inheritDoc} */ public Path getNormalizedPath() { if (this.isNormalized()) return this; LinkedList<Segment> newSegments = new LinkedList<Segment>(); for (Segment segment : this) { if (segment.isSelfReference()) continue; if (segment.isParentReference()) { if (newSegments.isEmpty()) { if (this.isAbsolute()) { throw new InvalidPathException(CommonI18n.pathCannotBeNormalized.text(this)); } } else if (!newSegments.getLast().isParentReference()) { newSegments.removeLast(); continue; } } newSegments.add(segment); } if (newSegments.isEmpty()) { if (this.isAbsolute()) return RootPath.INSTANCE; // Otherwise relative and it had contained nothing but self references ... return SELF_PATH; } return new BasicPath(newSegments, this.isAbsolute()); }
@Test( expected = InvalidPathException.class ) public void shouldPropogateExceptionFromConnectorWhenDeleteLocationIsNotFound() { connection.error = new InvalidPathException(); graph.delete(validUuid); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.Path#getAncestor(int) */ public Path getAncestor( int degree ) { CheckArg.isNonNegative(degree, "degree"); if (degree == 0) { return this; } String msg = GraphI18n.pathAncestorDegreeIsInvalid.text(this.getString(), Inflector.getInstance().ordinalize(degree)); throw new InvalidPathException(msg); }
if (!this.isAbsolute()) { String msg = GraphI18n.pathIsNotAbsolute.text(this); throw new InvalidPathException(msg); throw new InvalidPathException(msg);
/** * {@inheritDoc} * * @see org.modeshape.graph.property.Path#getAncestor(int) */ public Path getAncestor( int degree ) { CheckArg.isNonNegative(degree, "degree"); if (degree == 0) { return this; } String msg = GraphI18n.pathAncestorDegreeIsInvalid.text(this.getString(), Inflector.getInstance().ordinalize(degree)); throw new InvalidPathException(msg); }
/** * {@inheritDoc} */ public Path getAncestor( int degree ) { CheckArg.isNonNegative(degree, "degree"); if (degree == 0) return this; int endIndex = this.segments.size() - degree; if (endIndex == 0) return this.isAbsolute() ? RootPath.INSTANCE : null; if (endIndex < 0) { String msg = GraphI18n.pathAncestorDegreeIsInvalid.text(this.getString(), Inflector.getInstance().ordinalize(degree)); throw new InvalidPathException(msg); } return subpath(0, endIndex); }
/** * {@inheritDoc} */ public Path resolve( Path relativePath ) { CheckArg.isNotNull(relativePath, "relative path"); if (!this.isAbsolute()) { String msg = GraphI18n.pathIsNotAbsolute.text(this); throw new InvalidPathException(msg); } if (relativePath.isAbsolute()) { String msg = GraphI18n.pathIsNotRelative.text(relativePath); throw new InvalidPathException(msg); } // If the relative path is the self or parent reference ... relativePath = relativePath.getNormalizedPath(); if (relativePath.size() == 1) { Segment onlySegment = relativePath.getSegment(0); if (onlySegment.isSelfReference()) return this; if (onlySegment.isParentReference()) return this.getParent(); } List<Segment> segments = new ArrayList<Segment>(this.size() + relativePath.size()); for (Segment segment : this) { segments.add(segment); } for (Segment segment : relativePath) { segments.add(segment); } return new BasicPath(segments, true).getNormalizedPath(); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.basic.AbstractPath#resolve(org.modeshape.graph.property.Path) */ @Override public Path resolve( Path relativePath ) { CheckArg.isNotNull(relativePath, "relative path"); if (relativePath.isAbsolute()) { String msg = GraphI18n.pathIsNotRelative.text(relativePath); throw new InvalidPathException(msg); } // Make an absolute path out of the supplied relative path ... return new BasicPath(relativePath.getSegmentsList(), true).getNormalizedPath(); }
@Test( expected = InvalidPathException.class ) public void shouldPropogateExceptionFromConnectorWhenCopyLocationIsNotFound() { connection.error = new InvalidPathException(); graph.copy(validUuid).into(validPath); }
@Test( expected = InvalidPathException.class ) public void shouldPropogateExceptionFromConnectorWhenMovingLocationIsNotFound() { connection.error = new InvalidPathException(); graph.move(validUuid).into(validPath); }