Java Code Examples for org.apache.atlas.AtlasErrorCode#BAD_REQUEST
The following examples show how to use
org.apache.atlas.AtlasErrorCode#BAD_REQUEST .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GlossaryService.java From atlas with Apache License 2.0 | 6 votes |
@GraphTransaction public AtlasGlossaryTerm getTerm(String termGuid) throws AtlasBaseException { if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.getTerm({})", termGuid); } if (Objects.isNull(termGuid)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "termGuid is null/empty"); } AtlasGlossaryTerm atlasGlossary = getAtlasGlossaryTermSkeleton(termGuid); AtlasGlossaryTerm ret = dataAccess.load(atlasGlossary); setInfoForRelations(ret); if (DEBUG_ENABLED) { LOG.debug("<== GlossaryService.getTerm() : {}", ret); } return ret; }
Example 2
Source File: GlossaryService.java From atlas with Apache License 2.0 | 6 votes |
@GraphTransaction public List<AtlasGlossaryTerm> getGlossaryTerms(String glossaryGuid, int offset, int limit, SortOrder sortOrder) throws AtlasBaseException { if (Objects.isNull(glossaryGuid)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "glossaryGuid is null/empty"); } if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.getGlossaryTerms({}, {}, {}, {})", glossaryGuid, offset, limit, sortOrder); } List<AtlasGlossaryTerm> ret = new ArrayList<>(); List<AtlasRelatedTermHeader> termHeaders = getGlossaryTermsHeaders(glossaryGuid, offset, limit, sortOrder); for (AtlasRelatedTermHeader header : termHeaders) { ret.add(dataAccess.load(getAtlasGlossaryTermSkeleton(header.getTermGuid()))); } if (DEBUG_ENABLED) { LOG.debug("<== GlossaryService.getGlossaryTerms() : {}", ret); } return ret; }
Example 3
Source File: EntityREST.java From atlas with Apache License 2.0 | 6 votes |
@GET @Path("bulk/headers") @Produces(Servlets.JSON_MEDIA_TYPE) public AtlasEntityHeaders getEntityHeaders(@QueryParam("tagUpdateStartTime") long tagUpdateStartTime) throws AtlasBaseException { AtlasPerfTracer perf = null; try { long tagUpdateEndTime = System.currentTimeMillis(); if (tagUpdateStartTime > tagUpdateEndTime) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "fromTimestamp should be less than toTimestamp"); } if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getEntityHeaders(" + tagUpdateStartTime + ", " + tagUpdateEndTime + ")"); } ClassificationAssociator.Retriever associator = new ClassificationAssociator.Retriever(typeRegistry, auditRepository); return associator.get(tagUpdateStartTime, tagUpdateEndTime); } finally { AtlasPerfTracer.log(perf); } }
Example 4
Source File: EntityLineageService.java From atlas with Apache License 2.0 | 6 votes |
@Override @GraphTransaction public SchemaDetails getSchemaForHiveTableByName(final String datasetName) throws AtlasBaseException { if (StringUtils.isEmpty(datasetName)) { // TODO: Complete error handling here throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST); } AtlasEntityType hive_table = atlasTypeRegistry.getEntityTypeByName("hive_table"); Map<String, Object> lookupAttributes = new HashMap<>(); lookupAttributes.put("qualifiedName", datasetName); String guid = AtlasGraphUtilsV2.getGuidByUniqueAttributes(hive_table, lookupAttributes); return getSchemaForHiveTableByGuid(guid); }
Example 5
Source File: GlossaryService.java From atlas with Apache License 2.0 | 5 votes |
@GraphTransaction public AtlasGlossary updateGlossary(AtlasGlossary atlasGlossary) throws AtlasBaseException { if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.updateGlossary({})", atlasGlossary); } if (Objects.isNull(atlasGlossary)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Glossary is null/empty"); } if (StringUtils.isEmpty(atlasGlossary.getName())) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "DisplayName can't be null/empty"); } if (isNameInvalid(atlasGlossary.getName())) { throw new AtlasBaseException(AtlasErrorCode.INVALID_DISPLAY_NAME); } AtlasGlossary storeObject = dataAccess.load(atlasGlossary); if (!storeObject.equals(atlasGlossary)) { atlasGlossary.setGuid(storeObject.getGuid()); atlasGlossary.setQualifiedName(storeObject.getQualifiedName()); storeObject = dataAccess.save(atlasGlossary); setInfoForRelations(storeObject); } if (DEBUG_ENABLED) { LOG.debug("<== GlossaryService.updateGlossary() : {}", storeObject); } return storeObject; }
Example 6
Source File: AtlasTypeDefGraphStore.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Override @GraphTransaction public AtlasTypesDef updateTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasTypeDefGraphStore.updateTypesDef(enums={}, structs={}, classfications={}, entities={}, relationships{})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs()), CollectionUtils.size(typesDef.getRelationshipDefs())); } AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit(); // Translate any NOT FOUND errors to BAD REQUEST try { ttr.updateTypes(typesDef); } catch (AtlasBaseException e) { if (AtlasErrorCode.TYPE_NAME_NOT_FOUND == e.getAtlasErrorCode()) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, e.getMessage()); } else { throw e; } } AtlasTypesDef ret = updateGraphStore(typesDef, ttr); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasTypeDefGraphStore.updateTypesDef(enums={}, structs={}, classfications={}, entities={}, relationships={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs()), CollectionUtils.size(typesDef.getRelationshipDefs())); } return ret; }
Example 7
Source File: AtlasTypeDefGraphStore.java From incubator-atlas with Apache License 2.0 | 5 votes |
private void tryTypeCreation(AtlasTypesDef typesDef, AtlasTransientTypeRegistry ttr) throws AtlasBaseException { // Translate any NOT FOUND errors to BAD REQUEST try { ttr.addTypes(typesDef); } catch (AtlasBaseException e) { if (AtlasErrorCode.TYPE_NAME_NOT_FOUND == e.getAtlasErrorCode() || AtlasErrorCode.TYPE_GUID_NOT_FOUND == e.getAtlasErrorCode()) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, e.getMessage()); } else { throw e; } } }
Example 8
Source File: GlossaryService.java From atlas with Apache License 2.0 | 5 votes |
@GraphTransaction public void deleteTerm(String termGuid) throws AtlasBaseException { if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.deleteTerm({})", termGuid); } if (Objects.isNull(termGuid)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "termGuid is null/empty"); } AtlasGlossaryTerm storeObject = dataAccess.load(getAtlasGlossaryTermSkeleton(termGuid)); // Term can't be deleted if it is assigned to any entity if (CollectionUtils.isNotEmpty(storeObject.getAssignedEntities())) { throw new AtlasBaseException(AtlasErrorCode.TERM_HAS_ENTITY_ASSOCIATION, storeObject.getGuid(), String.valueOf(storeObject.getAssignedEntities().size())); } // Remove term from Glossary glossaryTermUtils.processTermRelations(storeObject, storeObject, GlossaryUtils.RelationshipOperation.DELETE); // Now delete the term dataAccess.delete(termGuid); if (DEBUG_ENABLED) { LOG.debug("<== GlossaryService.deleteTerm()"); } }
Example 9
Source File: AtlasTypeDefGraphStore.java From atlas with Apache License 2.0 | 5 votes |
private void tryUpdateByGUID(String guid, AtlasBaseTypeDef typeDef, AtlasTransientTypeRegistry ttr) throws AtlasBaseException { try { ttr.updateTypeByGuid(guid, typeDef); } catch (AtlasBaseException e) { if (AtlasErrorCode.TYPE_GUID_NOT_FOUND == e.getAtlasErrorCode()) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, e.getMessage()); } else { throw e; } } }
Example 10
Source File: AtlasTypeDefGraphStore.java From atlas with Apache License 2.0 | 5 votes |
private void tryUpdateByName(String name, AtlasBaseTypeDef typeDef, AtlasTransientTypeRegistry ttr) throws AtlasBaseException { try { ttr.updateTypeByName(name, typeDef); } catch (AtlasBaseException e) { if (AtlasErrorCode.TYPE_NAME_NOT_FOUND == e.getAtlasErrorCode()) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, e.getMessage()); } else { throw e; } } }
Example 11
Source File: GlossaryService.java From atlas with Apache License 2.0 | 5 votes |
@GraphTransaction public Map<String, List<AtlasRelatedCategoryHeader>> getRelatedCategories(String categoryGuid, int offset, int limit, SortOrder sortOrder) throws AtlasBaseException { if (Objects.isNull(categoryGuid)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "categoryGuid is null/empty"); } if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.getRelatedCategories({}, {}, {}, {})", categoryGuid, offset, limit, sortOrder); } AtlasGlossaryCategory glossaryCategory = getCategory(categoryGuid); Map<String, List<AtlasRelatedCategoryHeader>> ret = new HashMap<>(); if (glossaryCategory.getParentCategory() != null) { ret.put("parent", new ArrayList<AtlasRelatedCategoryHeader>() {{ add(glossaryCategory.getParentCategory()); }}); } if (CollectionUtils.isNotEmpty(glossaryCategory.getChildrenCategories())) { ret.put("children", new ArrayList<>(glossaryCategory.getChildrenCategories())); } if (DEBUG_ENABLED) { LOG.debug("<== GlossaryService.getRelatedCategories() : {}", ret); } return ret; }
Example 12
Source File: EntityDiscoveryService.java From atlas with Apache License 2.0 | 5 votes |
@Override public AtlasUserSavedSearch getSavedSearchByName(String currentUser, String userName, String searchName) throws AtlasBaseException { try { if (StringUtils.isEmpty(userName)) { userName = currentUser; } else if (!StringUtils.equals(currentUser, userName)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "invalid data"); } return userProfileService.getSavedSearch(userName, searchName); } catch (AtlasBaseException e) { LOG.error("getSavedSearchByName({}, {})", userName, searchName, e); throw e; } }
Example 13
Source File: EntityDiscoveryService.java From atlas with Apache License 2.0 | 5 votes |
@Override public List<AtlasUserSavedSearch> getSavedSearches(String currentUser, String userName) throws AtlasBaseException { try { if (StringUtils.isEmpty(userName)) { userName = currentUser; } else if (!StringUtils.equals(currentUser, userName)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "invalid data"); } return userProfileService.getSavedSearches(userName); } catch (AtlasBaseException e) { LOG.error("getSavedSearches({})", userName, e); throw e; } }
Example 14
Source File: DiscoveryREST.java From atlas with Apache License 2.0 | 5 votes |
/** * Attribute based search for entities satisfying the search parameters *@return Atlas search result * @throws AtlasBaseException * @HTTP 200 On successful search * @HTTP 400 Entity/attribute doesn't exist or entity filter is present without type name */ @Path("/quick") @POST public AtlasQuickSearchResult quickSearch(QuickSearchParameters quickSearchParameters) throws AtlasBaseException { AtlasPerfTracer perf = null; try { if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DiscoveryREST.searchWithParameters(" + quickSearchParameters + ")"); } if (quickSearchParameters.getLimit() < 0 || quickSearchParameters.getOffset() < 0) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Limit/offset should be non-negative"); } if (StringUtils.isEmpty(quickSearchParameters.getTypeName()) && !isEmpty(quickSearchParameters.getEntityFilters())) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "EntityFilters specified without Type name"); } if (StringUtils.isEmpty(quickSearchParameters.getTypeName()) && StringUtils.isEmpty(quickSearchParameters.getQuery())){ throw new AtlasBaseException(AtlasErrorCode.INVALID_SEARCH_PARAMS); } validateSearchParameters(quickSearchParameters); return discoveryService.quickSearch(quickSearchParameters); } finally { AtlasPerfTracer.log(perf); } }
Example 15
Source File: GlossaryREST.java From atlas with Apache License 2.0 | 5 votes |
/** * Partially update the glossary category * @param categoryGuid unique identifier for glossary term * @param partialUpdates Map containing keys as attribute names and values as corresponding attribute values * @return Updated glossary category * @throws AtlasBaseException * @HTTP 200 If glossary category partial update was successful * @HTTP 404 If glossary category guid in invalid * @HTTP 400 If category attributes are invalid */ @PUT @Path("/category/{categoryGuid}/partial") public AtlasGlossaryCategory partialUpdateGlossaryCategory(@PathParam("categoryGuid") String categoryGuid, Map<String, String> partialUpdates) throws AtlasBaseException { Servlets.validateQueryParamLength("categoryGuid", categoryGuid); AtlasPerfTracer perf = null; try { if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.partialUpdateGlossaryCategory()"); } if (MapUtils.isEmpty(partialUpdates)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "PartialUpdates missing or empty"); } AtlasGlossaryCategory glossaryCategory = glossaryService.getCategory(categoryGuid); for (Map.Entry<String, String> entry : partialUpdates.entrySet()) { try { glossaryCategory.setAttribute(entry.getKey(), entry.getValue()); } catch (IllegalArgumentException e) { throw new AtlasBaseException(AtlasErrorCode.INVALID_PARTIAL_UPDATE_ATTR, "Glossary Category", entry.getKey()); } } return glossaryService.updateCategory(glossaryCategory); } finally { AtlasPerfTracer.log(perf); } }
Example 16
Source File: GlossaryService.java From atlas with Apache License 2.0 | 5 votes |
@GraphTransaction public List<AtlasRelatedTermHeader> getGlossaryTermsHeaders(String glossaryGuid, int offset, int limit, SortOrder sortOrder) throws AtlasBaseException { if (Objects.isNull(glossaryGuid)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "glossaryGuid is null/empty"); } if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.getGlossaryTermsHeaders({}, {}, {}, {})", glossaryGuid, offset, limit, sortOrder); } AtlasGlossary glossary = getGlossary(glossaryGuid); List<AtlasRelatedTermHeader> ret; if (CollectionUtils.isNotEmpty(glossary.getTerms())) { List<AtlasRelatedTermHeader> terms = new ArrayList<>(glossary.getTerms()); if (sortOrder != null) { terms.sort((o1, o2) -> sortOrder == SortOrder.ASCENDING ? o1.getDisplayText().compareTo(o2.getDisplayText()) : o2.getDisplayText().compareTo(o1.getDisplayText())); } ret = new PaginationHelper<>(terms, offset, limit).getPaginatedList(); } else { ret = Collections.emptyList(); } if (DEBUG_ENABLED) { LOG.debug("<== GlossaryService.getGlossaryTermsHeaders() : {}", ret); } return ret; }
Example 17
Source File: GlossaryService.java From atlas with Apache License 2.0 | 5 votes |
@GraphTransaction public List<AtlasRelatedCategoryHeader> getGlossaryCategoriesHeaders(String glossaryGuid, int offset, int limit, SortOrder sortOrder) throws AtlasBaseException { if (Objects.isNull(glossaryGuid)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "glossaryGuid is null/empty"); } if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.getGlossaryCategoriesHeaders({}, {}, {}, {})", glossaryGuid, offset, limit, sortOrder); } List<AtlasRelatedCategoryHeader> ret; AtlasGlossary glossary = getGlossary(glossaryGuid); if (CollectionUtils.isNotEmpty(glossary.getCategories())) { List<AtlasRelatedCategoryHeader> categories = new ArrayList<>(glossary.getCategories()); if (sortOrder != null) { categories.sort((o1, o2) -> sortOrder == SortOrder.ASCENDING ? o1.getDisplayText().compareTo(o2.getDisplayText()) : o2.getDisplayText().compareTo(o1.getDisplayText())); } ret = new PaginationHelper<>(categories, offset, limit).getPaginatedList(); } else { ret = Collections.emptyList(); } if (DEBUG_ENABLED) { LOG.debug("<== GlossaryService.getGlossaryCategoriesHeaders() : {}", ret); } return ret; }
Example 18
Source File: EntityDiscoveryService.java From atlas with Apache License 2.0 | 4 votes |
private void checkSavedSearchOwnership(String claimedOwner, AtlasUserSavedSearch savedSearch) throws AtlasBaseException { // block attempt to delete another user's saved-search if (savedSearch != null && !StringUtils.equals(savedSearch.getOwnerName(), claimedOwner)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "invalid data"); } }
Example 19
Source File: GlossaryService.java From atlas with Apache License 2.0 | 4 votes |
@GraphTransaction public AtlasGlossaryCategory updateCategory(AtlasGlossaryCategory glossaryCategory) throws AtlasBaseException { if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.updateCategory({})", glossaryCategory); } if (Objects.isNull(glossaryCategory)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "GlossaryCategory is null/empty"); } if (StringUtils.isEmpty(glossaryCategory.getName())) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "DisplayName can't be null/empty"); } if (isNameInvalid(glossaryCategory.getName())) { throw new AtlasBaseException(AtlasErrorCode.INVALID_DISPLAY_NAME); } AtlasGlossaryCategory storeObject = dataAccess.load(glossaryCategory); if (!storeObject.equals(glossaryCategory)) { try { glossaryCategory.setGuid(storeObject.getGuid()); glossaryCategory.setQualifiedName(storeObject.getQualifiedName()); storeObject = dataAccess.save(glossaryCategory); } catch (AtlasBaseException e) { LOG.debug("No immediate attribute update. Exception: {}", e.getMessage()); } Map<String, AtlasGlossaryCategory> impactedCategories = glossaryCategoryUtils.processCategoryRelations(storeObject, glossaryCategory, GlossaryUtils.RelationshipOperation.UPDATE); // Since the current category is also affected, we need to update qualifiedName and save again if (StringUtils.equals(glossaryCategory.getQualifiedName(), storeObject.getQualifiedName())) { storeObject = dataAccess.load(glossaryCategory); } else { glossaryCategory.setQualifiedName(storeObject.getQualifiedName()); if (categoryExists(glossaryCategory)) { throw new AtlasBaseException(AtlasErrorCode.GLOSSARY_CATEGORY_ALREADY_EXISTS, glossaryCategory.getQualifiedName()); } storeObject = dataAccess.save(glossaryCategory); } dataAccess.save(impactedCategories.values()); } if (DEBUG_ENABLED) { LOG.debug("<== GlossaryService.updateCategory() : {}", storeObject); } setInfoForRelations(storeObject); return storeObject; }
Example 20
Source File: GlossaryService.java From atlas with Apache License 2.0 | 4 votes |
/** * Get specific glossary * * @param glossaryGuid unique identifier * @return Glossary corresponding to specified glossaryGuid * @throws AtlasBaseException */ @GraphTransaction public AtlasGlossary.AtlasGlossaryExtInfo getDetailedGlossary(String glossaryGuid) throws AtlasBaseException { if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.getGlossary({})", glossaryGuid); } if (Objects.isNull(glossaryGuid)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "glossaryGuid is null/empty"); } AtlasGlossary atlasGlossary = getGlossarySkeleton(glossaryGuid); AtlasGlossary glossary = dataAccess.load(atlasGlossary); AtlasGlossary.AtlasGlossaryExtInfo ret = new AtlasGlossary.AtlasGlossaryExtInfo(glossary); // Load all linked terms if (CollectionUtils.isNotEmpty(ret.getTerms())) { List<AtlasGlossaryTerm> termsToLoad = ret.getTerms() .stream() .map(id -> getAtlasGlossaryTermSkeleton(id.getTermGuid())) .collect(Collectors.toList()); Iterable<AtlasGlossaryTerm> glossaryTerms = dataAccess.load(termsToLoad); glossaryTerms.forEach(ret::addTermInfo); } // Load all linked categories if (CollectionUtils.isNotEmpty(ret.getCategories())) { List<AtlasGlossaryCategory> categoriesToLoad = ret.getCategories() .stream() .map(id -> getAtlasGlossaryCategorySkeleton(id.getCategoryGuid())) .collect(Collectors.toList()); Iterable<AtlasGlossaryCategory> glossaryCategories = dataAccess.load(categoriesToLoad); glossaryCategories.forEach(ret::addCategoryInfo); } if (DEBUG_ENABLED) { LOG.debug("<== GlossaryService.getGlossary() : {}", ret); } return ret; }