@Override public boolean equals(Object arg0) { // TODO add support for checking authHeader if (this == arg0) { return true; } if (arg0 == null) { return false; } if (this.getClass() == arg0.getClass()) { GetObjectRequest goReq0 = (GetObjectRequest)arg0; if (this.isOnlyMetadata()!=goReq0.isOnlyMetadata()) { return false; } if (this.getObject()==null) { if (goReq0.getObject()!=null) { return false; } } else { if (!this.getObject().equals(goReq0.getObject())) { return false; } } return true; } else { return false; } } }
/** * 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 GetPartResponse<String> getPart(GetPartRequest request) { GetObjectRequest oReq = new GetObjectRequest(); oReq.setObject(request.getObject()); SAMLObject[] samlObjects = securityRequestHandler.extract(request); securityRequestHandler.attach(oReq, samlObjects); GetObjectResponse<String> oResp = this.getObject(oReq); if(!oResp.isOK()) { GetPartResponse<String> resp = new GetPartResponse<String>(); resp.setError(oResp.getError()); return resp; } else { return catalog.getPart(request); } }
/** * 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; } }
@Override public GetObjectResponse<String> getObject(GetObjectRequest request) { GetObjectResponse<String> resp = new GetObjectResponse<String>(); try { CatalogObject<String> co = null; YaddaObjectID oid = request.getObject(); // we check history too if the request is for a specific version and metadata only if (request.isOnlyMetadata()) { CatalogObjectMeta meta; if (oid.getVersion() == null) meta = curdao.findMeta(oid.getId()); else meta = histdao.findMeta(oid); if (meta != null) co = new CatalogObject<String>(meta); } else { if (oid.getVersion() == null) co = curdao.findObject(oid.getId()); else co = curdao.findObject(oid); } resp.setObject(co); } catch (Exception e) { log.error("Exception caught", e); resp.setError(new YaddaError(ERROR_CODE, "exception caught", e)); } return resp; }