/** * Returns catalog object either from cached context or by using catalog instance. * @param extId * @param context * @return CatalogObject */ protected CatalogObject<String> getCatalogObject( LicenseEvaluatorContext<CatalogObject<String>> context) { if (context==null) { return null; } if (context.getStoredObjectContent()!=null) { return context.getStoredObjectContent(); } else if (context.getStoredObjectId()!=null) { getLogger().warn("no catalog object found in context, " + "using embedded catalog instance"); GetObjectRequest goReq = new GetObjectRequest(); goReq.setObject(new YaddaObjectID((String)context.getStoredObjectId())); GetObjectResponse<String> goResponse = catalog.getObject(goReq); if (goResponse!=null && goResponse.isOK()) { context.setStoredObjectContent(goResponse.getObject()); return goResponse.getObject(); } else { return null; } } else { return null; } }
/** * Adds public licence tag to catalog ID object. * @throws Exception */ @Override public void afterPropertiesSet() throws Exception { GetObjectRequest req = new GetObjectRequest(); YaddaObjectID yaddaId = new YaddaObjectID(ICatalog.ID_CATALOG_META); req.setObject(yaddaId); req.setOnlyMetadata(true); GetObjectResponse<String> objectResp = catalog.getObject(req); if (objectResp.isOK()) { if(skipLicenses) { return; } for (String tag : objectResp.getObject().getTags()) { if (tag.equals(SecurityConstants.TAG_PUBLIC_LICENSE)) { return; } } ExecuteRequest request = new ExecuteRequest(); EditorOperation operation = new TagOperation(yaddaId, new String[]{SecurityConstants.TAG_PUBLIC_LICENSE}, null); request.setOperation(operation); service.execute(request); } else { throw new EditorException("Unable to get catalog identifier object, reason: " + objectResp.getError().getMssg(), objectResp.getError().getException()); } }
@Override public GetObjectResponse<String> getObject(GetObjectRequest request) { GetObjectResponse<String> response = catalog.getObject(request); if(!response.isOK() || skipLicenses) return response;